Created
January 2, 2013 06:19
-
-
Save cocuh/4432634 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 | |
from sys import argv | |
# 1 0 | |
# 2 3 | |
rawimg = Image.open('img.jpg') | |
rawimg = rawimg.crop((0,0,32,32)) | |
quadtree = [] | |
max_depth = 5 | |
length = 100 | |
#TODO | |
#2^max_depth | |
def is_this_true(img, depth=0): | |
flag = 0 | |
length = img.size[0] | |
if depth == max_depth: | |
for x in range(length): | |
for y in range(length): | |
rgb = img.getpixel((x,y)) | |
if sum(rgb)<256*3/2: | |
print 1, | |
return 1 | |
print 0, | |
return 0 | |
img_0 = is_this_true(img.crop((length/2,0,length,length/2)),depth+1) | |
img_1 = is_this_true(img.crop((0,0,length/2,length/2)),depth+1) | |
img_2 = is_this_true(img.crop((0,length/2,length/2,length)),depth+1) | |
img_3 = is_this_true(img.crop((length/2,length/2,length,length)),depth+1) | |
res = (img_0,img_1,img_2,img_3) | |
if img_0==0 and img_1==0 and img_2==0 and img_3==0: | |
return 0 | |
else: | |
return res | |
if __name__ == '__main__': | |
is_this_true(rawimg) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment