Dapatkan daftar warna yang muncul dari python gambar

'''First the defaultdict is populated with data from the image
using built-in getdata() method as follows:'''
from collections import defaultdict

by_color = defaultdict(int)
im = Image.open('myimage.jpg')
for pixel in im.getdata():
    by_color[pixel] += 1
#Then print the populated dictionary:    
print(by_color)
#################################Output################################
defaultdict(<class 'int'>, {(123, 131, 82): 31, (121, 131, 81): 24,...})
#Where the pixel, (123, 131, 82) is the key and the value 31 indicates-
#how many times this pixel appears on the image. 
Coderunner