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

14 vues (au cours des 30 derniers jours)
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;

Réponse acceptée

Jyotsna Talluri
Jyotsna Talluri le 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

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by