MATLAB Answers

How do I display the binary mask of a polygon ROI that was selected in an axis containing overlayed images?

10 views (last 30 days)
I am working with an overlayed image, where I've turned the transparency down. I would like to set a polygon ROI and display the binary mask of the ROI for the image. However, because there are multiple images in the axis, the function is throwing me an error:
"Error using images.roi.internal.mixin.CreateMask/validateInputs
Ambiguous syntax. Associated axes contains more than one image. Specify image handle as input argument to resolve ambiguity.
Error in images.roi.internal.mixin.CreateMask/createMask"
It seems like this wasn't a problem in previous versions since you could specify the image handle. Is there some way to access the roi of the different image in the Polygon object? (Matlab R2020a)
Here's some example code of what I'm trying to do:
I1 = imread('cell.tif');
I2 = imread('cameraman.tif');
im1 = imshow(I1,[]); hold on;
im2 = imshow(I2,[]);
set(im2, 'AlphaData', 0.6)
roi = drawpolygon(gca);
bw = roi.createMask;

  0 Comments

Sign in to comment.

Accepted Answer

Jyotsna Talluri
Jyotsna Talluri on 31 Mar 2020
If there are multiple images on the axis , you have to specify the image handle as a input argument to the createMask function
bw = roi.createMask(im2);
This works fine in the latest version R2020a of MATLAB also

  0 Comments

Sign in to comment.

More Answers (0)


Translated by