Insignificant Changes in mean value of RGB for Different Images with contrary color

1 view (last 30 days)
Hello.I'm newbie here.I want to ask opinion about my coding.My project is to detect color changes in fish body segment with different level concentration of water impurities.Color changes are defined through mean value of RGB .Below are the codes
RGB1=imread('C:\Users\user\Documents\MATLAB\C330min1crop.jpg');
A=RGB1;
R=A(:,:,1);
I2=histeq(R);
Pixel_Values_Imred=single(I2);
mean_I2= mean(Pixel_Values_Imred(:))
G=A(:,:,2);
I3=histeq(G);
Pixel_Values_Imgreen=single(I3);
mean_I3= mean(Pixel_Values_Imgreen(:))
B=A(:,:,3);
I4=histeq(B);
Pixel_Values_Imblue=single(I4);
mean_I4= mean(Pixel_Values_Imblue(:))
figure, subplot(3,1,1),imhist(R),title('Red Color Histogram');
subplot(3,1,2),imhist(G),title('Green Color Histogram');
subplot(3,1,3),imhist(B),title('Blue Color Histogram');
After running the codes,results show just a little changes in mean value for rgb histogram which only changes in point value.I expect the results will show significant changes since even just looking at the images with naked eyes, the color differences between images are in contrary.For example RED histogram,mean value of (concentration 1)Image1=127.6574 and (concentration 2)image 2=127.4563.Changes are insignificant.My question is is it normal for the value to only change in point or there are errors in my coding?Please correct me if I'm wrong :)Thank you

Accepted Answer

Image Analyst
Image Analyst on 2 May 2015
I was just consulting with someone on a similar situation. They wanted to know why a rainbow/oil-slick-like corrosion/etching on metal did not show any meaningful difference in the delta E color change despite the surfaces looking quite different from nearly gray to pastel rainbows to vivid rainbows. Obviously one is a lot more colored than the other so delta E should show that right? No, not necessarily. When you use a colorimeter, spectrophotometer, radiometer, or digital image, you're calculating the location of the centroid color. Well two gamuts (clusters of points in RGB space or LAB color space) could have the same centroid but the cluster could be different widths, right? Look at my icon to the left. Imagine you had a point in that coordinate system for every pixel in your image. That collection of points is called the "gamut." So you can't just compare the distance between the centroids (the mean color) - you also have to look at the distance between every pixel and the mean color. That distance WILL be different if the cluster is larger or smaller. Attach your images and we can discuss in more detail.
  3 Comments
Image Analyst
Image Analyst on 2 May 2015
Yes, that illustrates my point well. In fact red and green are on opposite sides of the lab color space (which you should be using) - see my icon to the left. So the mean color will be near the neutral axis, and won't change much even if the entire image went to all gray!
Use the method I said and you should be able to see a more substantial difference. A couple of pointers though. First, you might want to mask out dark and black pixels if they don't contribute at all to any color change. Or maybe you might want to measure the area fraction of black. Secondly, you have bad focus and specular reflections. You can knock out the specular reflections/glints with crossed polarizers - on in front of the light source and one you can turn on the lens. Rotate it until the reflections go away.
Secondly you should convert the images to lab with rgb2lab(). This uses a "book formula". if you want to be absolutely accurate, like I need to be, then you will need to calibrate to a known color standard in the image, like the x-rite color checker chart (<http://xritephoto.com/ph_product_overview.aspx?ID=1257&action=overview ColorChecker Passport>, which has known LAB values. This is the only way to get reproducible lab values out because your RGB values can change on a photo-by-photo basis. For any given fish, I can make the RGB values almost whatever I want by adjusting camera settings (like exposure) and that's no good. So you must have a standard embedded in your pictures.
If you want to do color segmentation to get area fractions, you might take a look at several color segmentation demos in my File Exchagne http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862
suhaini abjalil
suhaini abjalil on 4 May 2015
thanks for your response.I did everything I could to follow your instruction,but I failed.I think this maybe because of my poor image.I cannot do anything about it since that is the only way for me to take the picture.I just used my phone camera to be honest.I took the picture by putting the fish in a box so that the image is not affected by surrounding light.the distance is fixed since I used the same box and level of zooming also fixed which is 2.Reflection cannot be avoided even after I wiped the fish surface from remaining water.Therefore, if you do not mind may I ask you another question.Can I used data cursor instead to read the value at the desired coordinate.The method is, I mark a fixed point on the image,then I insert the coordinate in the coding.I have to repeat this step for another image since the coordinate may altered a bit.This might sound silly but this is the only way where I can see significant changes.Here is the code
a=imread('C:\Users\user\Documents\MATLAB\matlabanswer2crop.jpg');
a(1048,380,:)
RED=a(:,:,1);
figure,subplot(1,2,1),imshow(a),subplot(1,2,2),imhist(RED);
I choose to show RED histogram because I red color changes can be clearly seen on the image. I want to ask your opinion about this.Is this logic to you?I have to confirm this method..:)Thank you

Sign in to comment.

More Answers (0)

Categories

Find more on Image Processing Toolbox in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!