You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
Color differentation in the image
2 views (last 30 days)
Show older comments
Accepted Answer
Image Analyst
on 15 Feb 2014
What do you mean by differentiation? I have several color segmentation demos in my File Exchange if that's what you mean: http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862
26 Comments
hamed abdulaziz
on 15 Feb 2014
Thanks for your response,I have many coloured images some of them contains some color (red,blue,brown,and black)what I need to know how can I detect the color variation in the segmented image(ROI),could you help me by demo please?
Image Analyst
on 15 Feb 2014
Edited: Image Analyst
on 15 Feb 2014
If you have objects with a variety of vivid colors, then it's probably best to threshold the saturation image. See my Color segmentation using HSV demo in my File Exchange, or see this answer: http://www.mathworks.com/matlabcentral/answers/116126#answer_124379 Or perhaps you'd like this: http://www.mathworks.com/matlabcentral/fileexchange/37197-dem-diffused-expectation-maximisation-for-image-segmentation
hamed abdulaziz
on 15 Feb 2014
Please could you take a look to some my images that attached
Image Analyst
on 15 Feb 2014
OK, once you attach them.
hamed abdulaziz
on 15 Feb 2014
Moved: DGM
on 30 Dec 2023
hamed abdulaziz
on 15 Feb 2014
Moved: DGM
on 30 Dec 2023
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/174353/image.bmp)
hamed abdulaziz
on 15 Feb 2014
Moved: DGM
on 30 Dec 2023
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/174354/image.bmp)
hamed abdulaziz
on 15 Feb 2014
Moved: DGM
on 30 Dec 2023
Where these image are melanoma and the color variation is one of the features to detect this disease
Image Analyst
on 15 Feb 2014
Yes, calculating delta E and then getting the histogram, mean, and std dev of that should be good.
hamed abdulaziz
on 15 Feb 2014
Could you explain by demo please,thanks in advance
Image Analyst
on 15 Feb 2014
Edited: Image Analyst
on 15 Feb 2014
This demo shows you how to calculate the delta E image and get its histogram. http://www.mathworks.com/matlabcentral/fileexchange/31118-color-segmentation-by-delta-e-color-difference.
hamed abdulaziz
on 15 Feb 2014
Edited: hamed abdulaziz
on 15 Feb 2014
OK, I will accept please could adapt your excellent demo for calculating delta E and then getting the histogram, mean, and std dev for use it with my images ,thanks
hamed abdulaziz
on 15 Feb 2014
Image Analyst : please could you help me for calculating delta E and then getting the histogram, mean, and std dev for use it with my images ,thanks
Image Analyst
on 15 Feb 2014
Edited: Image Analyst
on 15 Feb 2014
Make sure you take the mask into account.
pixelsInsideMask = deltaE(mask); % 1D vector of pixels only within mask.
counts = hist(pixelsInsideMask, numberOfBins);
meanDeltaE = mean(pixelsInsideMask(:));
SDDeltaE = std(pixelsInsideMask(:));
hamed abdulaziz
on 15 Feb 2014
Ok , I tried your demo but I need to all operation automatically (not clicking by mouse) what I need is to get the color variation as a indication for disease feature
Image Analyst
on 15 Feb 2014
You just change/adapt it so that it takes the mean color from your whole image (or the masked part). Do you know how to do that?
hamed abdulaziz
on 16 Feb 2014
Edited: hamed abdulaziz
on 16 Feb 2014
I don't know how to do that?please could you change the demo to work with my images,thanks.
Image Analyst
on 16 Feb 2014
Find the mask something like this:
% Extract the individual red, green, and blue color channels.
redChannel = rgbImage(:, :, 1);
greenChannel = rgbImage(:, :, 2);
blueChannel = rgbImage(:, :, 3);
% Find where all of them are zero.
mask = redChannel == 0 & greenChannel == 0 & blueChannel == 0;
Then convert rgb to lab and get mean lab like this:
meanL = mean(lChannel(mask));
meanA = mean(aChannel(mask));
meanB = mean(bChannel(mask));
hamed abdulaziz
on 16 Feb 2014
Then how can I get the DELTA E after getting the meanL ,meanA,and meanB ?
Image Analyst
on 16 Feb 2014
Like it shows in the demo:
% Make uniform images of only that one single LAB color.
LStandard = LMean * ones(rows, columns);
aStandard = aMean * ones(rows, columns);
bStandard = bMean * ones(rows, columns);
% Create the delta images: delta L, delta A, and delta B.
deltaL = LChannel - LStandard;
deltaa = aChannel - aStandard;
deltab = bChannel - bStandard;
% Create the Delta E image.
% This is an image that represents the color difference.
% Delta E is the square root of the sum of the squares of the delta images.
deltaE = sqrt(deltaL .^ 2 + deltaa .^ 2 + deltab .^ 2);
% Mask it to get the Delta E in the mask region only.
maskedDeltaE = deltaE .* mask;
% Get the mean delta E in the mask region
% Note: deltaE(mask) is a 1D vector of ONLY the pixel values within the masked area.
meanMaskedDeltaE = mean(deltaE(mask));
where meanL is just Lmean by a different name.
hamed abdulaziz
on 17 Feb 2014
Edited: hamed abdulaziz
on 17 Feb 2014
how can determine the the number of(rows and columns) in the
LStandard = LMean *
ones(rows, columns);
and can I use the value of deltaE in the
deltaE = sqrt(deltaL
.^ 2 + deltaa .^ 2 +
deltab .^ 2);
as a feature for color variation?
I tried this code
clear all;
clc;
close all;
% rgbImage= imread('D:\final_segmentation\segmentation_abnormal\200AC.BMP');
rgbImage= imread('D:\3.BMP');
% Find the mask something like this:
% Extract the individual red, green, and blue color channels.
redChannel = rgbImage(:, :, 1);
greenChannel = rgbImage(:, :, 2);
blueChannel = rgbImage(:, :, 3);
% Find where all of them are zero.
mask = redChannel ==
0 & greenChannel ==
0 & blueChannel ==
0; % Then convert rgb to lab and get mean lab like this:
% Convert image from RGB colorspace to lab color space.
cform =
makecform('srgb2lab'
);
lab_Image =
applycform(im2double
(rgbImage),cform); % Extract out the color bands from the original image % into 3 separate 2D arrays, one for each color component.
LChannel = lab_Image(:, :, 1);
aChannel = lab_Image(:, :, 2);
bChannel = lab_Image(:, :, 3);
LMean =
mean(LChannel(mask));
aMean =
mean(aChannel(mask));
bMean =
mean(bChannel(mask));
[rows,
columns]=size(LChann
el);
% Make uniform images of only that one single LAB color.
LStandard = LMean *
ones(rows, columns);
aStandard = aMean *
ones(rows, columns);
bStandard = bMean *
ones(rows, columns); % Create the delta images: delta L, delta A, and delta B.
deltaL = LChannel - LStandard;
deltaa = aChannel - aStandard;
deltab = bChannel - bStandard; % Create the Delta E image. % This is an image that represents the color difference. % Delta E is the square root of the sum of the squares of the delta images.
deltaE = sqrt(deltaL .^ 2 + deltaa .^ 2 + deltab .^ 2);
but I always get deltaE = zero
thank you
Image Analyst
on 17 Feb 2014
That's from a line earlier in the demo:
[rows, columns, numberOfColorBands] = size(rgbImage);
hamed abdulaziz
on 17 Feb 2014
THANK YOU I ATTACHED WAHT I TRIED (MY_DELTA_E) CODE HOW CAN USE FOR COLOR VARIATION INDICATOR PLEASE COULD CHECK IT FOR CORRECTNESS THANK YOU
hamed abdulaziz
on 17 Feb 2014
Moved: DGM
on 30 Dec 2023
I ATTACHED WAHT I TRIED (MY_DELTA_E) CODE HOW CAN USE DELTA_E FOR COLOR VARIATION INDICATOR PLEASE COULD CHECK IT FOR CORRECTNESS
Image Analyst
on 17 Feb 2014
Moved: DGM
on 30 Dec 2023
Looks about right for as far as you got. You just need to complete it to find the variation using code I gave you in my answer:
pixelsInsideMask = deltaE(mask); % 1D vector of pixels only within mask.
counts = hist(pixelsInsideMask, numberOfBins);
meanDeltaE = mean(pixelsInsideMask(:));
SDDeltaE = std(pixelsInsideMask(:));
hamed abdulaziz
on 17 Feb 2014
Moved: DGM
on 30 Dec 2023
Please did you check (MY_DELTA_E) CODE wher do I add your code?could you complet it and check it on the above images,thanks
pixelsInsideMask = deltaE(mask); % 1D vector of pixels only within mask.
counts = hist(pixelsInsideMask, numberOfBins);
meanDeltaE = mean(pixelsInsideMask(:));
SDDeltaE = std(pixelsInsideMask(:));
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)