0

I have a question related to projective transform. Suppose now we know a line function ax+by+c=0in an image, and the image will go through a projective distortion, and the distortion can be represented as a projective transformation matrix :

enter image description here

Then after the porjective transformation, how could I know the line function in the new distorted image? Thanks!

** EDIT ** Based on the suggestion, I have found the answer. Here, I posted the MATLAB codes to illustrate it:

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);

The original images with two lines on it:

enter image description here

After projective distoration, the output image with lines on it becomes: enter image description here

4

2 回答 2

1

I'm no mathematician so maybe there's a better solution, but you could use the equation as it is and then transform the output by multiplying by the transformation matrix.

于 2012-10-17T15:50:53.283 回答
1

Here is an easier way to understand it than in your code above.

Given a non-singular homography H (i.e. a homography represented by a 3x3 matrix H with non-zero determinant):

  1. Homogeneous 2D points (represented as 3D column vectors) transform from the right:

    p' = H * p

  2. 2D lines (represented as 3D row vectors of their 3 coefficients) transform from the left by the inverse homography:

    l' = l * H^-1

Proof: for every point p belonging to line l it is l * p = 0. But then l * (H^-1 * H) * p = 0, since (H^-1 * H) = I is the identity matrix. The last equation, by the associative property, can be rewritten as (l * H^-1) * (H * p) = 0. But, for every p belonging to the line, p' = H * p is the same point transformed by the homography. Therefore the last equation says that these same points, in transformed coordinates, belong to a line with coefficients l' = l * H^-1, QED.

于 2012-10-18T12:08:44.443 回答