save and loading ROIs

9 views (last 30 days)
Yong-Ho
Yong-Ho on 20 Aug 2013
I want to save ROIs that selected from a jpg image using imfreehand. And in other jpg image, I want load save ROIs and adjust their position separately. How can I save ROIs and read again?

Accepted Answer

Image Analyst
Image Analyst on 20 Aug 2013
I'd save them into a .mat file with the save() function, and recall with the load() function.
  3 Comments
Matt Kindig
Matt Kindig on 20 Aug 2013
What doesn't work about this approach? Your r1 should be back in the workspace after you call the load() command.
Image Analyst
Image Analyst on 20 Aug 2013
Edited: Image Analyst on 20 Aug 2013
Moving the ROI has nothing to do with saving and recalling it. First of all, you can get the (x,y) coordinates like this:
hFH = imfreehand();
% Get the x,y coordinates from the ROI object.
xy = hFH.getPosition;
x = xy(:, 1);
y = xy(:, 2);
plot(x, y, 'r-'); % Draw it over the image.
Next you need to move it. Probably the easiest thing for you to do is to have scrollbars, one vertical and one horizontal. In the vertical scrollbar callback, increment or decrement the y value, and in the horizontal scrollbar callback increment or decrement the x values. See the FAQ: http://matlab.wikia.com/wiki/FAQ#How_can_I_share_data_between_callback_functions_in_my_GUI.28s.29.3F. If you want to get fancier you could use the mousemove callback to drag the ROI around.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!