Correct homograph or projective transformation of an inclined image
15 ビュー (過去 30 日間)
古いコメントを表示
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)])
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1446917/image.png)
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 件のコメント
Matt J
2023 年 8 月 2 日
編集済み: Matt J
2023 年 8 月 2 日
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.
回答 (1 件)
Matt J
2023 年 8 月 1 日
編集済み: Matt J
2023 年 8 月 1 日
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 件のコメント
Matt J
2023 年 8 月 2 日
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.
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!