how to create new figure with same image when you click on image in axes
1 view (last 30 days)
Show older comments
i have a multiple set output images which are to be shown in axes of my gui. now when i click on any one image i want that image to show in a separate figure window.
0 Comments
Answers (1)
Walter Roberson
on 21 Apr 2014
set the callback for the image() object to something like,
function show_in_figure(hObject, event)
hfig = figure();
hax = axes('Parent', hfig);
copyobj(hObject, hax);
axes(hax, 'image');
end
3 Comments
Walter Roberson
on 21 Apr 2014
image(DataMatrixForThisImage, 'Callback', @show_in_figure);
The show_in_figure function could go in a separate .m file -- that is what I would suggest if you are using GUIDE, so that GUIDE does not accidentally overwrite the code when it rebuilds the .m
You can use exactly the same callback for multiple images. The hObject value that MATLAB passes to the callback will be the handle of the image that got clicked on.
Note: you might want to record the output of copyobj() and use it to set() the Position of the image within the axes -- you might also want to set() the Position and visibility of the new axes (which can, in this code, be referenced by hax )
See Also
Categories
Find more on Migrate GUIDE Apps in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!