Recover image from current figure without saving it

2 views (last 30 days)
Suppose I have:
figure
imshow(matrix)
hold on
scatter(x2,y2,size2,color2, 'filled')
axis square
axis off
colormap(c)
saveas(gcf,'image2.jpg','jpg')
A=imread('image2.jpg');
imshow(A);
QUESTION: how do I recover composite image A without having to save image2.jpg on the first place? there should be a shortcut!! Any help?

Accepted Answer

Image Analyst
Image Analyst on 3 May 2013
Why do you want it? It wouldn't be just your image, it would be that plus border padding, tick marks (if axis was "on"), title, etc. Of what use is this to your program if it were to be a variable (an image variable)?
That said, you can use getframe().
  2 Comments
Mario Trevino
Mario Trevino on 3 May 2013
works fine, but with getrame im not getting a matrix2 the same size as the original one....
Image Analyst
Image Analyst on 3 May 2013
It won't be the size of the image of course, since you're grabbing extra stuff, and it also depends on how you sized the figure on the screen. What's your image size, what's your saved figure size, and what size are you expecting?
Have you tried export_fig()? See http://www.mathworks.com/matlabcentral/fileexchange/ for the most popular download.

Sign in to comment.

More Answers (0)

Categories

Find more on Images 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!