Last active
February 6, 2018 19:05
-
-
Save ahmed-bhs/ab06286baea3abb1462d3448a756571d to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
im = Image.open("binpeg.jpg") | |
rgb_im = im.convert('RGB') | |
w,h= rgb_im.size | |
#size is 256 by 256 | |
st='' | |
k=0 | |
for x in range(h): | |
for y in range(w): | |
r, g, b = rgb_im.getpixel((y,x)) | |
if(r==0 and g==0 and b==0): | |
s=1 | |
else: s=0 | |
k=k+1 | |
if (k%8 == 0): | |
st+=str(s)+" " | |
else: | |
st+=str(s) | |
print st | |
# ctfs{YoU_n33d_Rob0t_To_r3ad} | |
# from PIL import Image | |
# im = Image.open("binpeg.jpg") | |
# rgb_im = im.convert('RGB') | |
# #size is 256 by 256 | |
# st='' | |
# for x in xrange(0,255): | |
# for y in xrange(0,255): | |
# r, g, b = rgb_im.getpixel((x, y)) | |
# if(r==0 and g==0 and b==0): | |
# s=0 | |
# else: s=1 | |
# st+=str(s) | |
# print st |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment