Images search engine search by the main color in the image
i want to know the method of the images search according to the main object co开发者_开发百科lor in the images or the most used color in the image.
is there any tutorial, or even a product to buy it?
I would like to programming a search engine works with this feature.
so, can anybody help me
thank you.
I have done similar work. My implementation can be found here http://code.google.com/p/hppg/ . Live example can be found at project home page. This search engine also features search by keyword and colors at the same time. All detailed information and code can be found at project home page. Hope so it helps :)
Every color has an RGB value, indicating the levels of Red, Green and Blue in the color. You could calculate the sum of all RGB values for each pixel and then divide by the number of pixels, to get the "average" color of an image.
Another way to do it is flatten the colors (change all last digits in the RGB values to 0, for instance #F8824A becomes #F08040) and then find the largest surface in the image with the same color.
Imagine a photo of someone in front of a white wall - by using the first method you would get a mix of white and the person's clothes and face. Using the second method you would get white, unless the "color-constant" area of the person's shirt is bigger than the visible part of the wall.
There must be other ideas, but this should get you thinking about what you want.
Another option is to convert the image to HSV space (Hue, Saturation, Value), and calculate the mean hue. If the mean hue falls within a particular range, then keep the image, otherwise discard it. The particular range depends on the color you're interested in. For example, for green-ish images, you'd want anything with a hue between 60 and 180 degrees. See the HSV diagram below:
The benefit of working in HSV as opposed to RGB is that HSV is more naturally connected to how humans perceive color. RGB is more suited for displaying information in an additive color system, i.e. a computer monitor.
Depending on how much time you're willing to spend on this, you may not necessarily have to implement your own search engine. Just feed your query to Google's Image Search, crawl all the images from the result, and filter them using the above method (or some other criteria, like deltreme suggested above). I recently did something similar to grab maritime coastguard videos from Youtube (luckily, the ones I wanted were predominantly blue).
For the search part, check out Google's APIs. I haven't used one for image searching, but their Youtube API was very helpful.
精彩评论