how compute color std fast

3 views (last 30 days)
michael scheinfeild
michael scheinfeild on 9 Sep 2014
Commented: Image Analyst on 10 Sep 2014
hi i want to detect areas in image where there is large diffrence in color for example [r,g,b] = [130 120 137]--> new binary image 0 [r,g,b] = [60 190 87]--> new binary image 1 (large difrence of colors) so i do loop but it seems not efficient
for(mi=1:m)
for(ni=1:n)
newimg(mi,ni) = squeeze(std(imd(m,n,:)));
end
end
then i do threshold on newimg

Answers (3)

Image Analyst
Image Analyst on 9 Sep 2014
You don't want to do it the way you propose. Trust me - I teach courses on color science. Color difference is called "Delta E" and is pretty much the distance between the colors plotted in CIE LAB color space (see my avatar to the left). I have an application that computes the local Delta E and returns that as an image. You first compute that image and then threshold that. For example see in the image below that areas with high color variation are the edges and those are segmented out (by thresholding the delta E image in the middle row, left column), along with areas where the color doesn't change much.

Ahmed
Ahmed on 9 Sep 2014
Edited: Ahmed on 9 Sep 2014
The std function can operate on any dimension. For details see the help of 'std'.
newimg = std(imd,0,3);
It might be faster, if you re-order your data matrix 'imd' such that the third dimension becomes the first.
imd = permute(imd,[3 1 2]);
newimg = squeeze(std(imd,0));

Michael scheinfeild
Michael scheinfeild on 10 Sep 2014
i realy didnt get what you mean but my idea works great even it can overcome ilumination that homomorphic transform didnt succes , this is the histogram and it make great segmentation for my case , i cant put the segmented image due to security reasons
  1 Comment
Image Analyst
Image Analyst on 10 Sep 2014
OK, if your ad hoc method works for your images, then fine. Though, it doesn't measure color difference the same in different parts of color space because RGB color space is not linear with respect to human vision. For example the same stdDev around black or white does not produce the same apparent visual color difference to humans as when the colors are vivid red or blue. That's why CIE LAB color space was invented - see my avatar to the left. Hopefully some day you will have time to learn about color theory and the human visual system.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!