Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Image color detection using python

Tags:

python

I need to detect the color of an online image and save it in the name of the detected color.

imageurl='http://www.example.com/'
opener1 = urllib2.build_opener()
page1=opener1.open(imageurl)
my_picture=page1.read()
fout = open('images/tony'+image[s], "wb")
fout.write(my_picture)
fout.close()
like image 368
user244470 Avatar asked Feb 16 '10 05:02

user244470


People also ask

Which algorithm is used in color detection?

KMeans algorithm creates clusters based on the supplied count of clusters. In our case, it will form clusters of colors and these clusters will be our top colors. We then fit and predict on the same image to extract the prediction into the variable labels . We use Counter to get count of all labels.

Can OpenCV detect color?

OpenCV has some built-in functions to perform Color detection and Segmentation operations. So what are Color Detection and Segmentation Techniques in Image Processing? Color detection is a technique of detecting any color in a given range of HSV (hue saturation value) color space.

How can you identify a color?

Colour sensors detect colours by emitting light (RGB, red, green, blue) to a surface. The colour values ​​are calculated from the reflecting beams and compared with previously stored reference values.

What is colour detection system?

A color detection algorithm identifies pixels in an image that match a specified color or color range. The color of detected pixels can then be changed to distinguish them from the rest of the image.


1 Answers

Use a PIL (Python Image Library) histogram. Loop over the histogram and take the average of pixel color weighed by the pixel count.

like image 93
olooney Avatar answered Oct 07 '22 06:10

olooney