Can i use Color map to find which color is the most used color in an image ?
31 views (last 30 days)
Image Analyst on 23 Jun 2018
Edited: Image Analyst on 23 Jun 2018
You can display the 3-D color gamut with colorcloud(). Call that on your image and see what you think the dominant color is.
You might want too look at the Color Frequency Image. See this link
To give a good answer we need to know what you plan on doing assuming you had the "dominant color". If we knew that we might be able to suggest something. Post your image(s) and explain what you want to know about them or do with them assuming you knew the dominant color.
Finally, look at these fun web sites:
Jan on 23 Jun 2018
Edited: Jan on 23 Jun 2018
Walter is right. What is the dominant color of the French flag? Imagine a photo of a traffic light in the dusk. Most of the pixels are dark gray, but if you ask a person about the color, you get the answer green (or yellow, or red). Of course there are some rare examples, which allows a unique decision about the most frequent RGB or Lab color. But even then there is no unique relation to a name of a color. Do you remember the discussion about the blue/black or gold/white dress (link) ? Even human could not decide which color the image contain.
What is the basic method behind this ?
There is no basic method. If you have a clear and unique definition, and an exactly defined workflow considering the color profiles of the camera, monitor, etc., it can be implemented in Matlab.
Currently the best method is to show the image printed on paper or shown on a calibrated monitor to 10 persons. If they agree, there is a high chance that other human have the same impression.
Walter Roberson on 24 Jun 2018
topN = 50;
img = imread('demo.jpg');
rimg = reshape(img, , 3);
[urgb, ~, uidx] = unique(rimg, 'rows');
labs = reshape(uint32(uidx),size(img,1),size(img,2));
recolored = uint8(ind2rgb(labs-1, urgb));
counts = accumarray(uidx,1);
[sortedcounts, sortidx] = sort(counts,'descend');
mcc1 = urgb(sortidx(1),:);
mcc2 = urgb(sortidx(2),:);
title(sprintf('Most common color [%d,%d,%d]\n%d occurrences', mcc1, sortedcounts(1)));
title(sprintf('Second most common color [%d,%d,%d]\n%d occurrences', mcc2, sortedcounts(2)));
onlytop = double(ismember(labs,sortidx(1:topN)));
image(recolored, 'alphadata', onlytop);
title(sprintf('showing only top %d colors', topN));
set(gca, 'color', 'k')
You have to go to the 47th most common RGB combination to get one that is not essentially black. No yellow-ish RGB combination occupies more than 96 pixels.