How to find whether a ROI handle exist, if the ROI is not visible in the figure axes?
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Sudhanshu Goel
am 3 Okt. 2016
Bearbeitet: Xingwang Yong
am 30 Sep. 2022
I have a grayscale image in a GUI axes. I have to draw a ROI in the image using imellipse(). Now if I want to check whether ROI exist, isvalid() command works fine.
But if I draw a ROI and then make changes in the Image (eg: assign new values to some pixels and display the updated image in GUI axes) then isvalid command always returns false no matter the ROI exist or not.
Is there any way to check whether the handle of a ROI exist even if the ROI is not visible in current figure axes.
0 Kommentare
Akzeptierte Antwort
Matthew Eicholtz
am 3 Okt. 2016
Bearbeitet: Matthew Eicholtz
am 3 Okt. 2016
What do you mean by "display the updated image in GUI axes"? If you mean that you make a call to imshow or imagesc, then chances are you overwriting the current figure axes with the new image. In this case, the imellipse handle is no longer valid, not just "hidden" under the axes.
I suggest storing the Image to a variable, then updating the CData property of the Image, which will not clear the imellipse object.
Here is an example:
I = imread('peppers.png'); %sample image
J = rgb2gray(I); %sample modification to the image
h = imshow(I); %h is an Image object
e = imellipse(); %draw the ellipse on the figure
isvalid(e) %should return true
h.CData = J; %change the image in the figure without clearing the axes
isvalid(e) %should still return true
3 Kommentare
Xingwang Yong
am 30 Sep. 2022
Bearbeitet: Xingwang Yong
am 30 Sep. 2022
@Matthew Eicholtz I have a similar question. Can I access ROI object without saving the output of imecllipse()?
I = imread('pout.tif'); %sample image
h = imshow(I); %h is an Image object
imellipse(); %draw the ellipse on the figure
J = I;
J(1,1) = 1; %sample modification to the image
h.CData = J; %change the image in the figure without clearing the axes
% how to get the ROI object? then calculate something based on mask...
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!