MATLAB Answers

how do i get a image which is present at the axes in gui?

조회 수: 11(최근 30일)
user06
user06 1 Mar 2015
답변: Image Analyst 1 Mar 2015
suppose i have two axes. and in one axes i have taken an image , now i want that after clicking on a button that image will transfer on to the 2nd axes in matlab gui..

  댓글 수: 0

로그인 to comment.

채택된 답변

Geoff Hayes
Geoff Hayes 1 Mar 2015
Anamika - how did you load the image into the first axes? If you are using GUIDE, you can save the image to the handles structure (see guidata for details) within the callback (or whatever) that loads the image into the first image. Then, in the button callback, just access the image from handles and load it into the second axes.
See this example for a question that is similar to yours.

  댓글 수: 0

로그인 to comment.

추가 답변(1개)

Image Analyst
Image Analyst 1 Mar 2015
Use getframe() and take the cdata field:
% Create sample data.
z = peaks(64);
surf(z);
colormap(jet(256));
% Get image from the axes container.
f = getframe(gca)
thisImage = f.cdata;
figure;
imshow(thisImage);
Of course it's best if you just use the original data, like Geoff suggested, if you can, but sometimes that's not convenient if you have to pass the array way down deep into a call stack. Using setappdata/getappdata is not much more onerous than the code I gave, but you must remember to call setappdata whenever you put new stuff into the axes, and I think you'd end up having to call getframe anyway if you wanted to capture any graphics you put into the overlay above the image.

  댓글 수: 0

로그인 to comment.

이 질문에 답변하려면 로그인을(를) 수행하십시오.

태그


Translated by