필터 지우기
필터 지우기

extract regions detected by watershed segmentation

조회 수: 2 (최근 30일)
mariem farhat
mariem farhat 2013년 5월 22일
Hello,
I have found this code in image processing toolbox of matlab for image segmentation through watershed function:
Really, I gaven't understood the code, and I want to extract regions detected after segmentation with the function watershed and represent each region with its dominant color. So can you help me?
I want to extract those regions, so where find them?
Thanks

답변 (2개)

Image Analyst
Image Analyst 2013년 5월 22일
Once you have the binary image, you simply call regionprops() for each color channel to get the color for that color channel in each labeled region. See my demos for examples: http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862
% Extract the individual red, green, and blue color channels.
redChannel = rgbImage(:, :, 1);
greenChannel = rgbImage(:, :, 2);
blueChannel = rgbImage(:, :, 3);
% Now do your marker controled watershed segmentation
% to get your binary image. Then:
labeledImage = bwlabel(binaryImage);
% Make color measureents.
measurementsRed = regionprops(labeledImage, redChannel, 'MeanIntensity');
measurementsGreen = regionprops(labeledImage, greenChannel, 'MeanIntensity');
measurementsBlue = regionprops(labeledImage, blueChannel, 'MeanIntensity');
  댓글 수: 3
mariem farhat
mariem farhat 2013년 5월 22일
ok, thank you for your response.
mariem farhat
mariem farhat 2013년 5월 22일
but I haven't used regionprops like you have mentioned in your post because actually I want to compute the dominant color of each region and not the mean value. It remains false to use it like I have mentioned?

댓글을 달려면 로그인하십시오.


mariem farhat
mariem farhat 2013년 5월 22일
편집: mariem farhat 2013년 5월 22일
thank you for your response,
this is the code that I have implemented :
if true
f = unique (L);
n = size(f);
for i = 1:n
resultc (:,1:3) = 255;
[r c] = find(L==i);
m= size(r);
for j = 1:m
resultc(j,1) = rgb(r(j), c(j), 1);
resultc(j,2) = rgb(r(j), c(j), 2);
resultc(j,3) = rgb(r(j), c(j), 3);
end
coul(i,:) = mean_coul(resultc);
end;
end
after this I want to use the result of the mean of intensities to visualize the result such that for each object I print the mean color so I do llike this:
if
Lrgb = label2rgb(L, coul); end
but I got an error:
A message identifier must be followed by another input argument, of type char, representing the message text. *_??? Error using ==> label2rgb>parse_inputs at 147 Invalid entry for MAP.
Error in ==> label2rgb at 50 [label,map,zerocolor,order,fcnflag] = parse_inputs(varargin{:});
Error in ==> test at 241 Lrgb = label2rgb(L, coul);_*

카테고리

Help CenterFile Exchange에서 Get Started with Image Processing Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by