Projection of an Image

55 Ansichten (letzte 30 Tage)
Logan Davis
Logan Davis am 13 Dez. 2017
Kommentiert: Masoud Heidari am 5 Mär. 2021
If I know the four corners of a rectangle that has been projected, how can I obtain a top-down view of that image using image projection. I tried to use fitgeotrans and imwarp but did not obtain the correct results. Below is the code I used:
U = double([topLeft; topRight; bottomRight; bottomLeft]);
topLeftNew = [1 1];
topRightNew = [1 width];
bottomLeftNew = [height 1];
bottomRightNew = [height width];
X = double([topLeftNew; topRightNew; bottomRightNew; bottomLeftNew]);
tform = fitgeotrans(U, X, 'projective');
B = imwarp(orig, tform);
Does anyone know what I could do to fix this or a different method? The image I'm trying to transform is:
The four corners I've obtained are shown as well. The result of the transformation is.
I'd like for the result to only contain the notecard and orient it correctly upright as well. Is this possible and how can I go about achieving this?

Antworten (2)

Ben Drebing
Ben Drebing am 21 Dez. 2017
I think that the orderings of your fixedpoints and movingpoints do not match up. Try
topLeft = [360, 546];
topRight = [609, 109];
botRight = [873, 240];
botLeft = [645, 703];
U = [topLeft; topRight; botRight; botLeft];
width = size(I,2);
height = size(I,1);
topLeftNew = [1 1];
topRightNew = [1 width];
bottomLeftNew = [height 1];
bottomRightNew = [height width];
X = double([topLeftNew;bottomLeftNew; bottomRightNew; topRightNew ]);
tform = fitgeotrans(U, X, 'projective');
B = imwarp(I, tform);
imshow(B,[]);
You can use imcrop to crop out the rest of the image.
  1 Kommentar
Masoud Heidari
Masoud Heidari am 5 Mär. 2021
Thank you very much Ben! it was a big help for me too.

Melden Sie sich an, um zu kommentieren.


Image Analyst
Image Analyst am 21 Dez. 2017
See attached demo.

Kategorien

Mehr zu Images finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by