matlab内置函数fitgeotrans与transformPointsForward解析

最近研究3000fps的实现,看了网上给的一个matlab代码,里面有提到init_shape到mean_shape的对齐,里面使用了fitgeotrans和transformPointsForward两个函数。于是参考matlab help研究了一下这两个函数.

fitgeotrans函数

语法:

 tform = fitgeotrans(movingPoints,fixedPoints,transformationType)

说明:

  • movingPoints — 图像上想要移动的点的坐标,至少是两个double型2维点.
  • fixedPoints — 目标点,和上面同等规模
  • transformationType — 变换类型,包括如下几种:
transformationType Description
‘Affine’ 仿射变换
‘NonreflectiveSimilarity’ 非反射相似变换(这个有点不懂哎)
‘Projective’ 投影变换
‘Similarity’ 相似变换(即仿射变换中去除错切变换)

总结:
这个函数主要描述了将movingPoints(设大小为:N*2,N>=2)通过某种变换变化到fixedPoints来,最后输出了变换矩阵。tform 是一个结构体类型,里面包含了变换矩阵.

transformPointsForward函数

语法:

[x,y] = transformPointsForward(tform,u,v)
X = transformPointsForward(tform,U)

说明:
tform为变换矩阵. u,v分别代表你要变换的点的x,y序列。u,v必须维数相同.变换后输出了对应的x,y。
而第二个函数,U包含了[u,v],X=[x,y]。
注意:
什么是前置变换呢?
即: X=U*tform

两个例子

例1

theta = 10;
tform = affine2d([cosd(theta) -sind(theta) 0; sind(theta) cosd(theta) 0; 0 0 1])
[X,Y] = transformPointsForward(tform,5,10)

结果:
tform =

affine2d with properties:

             T: [3x3 double]
Dimensionality: 2

其中

而X=6.6605 , Y=8.9798 。
具体计算方法是:

[
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值