Suppose I create an axis and draw several shapes on it from a .mat file:
function Image = draw_rois(filename)figuremyAx = 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