Created
February 28, 2015 17:58
-
-
Save christianp/9116466cf56b62eb9300 to your computer and use it in GitHub Desktop.
number of white pixels in an image of a Norwegian flag 1000 pixels tall - https://twitter.com/wacnt/status/567836059054186496
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 | |
f=Image.open(r"2000px-flag_of_Norway.svg.png") # http://upload.wikimedia.org/wikipedia/commons/thumb/d/d9/Flag_of_Norway.svg/2000px-Flag_of_Norway.svg.png | |
white = 0 | |
scale = f.size[1]/1000.0 | |
for r,g,b,a in f.getdata(): | |
if (r,g,b)==(255,255,255): | |
white += 1 | |
white/(scale*scale) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
247338