how do i get a image which is present at the axes in gui?
Show older comments
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..
Accepted Answer
More Answers (1)
Image Analyst
on 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.
Categories
Find more on Red in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!