|
"Eye Lab" <2blka2@gmail.com> wrote in message <gcbpbh$47b$1@fred.mathworks.com>...
> I am trying to write some text on 1920x1080 image and then save the image overlaid with text with the same dimensions and no margins. I have tried this:
>
> A = rand(1080,1920);
> f = figure('units', 'pixels', 'position', [0 0 1920 1080], 'paperpositionmode', 'auto');
> axis off;
> image(A);
> hold on;
> text(100,100,'a',);
> set(gca, 'visible', 'off', 'position', [0 0 1920 1080]);
> print -dpng test
>
> For some reason this produces a 3843x1610 image
>
> I have also tried saveSameSize.m, but this seems to have a limitation if your screen size is smaller than the image resolution.
>
> Any suggestions?
>
> Thanks!
I have been trying to something similar.
spfFig = figure;
colorIm = imread( 'image.png');
imRows = size(colorIm,1); imCols = size(colorIm,2);
figure(spfFig);
reset( gcf ); reset( gca );
set( spfFig , 'Visible', 'off');
imshow( colorIm ); hold on; axis image;
plot( ....// necessary plots and annotations
set( spfFig, 'Units', 'pixels', 'position', [100 100 imCols imRows] );
set( gca, 'Units', 'pixels', 'position', [1 1 imCols imRows ]);
set( spfFig, 'paperunits', 'points', 'papersize', [fix((imCols-1)*(3/4))+1 fix((imRows-1)*(3/4))+1]);
set( spfFig, 'paperunits', 'normalized', 'paperposition', [0 0 1 1]);
print( spfFig, sprintf('-r%d', fix(72*(4/3))), '-dpng', sprintf( '%s/%04d.png', spfOutputSeqDir, ind ) );
This is assuming that a pixel unit = 3/4th of a point. This approximation seems to work and the resulting image has the original dimensions without the bordor.
|