tformfwd 和 tforminv - 有什么区别?
假设我有一个任意变换矩阵 A,例如,
A =
0.9966 0.0007 -6.5625
0.0027 0.9938 1.0598
0 0 1.0000
和一组点,其 x 和 y 坐标分别由 X
和 Y
表示。
假设,
[Xf Yf] = tformfwd(maketform('projective',A),X,Y);
现在,
[Xff Yff] = tformfwd(maketform('projective',inv(A)),Xf,Yf);
[Xfi Yfi] = tforminv(maketform('projective',A),Xf,Yf);
[Xff Yff]
和 [Xfi Yfi]
似乎完全相同(而且它们应该)。
tforminv
只是为了方便还是我在这里遗漏了一些东西?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我会先说这是我的最佳猜测...
有可能
tforminv
可以执行变换而不实际形成逆矩阵。例如,您可以通过两种方式求解线性方程组Ax = b
:根据
inv
,第二个选项(使用矩阵除法运算符)“从执行时间和数值精度的角度来看”可以表现更好,因为它“使用高斯消元法产生解决方案,而不形成逆矩阵”。与将逆矩阵传递给 tforminv 可能会执行类似的操作,从而显示出更好的整体行为rel="nofollow noreferrer">tformfwd
。如果您愿意,您可能可以尝试多种不同的变换矩阵并测试两种方法(
tforminv
或tformfwd
和inv
)查看结果的准确性以及计算结果的速度。I'll preface this by saying it is my best guess...
It's possible that
tforminv
may perform the transformation without actually forming the inverse matrix. For example, you can solve a system of linear equationsAx = b
in two ways:According to the documentation for
inv
, the second option (using the matrix division operator) can perform better "from both an execution time and numerical accuracy standpoint" since it "produces the solution using Gaussian elimination, without forming the inverse".tforminv
may do something similar and thus show better overall behavior compared with passing the inverse matrix totformfwd
.If you were so inclined, you could probably try a number of different transformation matrices and test the two approaches (
tforminv
ortformfwd
andinv
) to see how accurate the results are and how fast they are each computed.