comparing colour similairty of two images
Show older comments
hi,
I have two RGB images of same size (250x250 or 100x100 depending on the program); but i need to get a value for the two images colour similairty. I have seen people saying that Delta E or Euclidean Distance for its similarity but i dont know how to get a double value for this. I basically just want to know how much of the same colours are used in image A and Image B.
Sorry if that sounds confusing. Thanks in advance
Answers (1)
Image Analyst
on 21 Apr 2015
0 votes
I was just talking about that today. Two engineers from our manufacturing group called me in today to consult on the very same general problem (quantifying color difference), and a month ago from someone in R&D on a totally different color comparison problem. It really depends on what you want to detect. For example do you just want a single metric about how different are images that are substantially the same? Do you want to compare discolorations for two images that are not substantially the same, spatially? Do you want to detect if your component "spot colors" in your manufacturing process are no good? Do you want to detect if your image is not being printed due to dithering problems or misalignment of print heads, or a print head being clogged?
Anyway, you can use delta E, or you can compare quantized gamuts, or you can use custom algorithms like the one these people developed. It just depends on what information would be useful to you. Maybe you can post a "good" image and a "bad" one that you want to compare to the good one.
10 Comments
Mohammed Khan
on 21 Apr 2015
Image Analyst
on 21 Apr 2015
Are they synthetic computer graphic images of pure colors? Are they images of some printout or package that was scanned in with a flatbed scanner? Are the "test" and "reference" image aligned/registered? The brain-dead simple way is to just subtract the images. If the images are the same, the subtraction will be zero. Of course that dumb algorithm has many, many problems with real world images, as you can imagine, meaning you can think of many situations where the two images can be "the same" but the subtraction is non-zero (for example misaligned images or different exposures, etc.).
Mohammed Khan
on 21 Apr 2015
Image Analyst
on 21 Apr 2015
No, that's really simplistic thinking. I can suggest two non-MATLAB ways to do it.
One is to use Google Images. Go to Google, click images, at the far right end of the search field click the camera, upload your logo from your computer, and see what it comes up with. I'm not sure what they do but it's probably a full CBIR search.
Another one just goes based on colors, so it's only like a partial/limited CBIR search. But it's a whole lot of fun. It's this: http://www.npr.org/blogs/thetwo-way/2010/12/10/131960390/color-picker-sorts-flickr-photos-for-fun
And a similar one is this: http://labs.tineye.com/multicolr/#colors=445e9a;weights=100; Again, a lot of fun, though it's just based on color, not other features like shape, etc. like Google probably does.
Mohammed Khan
on 21 Apr 2015
Image Analyst
on 21 Apr 2015
meanRed = mean2(rgbImage(:,:,1));
meanGreen = mean2(rgbImage(:,:,2));
meanBlue = mean2(rgbImage(:,:,3));
Mohammed Khan
on 21 Apr 2015
Image Analyst
on 21 Apr 2015
% Get means of first image
meanRed1 = mean2(rgbImage1(:,:,1));
meanGreen1 = mean2(rgbImage1(:,:,2));
meanBlue1 = mean2(rgbImage1(:,:,3));
% Get means of second image
meanRed2 = mean2(rgbImage2(:,:,1));
meanGreen2 = mean2(rgbImage2(:,:,2));
meanBlue2 = mean2(rgbImage2(:,:,3));
Mohammed Khan
on 21 Apr 2015
Edited: Mohammed Khan
on 21 Apr 2015
Image Analyst
on 21 Apr 2015
You need to cast to double so you can get negative values. Then take the absolute value
deltaR = abs(double(meanRed1) - double(meanRed2));
deltaG = abs(double(meanGreen1) - double(meanGreen2));
deltaB = abs(double(meanBlue1) - double(meanBlue2));
I don't know your definition of similar. I don't know how close they need to be to be "similar". Maybe 10 is fine, maybe 20, maybe 30. That's your choice.
Categories
Find more on Image Arithmetic in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!