Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

get a list of colors that appear of the image python

'''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. 
Comment

PREVIOUS NEXT
Code Example
Python :: pd.generate_date 
Python :: dropdown menu with selenium python 
Python :: python lambda append to list and return it 
Python :: for con condicion 
Python :: To select a column from the database table, we first need to make our dataframe accessible in our SQL queries. To do this, we call the df.createOrReplaceTempView method and set the temporary view name to insurance_df. 
Python :: fix the error when you close turtle screen in your own main loop 
Python :: egt id of current object django 
Python :: create list python 
Python :: newton backward interpolation python code 
Python :: python matrices access column 
Python :: Delete files in folder by extension 
Python :: expected str instance, NoneType found 
Python :: 5.2.5: Counting 10 to 100 by ... 
Python :: pandas set index integer not float 
Python :: poision in chinese 
Python :: python packing circles 
Python :: opencv cartoonizer script 
Python :: make_interp_spline 
Python :: python console ending multiline input 
Python :: print fps in while loop python 
Python :: python run scp command 
Python :: how to get user id discord.py 
Python :: mute button tkinter 
Python :: visualizzare csv in pycharm pandas read_csv 
Python :: PyQT5 reset color 
Python :: django rest framework encrypt passwors 
Python :: dynamic frame latest record 
Python :: pandas seaborn distplot 
Python :: compute mean over y for same x numpy 
Python :: undefined variable in python 
ADD CONTENT
Topic
Content
Source link
Name
2+1 =