imtransform
(Not recommended) Apply 2-D spatial transformation to image
imtransform
is not recommended. Use imwarp
instead for 2-D and 3-D transformations. Use tformarray
for higher dimensional transformations.
Syntax
Description
transforms image B
= imtransform(A
,tform
)A
according to the 2-D spatial transformation
defined by tform
, and returns the transformed image,
B
.
If A
is a color image, then imtransform
applies the same 2-D transformation to each color channel. Likewise, if
A
is a volume or image sequence with three or more dimensions,
then imtransform
applies the same 2-D transformation to all 2-D
planes along the higher dimensions.
uses name-value arguments to control various aspects of the spatial
transformation.B
= imtransform(___,Name,Value
)
[
also returns the extent of the output image B
,xdata
,ydata
] = imtransform(___)B
in the output X-Y
space. By default, imtransform
calculates
xdata
and ydata
automatically so that
B
contains the entire transformed image A
.
However, you can override this automatic calculation by specifying values for the
XData
and YData
name-value pair input
arguments.
Examples
Input Arguments
Output Arguments
Tips
Image Registration. The
imtransform
function automatically shifts the origin of your output image to make as much of the transformed image visible as possible. If you useimtransform
to do image registration, the syntaxB = imtransform(A,tform)
can produce unexpected results. To control the spatial location of the output image, setXData
andYData
explicitly.Pure Translation. Calling the
imtransform
function with a purely translational transformation results in an output image that is exactly like the input image unless you specifyXData
andYData
values in your call toimtransform
. For example, if you want the output to be the same size as the input revealing the translation relative to the input image, callimtransform
as shown in the following syntax:B = imtransform(A,T,"XData",[1 size(A,2)],... "YData",[1 size(A,1)])
For more information about this topic, see Perform Simple 2-D Translation Transformation.
Transformation Speed. If you do not specify the output-space location for
B
usingXData
andYData
, thenimtransform
estimates the location automatically using the functionfindbounds
. You can usefindbounds
as a quick forward-mapping option for some commonly used transformations, such as affine or projective. For transformations that do not have a forward mapping, such as polynomial transformations computed byfitgeotform2d
,findbounds
can take much longer. If you can specifyXData
andYData
directly for such transformations, thenimtransform
may run noticeably faster.Clipping. The automatic estimate of
XData
andYData
usingfindbounds
sometimes clips the output image. To avoid clipping, setXData
andYData
directly.
Version History
Introduced before R2006a