How I can display the same image in axes in another figure?

3 ビュー (過去 30 日間)
sara khaled
sara khaled 2019 年 11 月 23 日
コメント済み: Walter Roberson 2019 年 11 月 24 日
I have two figures the first one contains axes to display image and push button to show the second figure and when the second figure open I want it to display in axes the same image that it is in the first figure. My problem is when I press the push button to display the second one,it doesn't display any image.
  2 件のコメント
Jan
Jan 2019 年 11 月 23 日
@sara: Please post the code. Otherwise it is hard to find the reason of the observed behavior or to suggest a solution.

サインインしてコメントする。

回答 (2 件)

sara khaled
sara khaled 2019 年 11 月 24 日
編集済み: sara khaled 2019 年 11 月 24 日
In OpeningFcn
if true
global im2
axes(handles. axes_imag);
imshow(im2)
end
When run the figure alone it displays the image that stored in the variable im2, but when I execute a program from the beginning to show this figure from a button in the previous figure in this case does not display the image.
  1 件のコメント
Walter Roberson
Walter Roberson 2019 年 11 月 24 日
Typically, at the time an OpeningFcn is executed, global variables have not been initialized, and so would have their default value of being empty, [] .
when I execute a program from the beginning to show this figure from a button in the previous figure
You need to be careful in executing one GUI from another GUI. Each GUI has its own handles structure, and communicating between GUIs gets tricky.

サインインしてコメントする。


sara khaled
sara khaled 2019 年 11 月 24 日
But how do I solve this problem.If there is any method please help me
  1 件のコメント
Walter Roberson
Walter Roberson 2019 年 11 月 24 日
  1. Don't use global.
  2. Do not default any graphics operations to the "current" axes: always specify the parent axes. For example, imshow(handles.axes_imag, im2)
  3. To get information from the handles of another figure, you must know something unique about the figure, such as a Tag that only it has, or the figure Name must be unique. Use findobj() to find some object unique to that other figure, then use other_handles = guidata(object_unique_to_that_other_figure); to get the handles structure of that figure.

サインインしてコメントする。

Community Treasure Hunt

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

Start Hunting!

Translated by