Color differentation in the image
1 次查看(过去 30 天)
显示 更早的评论
采纳的回答
Image Analyst
2014-2-15
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 个评论
hamed abdulaziz
2014-2-15
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
2014-2-15
编辑:Image Analyst
2014-2-15
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
2014-2-15
移动:DGM
2023-12-30
Where these image are melanoma and the color variation is one of the features to detect this disease
Image Analyst
2014-2-15
Yes, calculating delta E and then getting the histogram, mean, and std dev of that should be good.
Image Analyst
2014-2-15
编辑:Image Analyst
2014-2-15
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
2014-2-15
编辑:hamed abdulaziz
2014-2-15
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
2014-2-15
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
2014-2-15
编辑:Image Analyst
2014-2-15
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
2014-2-15
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
2014-2-15
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
2014-2-16
编辑:hamed abdulaziz
2014-2-16
I don't know how to do that?please could you change the demo to work with my images,thanks.
Image Analyst
2014-2-16
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));
Image Analyst
2014-2-16
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
2014-2-17
编辑:hamed abdulaziz
2014-2-17
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
2014-2-17
That's from a line earlier in the demo:
[rows, columns, numberOfColorBands] = size(rgbImage);
hamed abdulaziz
2014-2-17
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
2014-2-17
移动:DGM
2023-12-30
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
2014-2-17
移动:DGM
2023-12-30
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
2014-2-17
移动:DGM
2023-12-30
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(:));
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!发生错误
由于页面发生更改,无法完成操作。请重新加载页面以查看其更新后的状态。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- 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)
亚太
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)