Data is a 6-tuple (a, b, c, d, e, f) which contain the first two rows
from an affine transform matrix. For each pixel (x, y) in the output
image, the new value is taken from a position (a x + b y + c, d x + e
y + f) in the input image, rounded to nearest pixel.
编辑:Ups,以上是仿射变换。你问的是视角转换。函数相同,但参数不同。数据应该是:
Data is a 8-tuple (a, b, c, d, e, f, g, h) which contains the
coefficients for a perspective transform. For each pixel (x, y) in the
output image, the new value is taken from a position (a x + b y +
c)/(g x + h y + 1), (d x + e y + f)/(g x + h y + 1) in the input
image, rounded to nearest pixel.
您可以通过求解方程得到参数:T.x1+v=x2,其中x1是坐标系1(原始图片)中的点坐标,x2是新坐标系(倾斜、旋转或三维)。x1,x2,v是2乘1向量,T是2乘2矩阵。例如x1=(x1x,x1y),x2=(x2x,x2y),v=(c,f)和
如果你不懂矩阵代数,你可以通过消除变量来解决这个问题。对于每一点,可以得到两个等式:
^{pr2}$如果你现在插入一个角点。假设x1=(0,1)和x2=(0,4),得到:
从中你可以得到:
现在,如果你对其他角点重复这个步骤(并使用b=-c的知识)。您可以求解所有变量的数值。在
提示,在计算转换之前,请将原始图片坐标缩放到单位平方(0,0),(0,1),(1,0)和(1,1)。这样你就有很多个1和0。数学方法称为高斯消去法(使用谷歌或维基百科->高斯消去->算法示例)。在
请注意im.tranform公司有六个参数(二维->二维变换):
编辑:Ups,以上是仿射变换。你问的是视角转换。函数相同,但参数不同。数据应该是:
所以方程是Q.x3=x4,其中原始坐标x3是(x3x,x3y,1),变换后的坐标x4是(x4x,x4y,1),对于Q:
与仿射方法相比,我们将常数v嵌入到矩阵中。现在你的方程式变成:
用高斯消去法作为仿射变换求解。在
相关问题 更多 >
编程相关推荐