Dominant colors with Image package in python -


i have transparent image , trying extract major colors out of using image module's getcolor() method

y = image.open('img.png') y.getcolors() [out]: [(21841, 0), (13328, 1),  (8171, 2),  (2673, 3),  (1337, 4),  (1010, 5),  (892, 6),  (519, 7),  (379, 8),  (234, 9)] 

how actual color values (or names) corresponding these indexes?

enter image description here

i not sure whether following code snippet finding. convert image object rgba object , use getcolors() follows.

from pil import image  im = image.open('img.png') rgba_im = im.convert('rgba') print ( rgba_im.getcolors() )  """ <output> [(2673, (218, 215, 209, 255)), (379, (195, 29, 54, 255)), (21841, (208, 208, 209, 0)), (234, (206, 198, 185, 255)), (519, (201, 178, 176, 255)), (1337, (193, 188, 186, 0)), (8171, (182, 176, 174, 0)), (892, (178, 170, 165, 255)), (13328, (168, 26, 41, 255)), (1010, (107, 18, 19, 255))] """ 

Comments

Popular posts from this blog

amazon web services - S3 Pre-signed POST validate file type? -

c# - Check Keyboard Input Winforms -