主要内容

本页翻译不是最新的。点击此处可查看最新英文版本。

affine2d

(不推荐)使用后乘约定的二维仿射几何变换

不建议使用 affine2d。请改用 affinetform2d 对象。有关详细信息,请参阅版本历史记录

说明

affine2d 对象使用后乘约定存储有关二维仿射几何变换的信息,并支持正变换和逆变换。

创建对象

描述

tform = affine2d 创建一个 affine2d 对象,其默认属性设置对应于恒等变换。

tform = affine2d(t) 将属性 T 设置为指定的二维仿射变换矩阵 t

示例

属性

全部展开

正向二维仿射变换,指定为非奇异矩阵 3×3 数值矩阵。矩阵 T 使用如下约定:

[x y 1] = [u v 1] * T

其中,T 采用以下形式:

 [a b 0;
  c d 0;
  e f 1];

T 的默认值为恒等变换。

数据类型: double | single

此 属性 为只读。

输入点和输出点的几何变换维度,指定为值 2

对象函数

invertInvert geometric transformation
isRigidDetermine if geometric transformation is rigid transformation
isSimilarityDetermine if geometric transformation is similarity transformation
isTranslationDetermine if geometric transformation is pure translation
outputLimitsFind output spatial limits given input spatial limits
transformPointsForwardApply forward geometric transformation
transformPointsInverseApply inverse geometric transformation

示例

全部折叠

创建一个 affine2d 对象,该对象定义围绕原点逆时针方向旋转 30 度。

theta = 30;
tform = affine2d([ ...
    cosd(theta) sind(theta) 0;...
    -sind(theta) cosd(theta) 0; ...
    0 0 1])
tform = 
  affine2d with properties:

                 T: [3×3 double]
    Dimensionality: 2

对点 (10,0) 应用正向几何变换。

[x,y] = transformPointsForward(tform,10,0)
x = 
8.6603
y = 
5

通过绘制原始点(蓝色)和变换后的点(红色)来验证变换。

plot(10,0,'bo',x,y,'ro')
axis([0 12 0 12])
axis square

Figure contains an axes object. The axes object contains 2 objects of type line. One or more of the lines displays its values using only markers

将图像读入工作区。

A = imread('pout.tif');

创建一个定义仿射几何变换的 affine2d 对象。此示例同时应用垂直剪切和水平拉伸。

tform = affine2d([2 0.33 0; 0 1 0; 0 0 1])
tform = 
  affine2d with properties:

                 T: [3×3 double]
    Dimensionality: 2

使用 imwarp 对图像应用几何变换。

B = imwarp(A,tform);

显示生成的图像。

figure
imshow(B);
axis on equal;

Figure contains an axes object. The axes object contains an object of type image.

扩展功能

全部展开

版本历史记录

在 R2013a 中推出

全部展开