Restore or copy IMROI / IMFREEHAND objects?
조회 수: 5 (최근 30일)
이전 댓글 표시
Hello!
I have a question regarding IMFREEHAND:
I need to create similar ROIs in several similar images and therefore would like to be able to save the ROI objects and reload them onto new figure objects. The ROIs must remain editable after copying because their exact position might have to be readjusted. However, whenever I close the figure in which the ROIs were created, the IMROI objects are automatically deleted.
Is there a way to achieve what I want?
With IMRECT, you can specify an initial size and position for the ROI and use this feature to save and load ROIs, but this does not seem to be possible with IMFREEHAND.
Thanks, Matthias
댓글 수: 0
채택된 답변
Image Analyst
2012년 10월 12일
I believe that is not an option for imfreehand. Let's say you did have handles like imrect or impoly - they would be practically every pixel. Then what would happen if you tried to grab a handle and move it? Just one pixel would move and the rest of the outline would stay put because you didn't grab their handles. So your new outline would look like the old one with a sharp spike sticking out of it. That doesn't seem very useful.
댓글 수: 5
Image Analyst
2012년 10월 15일
You can save anything you want in a cell. Make a cell array so you have one row per image. Then start tossing stuff in there. Think of a cell like a bucket. You can throw anything you want into each bucket. The handles into one bucket, an array into another, a string into another. Then everything is saved in the cell array variable.
for k = 1 : numberOfImages
ca{k,1} = handleToROI;
ca{k,2} = fullFileName;
ca{k,3} = whatever;
end
추가 답변 (2개)
Matthias
2012년 10월 15일
댓글 수: 3
Image Analyst
2012년 11월 16일
Yes. See the FAQ: http://matlab.wikia.com/wiki/FAQ#How_can_I_share_data_between_callback_functions_in_my_GUI.28s.29.3F So just save the roi's and recall them later when needed.
Tim Jackman
2018년 9월 27일
The new drawfreehand ROI supports save/load. You can save the entire figure and reload it, or you can save the ROI into a mat file and reload the ROI later.
When reloading the ROI, you need to set the Parent property of the ROI to the new axes.
https://www.mathworks.com/help/images/ref/drawfreehand.html
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Graphics Object Programming에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!