How to delete a ROI after having drawn a new one

5 次查看(过去 30 天)
Hello all.
In my program I create a square roi using imrect and impoly, the user has to position, resize and roate it on the image as he sees fit, but when the user resizes and rotate the roi a new one is created... Im having problems erasing the old one from the image. Does anybody has an idea how could I do that?
I already tried a function from Image Analyst -
function ClearLinesFromAxes()
axesHandlesToChildObjects = findobj(gca, 'Type', 'line');
if ~isempty(axesHandlesToChildObjects)
delete(axesHandlesToChildObjects);
end
return; % from ClearLinesFromAxes
but it clears all the image and I already have some other plots on it that shouldn't be erased...
and tried also - set(ROI_Q,'Visible','off')
Thanks

采纳的回答

Matt Kindig
Matt Kindig 2013-2-25
Probably the most robust way is to save the handles to imrect/impoly and then delete just that object. Something like this:
hrect = imrect(IMG) % your imrect code here
hpoly = impoly(IMG) % your impoly code here
%and then later when you want to delete it:
delete(hrect);
delete(hpoly);

更多回答(0 个)

标签

Community Treasure Hunt

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

Start Hunting!

Translated by