affineOutputView
Create output view for warping images
Description
Examples
Warp Image Using Different Output View Styles
Read and display an image. To see the spatial extents of the image, make the axes visible.
A = imread("kobi.png"); A = imresize(A,0.25); iptsetpref("ImshowAxesVisible","on") imshow(A)
Create a 2-D affine transformation. This example creates a randomized transformation that consists of scale by a factor in the range [1.2, 2.4], rotation by an angle in the range [-45, 45] degrees, and horizontal translation by a distance in the range [100, 200] pixels.
tform = randomAffine2d("Scale",[1.2,2.4],"XTranslation",[100 200],"Rotation",[-45,45]);
Create three different output views for the image and transformation.
centerOutput = affineOutputView(size(A),tform,"BoundsStyle","CenterOutput"); followOutput = affineOutputView(size(A),tform,"BoundsStyle","FollowOutput"); sameAsInput = affineOutputView(size(A),tform,"BoundsStyle","SameAsInput");
Apply the transformation to the input image using each of the different output view styles.
BCenterOutput = imwarp(A,tform,"OutputView",centerOutput); BFollowOutput = imwarp(A,tform,"OutputView",followOutput); BSameAsInput = imwarp(A,tform,"OutputView",sameAsInput);
Display the resulting images.
imshow(BCenterOutput)
title("CenterOutput Bounds Style");
imshow(BFollowOutput)
title("FollowOutput Bounds Style");
imshow(BSameAsInput)
title("SameAsInput Bounds Style");
iptsetpref("ImshowAxesVisible","off")
Input Arguments
sizeA
— Input image size
2-element numeric vector | 3-element numeric vector
Input image size, specified as a 2-element numeric vector for 2-D image input or a 3-element numeric vector for 3-D volumetric image input.
tform
— Geometric transformation
geometric transformation object
Geometric transformation, specified as a geometric transformation object listed in the table.
Geometric Transformation Object | Description |
---|---|
2-D Geometric Transformations | |
transltform2d | Translation transformation |
rigidtform2d | Rigid transformation: translation and rotation |
simtform2d | Similarity transformation: translation, rotation, and isotropic scaling |
affinetform2d | Affine transformation: translation, rotation, anisotropic scaling, reflection, and shearing |
3-D Geometric Transformations | |
transltform3d | Translation transformation |
rigidtform3d | Rigid transformation: translation and rotation |
simtform3d | Similarity transformation: translation, rotation, and isotropic scaling |
affinetform3d | Affine transformation: translation, rotation, anisotropic scaling, reflection, and shearing |
Note
You can also specify tform
as an affine2d
object or an affine3d
object. However, these objects are not recommended. For more
information, see Version History.
style
— Bounds style
"CenterOutput"
(default) | "FollowOutput"
| "SameAsInput"
Bounds style, specified as one of the following values.
Style | Description |
---|---|
"CenterOutput" | Center the view at the center of the image in output space while allowing translation to move the output image out of view. |
"FollowOutput" | Set the limits of the output view to completely contain the output image. |
"SameAsInput" | Set the output limits to be the same as the input limits. |
Output Arguments
Extended Capabilities
Thread-Based Environment
Run code in the background using MATLAB® backgroundPool
or accelerate code with Parallel Computing Toolbox™ ThreadPool
.
This function fully supports thread-based environments. For more information, see Run MATLAB Functions in Thread-Based Environment.
Version History
Introduced in R2019bR2022b: Supports new geometric transformation objects
Starting in R2022b, most Image Processing Toolbox™ functions create and perform geometric transformations using the premultiply
convention. Accordingly, you can now specify tform
as a geometric
transformation object that uses the premultiply convention, such as an affinetform2d
or
affinetform3d
object.
Although you can still specify tform
as an
affine2d
or affine3d
object, these objects are not
recommended because they use the postmultiply convention. You can streamline your geometric
transformation workflows by switching to objects that use the premultiply convention. For
more information, see Migrate Geometric Transformations to Premultiply Convention.
R2021b: Support for thread-based environments
affineOutputView
now supports thread-based
environments.
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)