Correct homograph or projective transformation of an inclined image
24 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have some inclined(with respect to camera angle) images that need to be made perpendicular to the camera direction. This could be done probably with homograph or projective transformation as I searched about it.
At first I am cropping the center of the image where the circle is which I am going to use as landmark. Then I pad the RGB image with a white border to visualize the transform.
I_crop_pad = padarray(I_crop, [2, 2], 255);
theta = -30;
pform = projective2d([cosd(theta) -sind(theta) -.0003;
sind(theta) cosd(theta) 0;
0 0 1
]);
outputImage = imwarp(I_crop_pad,pform);
figure,
subplot(121);imshow(I_crop_pad);
subplot(122);imshow(outputImage);
disp([size(I_crop), size(outputImage)])
If the image were taken perpendicularly, then line 1 and line 2 would be equal. and line 1 will be horizontal.
How do I achieve that?
3 commentaires
Matt J
le 2 Août 2023
Modifié(e) : Matt J
le 2 Août 2023
They should be equal to prove the concept of corrected homography of the image.
But that is not enough information to determine a unique homography. The white region in the uncorrected image is an ellipse and you are saying that all you want is a homography that transforms this ellipse into a circle. There are infinitely many such homographies. If C is the 3x3 conic matrix representing the ellipse, then the transformation equation is,
H'*C*H=diag([1,1,-R])
where R is the radius of the circle and H is the unknown 3x3 homography matrix. Because the left and right hand sides are both symmetric matrices, this gives you 6 equations in 9 unknowns.
Réponses (1)
Matt J
le 1 Août 2023
Modifié(e) : Matt J
le 1 Août 2023
You need 4 non-colinear landmarks in the image, for which you know the real-world coordinates. Then you can use fitgeotrans or fitgeotform2d.
4 commentaires
Matt J
le 2 Août 2023
Would you call it a good homography correction?
I suppose, considering as you say that the points are hand picked. Using more landmarks might improve it, if you've anyway to obtain those.
One other thing I am not sure, I chose the moving points as such there shouldn't be any pixel beyond the circle.
You could use imwarp's OutputView option.
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!