Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dominant "color" of an image

I have the following image:

enter image description here

What I want to do is "id" the individual strips based on their dominant color. What is the best approach to do this?

What I've done is used the image's value (HSV) and make a distribution on that value's occurrence. The problem is, for strip0 values [27=32191, 28=5433, others=8] strip1 values [26=7107, 27=23111, others=22]. I can't get a definitive distinction.

The project's main goal is to compare an actual yellow-colored paper to the strips and determine which strip is the most similar.

like image 594
user2034438 Avatar asked Feb 02 '13 03:02

user2034438


People also ask

What is a dominant color?

What is it? Dominant color is achieved when one color serves as the focal point in a photo. The color expresses more intensity among other colors in the picture. This type of photo tends to instantly catch the attention of the viewer.

How do you know if a color is dominant?

The most important thing to remember when determining dominant and recessive colors is that dominant colors always stand out. On a photograph, poster, or sign, a dominant color creates a single point of focus. Simply put, it is the spot that draws your attention. In contrast, recessive colors blend into the background.

What is the most dominant color?

Red is the most powerful color amongst all. It has a tendency to stimulate mind and attract attention.

How do you choose your dominant color?

Use the 60-30-10 rule. The formula works because it allows the eye to move comfortably from one focal point to the next. It's also incredibly simple to use: 60% is your dominant hue, 30% is your secondary color, and 10% is for an accent color.


2 Answers

First, since you know the boundaries of each strip in the reference image, the only problem possible here is that your reference image is noisy. A relatively overkill way to handle that is clustering the colors in each strip and taking the cluster's centroid as the representative color of the strip. In order to get a more meaningful response here, consider the CIELAB colorspace for this step. Doing this, and converting the results back to RGB, for the first strip I get the rgb triplet (0.949375, 0.879872, 0.147898), and for the second strip (0.945324, 0.857322, 0.129756) (each channel in range [0, 1]).

When you get a new image, you perform the same operation. But there are a lot of problems here. For instance, how are you handling the white balance in this input image ? Supposing you have no such problem, then now it is only a matter of finding the nearest color to the one you just found by the same process. To find the nearest color you have to use a meaningful colorspace for such thing too, and CIELAB is recommended again since the well established Delta-E functions are defined on it. See http://en.wikipedia.org/wiki/Color_difference for some such metrics, the simplest being the euclidean distance in CIELAB.

like image 151
mmgp Avatar answered Sep 21 '22 02:09

mmgp


Calibrate your equipment. If you do not calibrate your equipment, you will have arbitrary errors between the test sample and the reference. Lighting is part of your equipment.

Use edge detection and your knowledge of the reference strip's geometry (strips are equal width) to determine sampling regions. For each sampling region, extract an internal patch.

For the test strip, compute an image where each pixel is the max difference within a sampling window (e.g. 5x5). This will let you identify a relatively homogeneous region which is dissimilar to the outside region (i.e. the paper). Extract a patch.

Use downsampling to find an integrated color for each patch per svnpenn's advice. You can look at other computation methods later, but this should work quite well.

For weights wh, ws, wv, compute similarity = whabs(h0-h1) + wsabs(s0-s1) + wv*abs(v0-v1) between the test color and each reference color. You can look at other distance measures later, but this should work quite well. Start with equal weights. One perk to this method is that it behaves well regardless of the dimension or combination of dimensions under which the reference strip varies.

Sort the results to find the most similar and second most similar matches. Note that similarity is set up so zero is an exact match, and a big number is a poor match. Use the ratio of these two results to estimate the quality of the most similar match - if the first two matches are very close, it's probably not a great match to either.

like image 24
Jim Gray Avatar answered Sep 22 '22 02:09

Jim Gray