Compare color of images
9 次查看(过去 30 天)
显示 更早的评论
I have two standard shades of green.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/153830/image.jpeg)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/153833/image.jpeg)
I also have a test image ( a leaf with black background).
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/153836/image.jpeg)
Can you show me how to compare the test image with the 2 standard images and determine where the test image falls closer, in terms of color, among the 2 standard images.
thank you.
0 个评论
采纳的回答
Image Analyst
2013-12-19
I know we've talked about this before, a few months ago or so. First segment out the green leaf - get a binary image that is true where the leaf is and false where the leaf isn't. For example use the green mask like Walter showed you. Then the most widely used method in the color industry is to calculate the "Delta E" (which is the color difference). You convert RGB into LAB and then calculate the Euclidean distance between the two points in LAB color space. At least that's the simplest which is probably okay for you. Remember we talked about using a color checker passport to calibrate your images. Otherwise you're just using "book formulas" - which might be okay if you just want to find out which standard is closest. But if you ever want to graduate to a fully calibrated system, you'll have to use a standard such as the Color Checker Passport or the Munsell soil chart or the X-rite Color checker.
See my delta E demo in my File Exchange. http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862
8 个评论
更多回答(2 个)
Walter Roberson
2013-12-19
leaf_mask = LeafImage(:,:,2) > 32; %adjust the 32 if you want
inleaf_pixels = reshape( LeafImage(leaf_mask(:,:,[1 1 1])), [], 3);
leaf_mean = mean(inleaf_pixels, 1);
Now likewise you can find the mean colors for the two shades. With those in place, you can norm() the difference in mean colors (i.e., take the Euclidean distance)
6 个评论
Image Analyst
2013-12-19
You can probably find out which color it is closest to in any color space, but the more professional way that the pros use is LAB or HSV color space since it's more relevant to human vision than RGB space - in fact that's the whole reason why they were invented.
Ashish Dahal
2020-11-24
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/425563/image.png)
Hello Everyone,
I hope everybody is doing well. I want to know the color difference from shifting from YellowA to Yellow B to Yellow C. And same for the other colours from shifting from A to C. Or what is the relative change from going from YellowA to Yellow C?and same for other colours?
Best Regards
Ashish
1 个评论
Image Analyst
2020-11-24
编辑:Image Analyst
2020-11-24
This is not an Answer. You should have started your own question. Anyway...
You can use delta E but first you have to get control over your image capture situation. Right now I can immediately see that it's a total mess.
First of all, the items are not even in the same location. Look how we're looking at the right side of the "A" objects but the left side of the "C" objects. They should all be centered in the field of view.
Secondly, you don't have control over your lighting. Just look how the background brightness varies. Presumably it's the same white background but it's not the same from snapshot to snapshot so how can we know if the color difference is due to illumination change, camera exposure change, or due to the object changing color?
Third, what about your camera? Are you using a flash? Hopefully not because flashes are not consistent in their light output. Are you using the camera in manual mode, or is it fully automatic? It should be in manual mode since you don't want the camera automatically changing anything or else you won't know if the color change is true to the object or just a side effect of the camera changing something.
Fourth, you need a color standard in there, like the X-rite Color Checker Chart. It should be in the field of view next to the disc. Then you can do a true calibration from RGB to CIELAB and that will help alleviate any of the exposure differences that might still remain. See attached tutorial for how to color calibrate a digital imaging system.
If you get control over those then you still should do a background correction to correct for the lens shading and illumination non-uniformities.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Image Segmentation and Analysis 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!