Last active
June 4, 2016 20:20
-
-
Save rinchik/d023578a705d6d4a5b12e235c5a9df9a to your computer and use it in GitHub Desktop.
Calculating image region brightess
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
def process_region(self, image, x, y, width, height): | |
region_total = 0 | |
# This is the sensitivity factor, the larger it is the less sensitive the comparison | |
factor = 10 | |
for coordinateY in range(y, y+height): | |
for coordinateX in range(x, x+width): | |
try: | |
pixel = image.getpixel((coordinateX, coordinateY)) | |
region_total += sum(pixel)/4 | |
except: | |
return | |
return region_total/factor |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment