To resolve issues starting MATLAB on Mac OS X 10.10 (Yosemite) visit: http://www.mathworks.com/matlabcentral/answers/159016
I am currently fighting with the Matlab print function and I don't know how to get the results I need.
The idea is pretty simple: I read 512x512 px images, then do some feature extraction, overlay the features as polygons using patch() and then I want to write the image back in exactly the same resolution.
output_size = [512 512];%Size in pixels resolution = 300;%Resolution in DPI set(fig,'paperunits','inches','paperposition',[0 0 output_size/resolution]); print(fig,'-dtiffn',['-r' num2str(resolution)],'-painters',tiff_name_afm)
Does not work. Indeed the output image IS 512x512, but only because of a large white canvas, whilst the image and graph itself is a lot smaller.
Can anyone help me with this?
Best wishes, Chris
No products are associated with this question.
If you are not needing shading, then instead of using patch() to do the overlays, use poly2mask() to convert the polygons to pixel locations, and write the new values into the image array; then imwrite() the result.
If you need transparency then use the alpha equation to calculate the result:
(1-alpha) * background + alpha * foreground