Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find images of similar color

Based on suggestions here @ SO, I have cataloged the average color for a set of stock images.
r,g,b = image.convert("RGB").resize((1,1), Image.ANTIALIAS).getpixel((0,0))

Now, I would like to present a color wheel to the user and run a search against my catalog to find images that are the closest match to the color selected.

I have read through several questions posted here that recommend "finding the distance between two colors", and reference the Flickr Hacks book.

The Flickr Hack distance algorithm seems to be basically:


diffr = checkImage.r - search_r
diffg = checkImage.g - search_g
diffb = checkImage.b - search_b
distance = (diffr * diffr + diffg * diffg + diffb * diffb)
if distance < threshold then matched.


This method would require me to calculate the distance between my search color and every image's color fingerprint. I was wondering if there is a way to somehow specify a "search area" based on the selected color (center point) and a pre-determined threshold (or search radius). Then construct a SQL like query to return all images that fall within this area.

Is this possible??

BTW, I'm implementing this in Python using PIL and related libraries.

Thanks for your help SO!

SR

like image 706
Shaheeb Roshan Avatar asked Jun 01 '09 18:06

Shaheeb Roshan


People also ask

How do I find pictures with the same color?

Visit Site. A powerful yet often overlooked feature of Google Image Search is the ability to narrow your results by color. In the nav bar click on search tools and use the color dropdown to filter your images.

What is color extraction?

Color extraction from images allows for keyword tagging of visuals by color. This makes it possible to easily navigate large databases containing visuals. As color differentiation is essential for categorizing images, it allows for searching and browsing based on color tagging.

How do I search for a color on Google?

When you see results, click the “Tools” button in the toolbar just below the search area near the top of the page. Another small toolbar will appear just below. Click the “Color” menu, then pick a color square from the choices.


1 Answers

Color difference (Delta E) - the difference or distance between two colors is a metric of interest in color science.

You can find Python code here

Note that you need to convert RGB to Lab before calculating Delta E.

RGB -> XYZ -> Lab

Additional info:

Bruce Justin Lindbloom site

Color conversion math and formulas

Color delta/comparison math

like image 103
Pylyp Avatar answered Oct 12 '22 04:10

Pylyp