【问题标题】:Line function after projective transform投影变换后的线函数
【发布时间】:2012-10-17 15:44:54
【问题描述】:

我有一个与projective transform 相关的问题。假设现在我们知道图像中有一个线函数ax+by+c=0,图像会经历一个投影畸变,该畸变可以表示为一个射影变换矩阵:

那么在进行了投影变换后,我怎么知道新扭曲图像中的线函数呢?谢谢!

** 编辑 ** 根据建议,我找到了答案。在这里,我贴出MATLAB代码来说明一下:

close all;
% Step 1: show the images as well as lines on it
imshow(img);
line = hor_vt{1}.line(1).line;   a = line(1); b=line(2); c=line(3);
[row,col] = size(img);
x_range = 1:col;
y_range = -(a*x_range+c)/b;
hold on; plot(x_range,y_range,'r*');
line = hor_vt{1}.line(2).line;   a = line(1); b=line(2); c=line(3);
y_range = -(a*x_range+c)/b;
hold on; plot(x_range,y_range,'y*');
% Step 2: show the output distorted image that goes through projective
% distortion. 
ma_imshow(output);
[row,col] = size(output);
x_range = 1:col;
line = hor_vt{1}.line(1).line;  
line = reverse_tform.tdata.Tinv*line(:); % VERY IMPORT
a = line(1); b=line(2); c=line(3);
y_range = -(a*x_range+c)/b;
hold on; plot(x_range,y_range,'r*');
disp('angle');
disp( atan(-a/b)/pi*180);
line = hor_vt{1}.line(2).line;  
line = reverse_tform.tdata.Tinv*line(:); % VERY IMPORT
a = line(1); b=line(2); c=line(3);
y_range = -(a*x_range+c)/b;
hold on; plot(x_range,y_range,'y*');
disp('angle');
disp( atan(-a/b)/pi*180);

上面有两行的原始图像:

经过投影畸变后,带有线条的输出图像变为:

【问题讨论】:

标签: image-processing geometry computer-vision


【解决方案1】:

这是一种比上面的代码更容易理解的方法。

给定一个非奇异单应性 H(即由具有非零行列式的 3x3 矩阵 H 表示的单应性):

  1. 齐次 2D 点(表示为 3D 列向量)从右侧变换:

    p' = H * p

  2. 2D 线(表示为它们的 3 个系数的 3D 行向量)通过逆单应性从左侧变换:

    l' = l * H^-1

证明:对于属于线 l 的每个点 p,它是 l * p = 0。但是 l * (H^-1 * H) * p = 0,因为 (H^-1 * H) = I 是单位矩阵。最后一个方程,根据关联属性,可以重写为 (l * H^-1) * (H * p) = 0。但是,对于属于该线的每个 p,p' = H * p 是同一个点由单应性变换。因此,最后一个等式表明,这些相同的点在变换后的坐标中属于系数为 l' = l * H^-1,QED 的直线。

【讨论】:

    【解决方案2】:

    我不是数学家,所以也许有更好的解决方案,但您可以按原样使用方程,然后通过乘以变换矩阵来变换输出。

    【讨论】:

    猜你喜欢
    • 2010-09-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-06-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-11-11
    相关资源
    最近更新 更多