how to create new figure with same image when you click on image in axes

1 view (last 30 days)
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.

Answers (1)

Walter Roberson
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
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 )
asif
asif on 21 Apr 2014
could you please make an example of it . i have attached my gui -m and fig files with my code. this guide part is really new to me.thank you

Sign in to comment.

Categories

Find more on Migrate GUIDE Apps in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!