How can I control the output image pixel size using only the PRINT command?
11 views (last 30 days)
Show older comments
I need to have a specific pixel resolution in my output image. I do not have the image processing toolbox, and therefore can not use the IMRESIZE command.
Accepted Answer
MathWorks Support Team
on 18 Oct 2013
You can do this by manipulating the PAPERPOSITION property and the resolution switch in the PRINT command.
surf(peaks)
% control the image pixel size by manipulating the paper size and number of dots per inch
output_size = [500 300];%Size in pixels
resolution = 300;%Resolution in DPI
set(gcf,'paperunits','inches','paperposition',[0 0 output_size/resolution]);
% use 300 DPI
print('test.png','-dpng',['-r' num2str(resolution)]);
% now read the image back in to MATLAB and test its size
a=imread('test.png');
size(a)
0 Comments
More Answers (0)
See Also
Categories
Find more on Image Processing Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!