4

I generate a picture in an axes that is called newIM when I click on the apply button. Now, I want to save this new picture in a jpg, gif, bmp or whatever file when I push the save button.

This is what I had:

pathname = 'D:\pictures\';
filename = 'Test.bmp';
both = strcat(pathname, filename);
imshow(both);
imsave('test','*.jpg')

But this is only for a Test.bmp and not for the picture in newIM.

How can I make this variable?

HebeleHododo
  • 3,620
  • 1
  • 29
  • 38
user1008374
  • 41
  • 1
  • 2
  • You just want to save a figure? Use the `Save As...` item from the file menu and choose the desired format. Or did I misunderstand you? – reve_etrange Oct 22 '11 at 10:34
  • @reve_etrange `Save As...` saves the figure including boundaries and labels. It takes a different approach to save only the axes contents. – Xyand Oct 22 '11 at 11:34
  • @user1008374: how exactly do you "generate a picture in an axes"? please be more specific – Amro Oct 22 '11 at 21:31

2 Answers2

5

Use getfame:

F = getframe(gcf);
image(F.cdata);
imwrite(F.cdata, 'file.jpg');
Xyand
  • 4,470
  • 4
  • 36
  • 63
0

If it's in some gui or other plots I usually use copyobj to copy the axes containing the picture and add them to a new (usually hidden) figure window.

bdecaf
  • 4,652
  • 23
  • 44