使用变换矩阵将图像投影到另一个图像中

问题描述 投票:0回答:1

我需要将一个图像投影到另一个图像的门窗口。

这是家庭工作问题。我尝试使用线性方程解决它。门图像窗口坐标:

Top left corner = (188,155)
Top Right corner = (343,177)
Bottom left corner = (186,462)
Bottom right corner = (343,432)

我想要投影坐标的图像:

Top left corner = (0,0)
Top Right corner = (499,0)
Bottom left corner = (0,507)
Bottom right corner = (499,507)

我把方程式设为:

matrix(3*3)[a b c;d e f;g h 1]*[0 0 1]=[188 155 1] etc 

And I get the transformation matrix as 
[0.311 -0.003 188;0.044 0.605 155;0 0 1]

tm=[0.311 -0.003 188;0.044 0.605 155;0 0 1]
tff = projective2d(tm)
I=imread('a1.jpg');
output=imwarp(I,tff);
imshow(output);

在运行时我只得到一个点,但它不应该是那个

matlab computer-vision projection
1个回答
0
投票

您似乎正确地派生了Homography Matrix。但是你对该矩阵中的值有一些模糊的想法。

值188和155将您的图像转换为188点向右,155点向下。这就是输出为空的原因。因为图像移动到输出窗口中不可见的区域。

您可以根据更大的图像导出变换矩阵,从而使这些变换值变大。让他们0。

为了使变换后的图像可见,您需要将变换矩阵设为:

tm=[0.311 -0.003 0;0.044 0.605 0;0 0 1]

这可以解决我的问题。

© www.soinside.com 2019 - 2024. All rights reserved.