Search
H = u2H( u, u0 )
Create function u2H computing homography from four image matches. Let u be the image coordinates of points in the first image (2×4 matrix) and u0 (2×4 matrix) be the image coordinates of the corresponding points in the second image. Then H is a 3×3 homography matrix, such that
u2H
u
u0
H
λ_i [u0(:,i);1] = H * [u(:,i);1]
for all i=1:4 and some nonzero λ_i. Matrix H is regular. Return an empty matrix [] if there is no solution.
i=1:4
λ_i
[]
u = [0 0 1 1; 0 1 1 0] u0 = [1 2 1.5 1; 1 2 0.5 0] % result should be (but verify yourself): H = [1 1 1 -1 1 1 1 0 1 ]
00ID: Your data
edit_points
i
u(:,i)
u0(:,i)
u2h_optim
05_homography.mat
save( '05_homography.mat', 'H', 'u', 'u0', 'point_sel', '-v6' )
05_corrected.png
05_homography.pdf
The part of reference image is transferred to your image, so we need the transformation of coordinates in the opposite direction.
rgb = im0(round(u0(2,i)),round(u0(1,i)),:); % here we take all values (':') along the third dimension
im(u(2,i), u(1,i),:) = rgb;
Upload an archive consisting of: