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

1 次查看(过去 30 天)
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.

回答(1 个)

Walter Roberson
Walter Roberson 2014-4-21
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 个评论
Walter Roberson
Walter Roberson 2014-4-21
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 2014-4-21
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

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Migrate GUIDE Apps 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by