Created
March 6, 2016 19:09
-
-
Save miek/25eeb17b74c6a8d0a22b to your computer and use it in GitHub Desktop.
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
from PIL import Image | |
import struct | |
import sys | |
imgsize = 128 | |
img = Image.new('L', (imgsize, imgsize)) | |
with open("lily.cfile", "rb") as f: | |
while True: | |
sample = f.read(8) | |
if sample: | |
csample = [(x + 1) / 2 for x in struct.unpack("ff", sample)] | |
(x, y) = [int(imgsize * x) for x in csample] | |
img.putpixel((x, y), img.getpixel((x, y)) + 1) | |
else: | |
break | |
img.save('out.png') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment