How can I save an image from the handle of an axis (handles.imageAxe) using imwrite or other native matlab function?
The code:
% export_fig(handles.imageAxe, Name, '-jpg -m2.5'); %// WORKS
imwrite(handles.imageAxe, Name); %// DOES NOT WORK
The handle of the axis does not represent an 'image' in the matlab sense.
You can either:
A) export the figure:
saveas( handles.imageAxe , 'mysavedfig.jpg' )
or
B) capture a frame (the content of the axis) with getframe
, then write an actual image
F = getframe(handles.imageAxe) ;
imwrite(F.cdata,'mysavedframe.jpg','jpg')
Read the doc for saveas
, getframe
and imwrite
to better tune it to your needs.