MATLAB: Convert axis to image file/matrix

axis

Suppose I create an axis and draw several shapes on it from a .mat file:
function Image = draw_rois(filename)
figure
myAx = axes('YDir','reverse', 'Units', 'Pixels', 'XLim', [0 800], ...
'Position',[39,40,800,450], 'YLim', [0 450]);
load(filename)
set(face1{2,1}, 'Parent', myAx)
set(face2{2,1}, 'Parent', myAx)
I would like to convert myAx to the same kind of matrix produced when you call imread on an image file. The following code sort of works, but it skews the aspect ratio and makes everything look terrible if it is reloaded:
F = getframe(myAx);
Image = frame2im(F);
imwrite(Image, 'axis.png')
I need to use this to determine which regions of an identically sized image fall into the shapes drawn here. Hence it would be best if I could just immediately go from axis to image matrix without having to save/print as a .png .jpg etc. Is this even possible?
EDIT/SOLUTION:
Since the comments section got rather long, I've decided to move the working solution up here. I was able to get what I needed using export_fig, which I was helpfully directed to by Rik.

Best Answer

As KSSV mentions, print(gcf,'test','-dpng','-r300'); should do the trick if you want to print your entire figure content to a png file.
The print function relies on a dpi setting to determine how many pixels your figure is. You might be able to force the same pixel size by setting the paper properties of your figure to a different setting.
As an alternative you could consider the ScreenCapture FEX submission. It might be able to keep your figure resolution in an easy way. It also allows you to capture only the axis itself if you want that.
Edit:
The export_fig function has a different mode of operation (it doesn't use Java for a screen capture), so it can be used as well. The downside is that it only works on entire figures, so the result has to be cropped afterwards.
Related Question