If ROI is already outlined how to mask ROI without using imfreehand function output parameters?

조회 수: 1 (최근 30일)
I have detected the region of interest in an image without using imfreehand function. Now I want to mask inside the ROI which I have outlined in red line as shown in below image. http://img534.imageshack.us/img534/4272/output3l.jpg
I am stuck up with following part of code.
hFH = imfreehand();
binaryImage = hFH.createMask();
xy = hFH.getPosition;
I dont want to use imfreehand as I have already detected ROI. So in above code what should I assign to hFH?
Can somebody please help me with this? Thanks in advance for your help!
  댓글 수: 3
Amith Kamath
Amith Kamath 2013년 1월 7일
hFH would be an object inherited from the imroi class, and the methods available for it are
methods imfreehand
As far as I understand your question, you are trying to compare pixel values from your ROI with a freehand ROI using imfreehand? Would that not be possible by just an and between the ROI and your image?
Prashant Kashid
Prashant Kashid 2013년 1월 7일
Yes you are partially right. My intention here is to mask the ROI which I have already detected using Random Walker algorithm (& obviously without using imfreehand). If I could able to mask the ROI it would be helpful to proceed further for calculations such as Area, Centroid, Perimeter etc. It would be a great help if somebody could help me to mask the ROI as discussed above.

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

채택된 답변

Image Analyst
Image Analyst 2013년 1월 7일
I'm not sure what you're asking. What is "the ROI" - the area you drew with imfreehand(), or the white binary blob inside that, or the whole image?
And what does " the similar values from the "Region of Interest"" mean? Do you mean the gray levels in that ROI?
I don't understand what you're going to "apply the mask" to? What is the mask anyway? Is it the same as the ROI, or is it something else?
  댓글 수: 9
Image Analyst
Image Analyst 2013년 1월 9일
If somebody masked the image like that, and saved it as an RGB image, then you need to find the red:
% Extract the individual red, green, and blue color channels.
redChannel = rgbImage(:, :, 1);
greenChannel = rgbImage(:, :, 2);
blueChannel = rgbImage(:, :, 3);
% Find the outline by itself.
redOutline = (redChannel == 255) & ...
(greenChannel == 0) & ...
(blueChannel == 0);
% Fill it in
filledRedMaskImage = imfill(redOutline, 'holes');
% Count pixels
areaInPixels = sum(filledRedMaskImage (:));
Prashant Kashid
Prashant Kashid 2013년 1월 9일
I tried it on my image and worked like a magic. Thanks a Million!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Image Segmentation and Analysis에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by