Resizing Images in MATLAB
Methods
imresize(A, scale)
: Returns a new image by adjusting the size of A by a factor of scale.
If A is a 10x10 image and a scale of 0.5 is input, it returns a 5x5 image. You can also adjust the size directly as follows.
imresize(A, [m n])
: Returns an image with m rows and n columns. Below are example codes and their results.
X=imread('test\_{i}mage.jpg');
figure()
imshow(X)
saveas(gcf,'X.png')
title('X')
Y1=imresize(X,0.5);
Y2=imresize(X,[500 500]);
Y3=imresize(X,[700 500]);
Y4=imresize(X,[500,700]);
figure()
imshow(Y1)
saveas(gcf,'Y1.png')
title('Y1=imresize(X,0.5)')
figure()
imshow(Y2)
saveas(gcf,'Y2.png')
title('Y2=imresize(X,[500 500])')
figure()
imshow(Y3)
saveas(gcf,'Y3.png')
title('Y3=imresize(X,[700 500])')
figure()
imshow(Y4)
saveas(gcf,'Y4.png')
title('Y4=imresize(X,[500,700])')