resize pictures in matlab with code code example

Example 1: matlab reduce resolution of image

outputImage = imresize(inputImage, [numOutputRows, numOutputColumns]);

Example 2: matlab resize image by scale

% MATLAB
% scale any input image by defined factors
img = imread('yourimg');

% your scaling factors [row col]
scale[2 2];

mxn = size(img);
% compute new image dimensions
pxq = max(floor(scale.*mxn(1:2)),1);

% compute p and q values via Nearest neighbor interpolation.
p = min(round(((1:pxq(1))-0.5)./scale(1)+0.5),mxn(1));
q = min(round(((1:pxq(2))-0.5)./scale(2)+0.5),mxn(2));

% retain dimension perspective with : as the third param
outImg = originalImg(p,q,:);

imshow(img)

Tags:

Misc Example