Created
February 8, 2015 15:17
-
-
Save im-denisenko/35b7897d3e511905b28d 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
#!/usr/bin/env python | |
from PIL import Image | |
import binascii | |
import numpy as np | |
# Read image and convert pixels to array | |
im = Image.open('/home/someone/Downloads/picture.png') | |
matrix = np.array(im) | |
# Convert array to binary string (excluding red borders) | |
message = '0b' | |
for row in matrix: | |
for item in row: | |
if item in (0, 1): | |
message += str(item) | |
# Convert binary string to ascii | |
message = binascii.unhexlify('%x' % int(message, 2)) | |
# And print result... | |
print message |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment