Created
April 11, 2019 15:00
-
-
Save sam-thecoder/518b6664f101880e3eaf72609434c702 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
def get_hsv_positions(image, positions): | |
#hsv comes in hue (color of image), saturation and value that's supposed to be how light or dark the color is | |
image = image.filter(ImageFilter.BLUR) | |
hsv_image = image.convert('HSV') | |
values = [] | |
for pixel in positions: | |
values.append(hsv_image.getpixel(tuple(pixel))) | |
hues = set([x[0] for x in values]) | |
hue_matches = [] | |
width, height = image.size | |
img_width, img_height = 0,0 | |
for _ in range(width * height): | |
if img_width == width: | |
img_height += 1 | |
img_width = 0 | |
pixel = hsv_image.getpixel((img_width, img_height)) | |
if pixel[0] in hues: | |
hue_matches.append((img_width, img_height)) | |
img_width += 1 | |
return hue_matches |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment