Ericko
Ericko

Reputation: 132

Color based image search engine on PHP

I need to make a PHP a color based search, where user will click on a color on a palette and the search will retrieve all images with predominant similar colors.

Restults will be sorted in descending order from images with the most similar colors.

Can anyone point out some guidelines or existing classes, examples, etc.. on how to achieve this?

Specially how will the "aproximation" or "similar" part of the search will need to be? How to select different kinds of "orange" and sort them from the most similar to the most off.

Thanks

Upvotes: 2

Views: 7034

Answers (5)

v.tmab
v.tmab

Reputation: 21

I think using an algorithm like Color coherence vector might be so helpful in this case, because the algorithm finds the connected components of the colors in the image and defines a set of coherent colors and incoherent ones.

"Coherent colors" is another term to describe predominant colors which is what you are looking for. Probably, you will just use these coherent colors' features which you can match against user's choice.

This tutorial Image Retrieval: Color Coherence Vector describes describes the steps of the algorithm with examples of how it works and some of its drawbacks. btw, I think these drawback wouldn't affect your use case, since you are mainly looking for matching a predominant color regardless of where it is.

Upvotes: 1

Chris G
Chris G

Reputation: 21

Here's an example of how I've analysed images using php GD lib functions. From here you just need to store the analysed data in a DB to use during the search.

Full details can be found here: http://www.colab-aktiv.com/?page_id=263

The basic steps are as follows:

  • Define the colors in the color swatches

  • Create an image object using the image that is to be analysed, resizing the image if it is too large

  • Create an image object and load the colors from the the color swatches into image palette. This is the palette that a GIF image uses. This is the comparison palette that the colors in the image being analysed will be compared to.

  • Loop through all the pixels in the image and tally it against the closest match to the pixel in the comparison palette.

  • Sort the tally results in descending order

  • Display the top results

Upvotes: 2

Remdex
Remdex

Reputation: 148

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. 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 :)

Upvotes: 1

bcosca
bcosca

Reputation: 17555

First, you shouldn't search a library of images on the fly. That will be exceedingly slow specially if you have to find the predominant color of each image. You need something like a crawler, but specifically for images.

To find out the predominant color, you'll need some solid math foundation for that:

http://en.wikipedia.org/wiki/Normal_distribution

Upvotes: 1

Related Questions