FUNCTION REFERENCE
imwarp
Apply a 2-D geometric transformation or a displacement field to an image.
Apply a 2-D geometric transformation or a displacement field to an image.
Syntax
B = imwarp(A, tform)Syntax
[B, RB] = imwarp(A, RA, tform)Syntax
B = imwarp(A, D)Syntax
B = imwarp(..., interp, 'OutputView', R, 'FillValues', f, 'SmoothEdges', tf)A is M-by-N or M-by-N-by-P (each plane warped alike) of class double, single, logical or an integer class; B has the class of A (integers rounded and saturated, logical thresholded at 0.5). tform is an affinetform2d, rigidtform2d, simtform2d, transltform2d or affine2d object mapping input world coordinates to output world coordinates; RA (default imref2d(size(A))) places A in the world. Each output pixel centre is mapped back through the inverse transformation (inverse mapping) and sampled with interp: 'linear' (default), 'nearest' or 'cubic' (cubic convolution, a = -0.5); 'InterpolationMethod', interp is the same. Without OutputView the output covers the bounding box of the transformed image (outputLimits) at the pixel extent of RA, rounded up to whole pixels and centred; RB is the imref2d of the output. Points outside the pixel centres of A get FillValues (default 0; a scalar or one value per channel). 'SmoothEdges', true pads A with FillValues first, so the edges ramp to the fill value. D is M-by-N-by-2: B(r, c) samples A at column c + D(r, c, 1) and row r + D(r, c, 2), and B has the size of D.
Example
B = imwarp(magic(4), rigidtform2d(90, [0 0])) % rot90(magic(4), -1)Example
[B, RB] = imwarp(ones(4), simtform2d(1.5, 0, [0 0])); RB.XWorldLimits % [0.75 6.75]Example
B = imwarp([2 4 6 8], transltform2d(0.5, 0), 'OutputView', imref2d([1 4]), 'FillValues', 10, 'SmoothEdges', true) % [6 3 5 7]Example
B = imwarp(magic(3), cat(3, ones(3), zeros(3))) % columns shift left; last column 0Differences from MATLAB: the reference page does not give the edge rules or the rounding of the default output size; MatRust chooses these: a sample point is interpolated only inside the pixel-centre hull [1, N] x [1, M] (within 1e-9 pixel), cubic taps past the border repeat the edge pixel, SmoothEdges pads by 2 pixels, and the default size is ceil(extent / pixel extent) with the limits widened evenly. Categorical images, 3-D transformations (imref3d, affinetform3d), projective transformations and the Warper object are not supported yet.
These are the engine’s help pages. Each page keeps its compatibility notes. File operations are unavailable in the browser.