matlab - How to prevent that print changes image resolution? -
i tries create text image (i think called way) in matlab. means want create image containing text. problem there no matlab function can this. solution use text , captures output in figure.
in beginning used getframe capture output. went fine long did not else on screen @ same time. problem |getframe| captures whatever on screen @ moment, have led annoying bugs. in hope of solving problem plan use |print| instead. however, have problem of image resolution changes when print used. know solution this?
this have tried far:
xlen = 1200; ylen = 700; im = uint8(255*ones(ylen,xlen,3)); hf = figure('color','white','units','normalized','position',[.1 .1 .8 .8]); image(ones(size(im))); set(gca,'units','pixels','position',[5 5 size(im,2)-1 size(im,1)-1],'visible','off') text('units','pixels','position',[1 ylen/2],'fontsize',60,'fontweight','bold','string','this text') set(hf,'units','pixels') set(hf,'position',[100,100,xlen,ylen],'paperpositionmode','auto'); print(hf, '-dpng', 'mytext.png');
saving images in matlab can real struggle. found solution using export_fig mathlab file exchange (see http://www.mathworks.com/matlabcentral/fileexchange/23629-export-fig).
some of aims of export fig are:
- figure/axes reproduced appears on screen
- cropped borders (optional)
- embedded fonts (pdf only)
Comments
Post a Comment