Created
May 13, 2012 16:11
-
-
Save foota/2689099 to your computer and use it in GitHub Desktop.
Image file from tetration fractal data
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import sys, os | |
from PIL import Image | |
def main(args): | |
if len(args) < 3: | |
print >>sys.stderr, "Usage: %s datafile imagefile" % os.path.basename(args[0]) | |
sys.exit(1) | |
datafile, imagefile = args[1:3] | |
f = file(datafile) | |
sw, sh = map(int, f.readline().strip().split()) | |
im = Image.new("RGB", (sw, sh)) | |
for y, l in enumerate(f): | |
for x, data in enumerate(map(int, l.strip().split())): | |
rgb = (data % 4 * 64, data % 8 * 32, data % 16 * 16) | |
im.putpixel((x, y), rgb) | |
#im.show() | |
im.save(imagefile) | |
if __name__ == "__main__": main(sys.argv) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://handasse.blogspot.com/2012/05/blog-post.html