How to get image from axes in GUI matlab

6 ビュー (過去 30 日間)
twins
twins 2014 年 5 月 23 日
編集済み: saeed rehman 2016 年 12 月 14 日
Hello I have a question .. I load an image in axes in Matlab GUI , and I want to re-read this image in a variable and use this variable in other function .. What is the function which helps me on it . Thank you
  1 件のコメント
saeed rehman
saeed rehman 2016 年 12 月 14 日
編集済み: saeed rehman 2016 年 12 月 14 日
store loaded image in a variable and Use setappdata and getappdata .
axes(handles.axes2);
image(a);
setappdata(0,'image',a);
%%%
now get this image and load it in anyother axes or whatever u want.
im=getappdata(0,'image');
axes(handles.axes3);
image(im);

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

回答 (2 件)

Mahdi
Mahdi 2014 年 5 月 23 日
After knowing which axes handle the image is loaded into, you can simple use the getimage function.
  1 件のコメント
Naman Bansal
Naman Bansal 2014 年 7 月 27 日
This is fine but the problem I'm facing is to get the image after zooming i.e. I firstly loaded the image on axes and then performed the zoom operation. Now I only want the zoomed portion of the image. How can I do that.

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


Image Analyst
Image Analyst 2014 年 5 月 23 日
Try using getframe(). Or get(hAxes, 'CData');
  2 件のコメント
Naman Bansal
Naman Bansal 2014 年 7 月 27 日
This is fine but the problem I'm facing is to get the image after zooming i.e. I firstly loaded the image on axes and then performed the zoom operation. Now I only want the zoomed portion of the image. How can I do that.
Image Analyst
Image Analyst 2014 年 7 月 27 日
Naman, just like I told you. Look at this code:
close all;
im=imread('cameraman.tif');
subplot(1,2,1);
imshow(im);
subplot(1,2,2);
imshow(im);
size(im)
zoom(8);
zoomedImage = getframe(); % Get zoomed portion that is visible.
size(zoomedImage.cdata)
figure; % Bring up separate figure.
imshow(zoomedImage.cdata);
Do you see how in the second figure it is only the zoomed, visible portion of the image from figure 1 that was captured and is being displayed? From your post it sounds like you tried getframe() and it did not work for you for some reason. To fix it I'd have to see your code.

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

カテゴリ

Help Center および File ExchangeVisual Exploration についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by