How to create ROI object handle?
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
h = figure;
imshow(imread('pout.tif'));
imrect();
hg = findobj(h,'Type','hggroup')
% How can I "create" a ROI object so that I can call createMask()?
I'm trying to get ROI object handle, but it seems that it can not be retrieved after creation. Through property inspector, I found hggroup might be related to it. However, it is not the same as the handle returned by imrect().
Can I use hg to create a handle so that I can call createMask()?
Edit:
The main problem is that I have to get the ROI object after its creation. In my application, the ROI creation is done in a callback, thus I can not get an output from it. So I need to find out information about ROI object from figure handle.
0 Kommentare
Antworten (3)
Eric Delgado
am 30 Sep. 2022
Replace imrect for images.roi.Rectangle. See the first example of the doc - https://www.mathworks.com/help/images/ref/images.roi.rectangle.html
figure;
imshow(imread('pout.tif'));
% Directly draw your rectangle using your mouse:
roi = drawrectangle;
% Draw your rectangle programmatically:
% roi = images.roi.Rectangle(gca,'Position',[x,y,W,H]);
4 Kommentare
Image Analyst
am 3 Okt. 2022
Try this:
h = figure;
imshow(imread('pout.tif'));
uiwait(helpdlg('Drag out a box'))
rRect = imrect();
pos = rRect.getPosition
mask = rRect.createMask;
figure;
imshow(mask)
7 Kommentare
Simon Chan
am 3 Okt. 2022
You may try the following:
h = figure;
imshow(imread('pout.tif'));
imrect(); % not use the output of imrect()
ax=gca;
hAx=findobj(ax.Children,'-regexp','Tag','corner marker');
x = cat(1,hAx.XData);
y = cat(1,hAx.YData);
roi = [min(x) min(y), max(x)-min(x) max(y)-min(y)]
3 Kommentare
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!