numrows和numcols分别指定目标图像的高度和宽度。
显而易见,由于这种格式允许图像缩放后长宽比例和源图像长宽比例相同,因此所产生的图像有可能发生畸变。
示例一
I = imread(‘rice.png‘);
J = imresize(I, 0.5);
figure, imshow(I), figure, imshow(J)
示例二
Shrink by factor of two using nearest-neighbor interpolation.
(This is the fastest method, but it has the lowest quality.)
J2 = imresize(I, 0.5, ‘nearest‘);
示例三
Resize an indexed image
[X, map] = imread(‘trees.tif‘);
[Y, newmap] = imresize(X, map, 0.5);
imshow(Y, newmap)
示例四
Resize an RGB image to have 64 rows. The number of columnsis
computed automatically.
RGB = imread(‘peppers.png‘);
RGB2 = imresize(RGB, [64 NaN]);