FUNCTION REFERENCE

imresize

Resize an image.

Resize an image.

Syntax

B = imresize(A, scale)

Syntax

B = imresize(A, [numrows numcols])

Syntax

B = imresize(..., method, 'Antialiasing', tf)

Each plane of a 2-D or M-by-N-by-C image is resampled separably. A scale gives ceil(scale * size) rows and columns; a size [r c] uses r/rows and c/cols as the scales, and NaN in one entry keeps the aspect ratio (the other axis is scaled by the same factor, rounded up). Output pixel x (1-based) samples the input at u = x/scale + 0.5*(1 - 1/scale). Methods: 'bicubic' (default; Keys 1981 cubic convolution, a = -0.5), 'bilinear' (triangle) and 'nearest'. When shrinking with bilinear or bicubic, 'Antialiasing' (default true) widens the kernel by 1/scale; the weights are always normalised to sum 1. Pixels beyond the edges repeat the edge pixel. The class is kept (integers rounded and saturated; logical results are true above 0.5). Scale 1 returns the input. An antialiasing kernel may span at most max(2^20, 4*size+8) samples, which every scale of at least 1/size meets; a smaller scale is an error (use 'Antialiasing', false).

Example

imresize([1 2; 3 4], 2, 'nearest')   % [1 1 2 2; 1 1 2 2; 3 3 4 4; 3 3 4 4]

Example

size(imresize(zeros(4, 8), [NaN 6]))   % [3 6]

Example

imresize(uint8(magic(4)), 0.5)

Differences from MATLAB: the reference page does not describe the border handling or the kernel normalisation; MatRust repeats edge pixels, so values next to the border can differ. The 'box', 'triangle', 'lanczos2' and 'lanczos3' methods, custom kernels, indexed images (X, map) and the 'Colormap', 'Dither', 'Scale' and 'OutputSize' names are not supported yet.

These are the engine’s help pages. Each page keeps its compatibility notes. File operations are unavailable in the browser.