0

I have an image of a quadrilateral (the image is of a rectangle, but in an unknown perspective). Assume it looks something like this:

Initial image

Also, assume I've found the coordinates for the quadrilateral's corners (hence the black arrows, which are NOT part of the actual image).

What I want is, given the 4 corners' coordinates, to take only the quadrilateral and project it to a rectangle of a given size (say, height h and width w).

Meaning, the result should be:

Wanted result

I've tried several things (like imwarp, for example) but can't get the result I'm looking for.

How do I go about making this in MARLAB?

EDIT: I should mention that thus far, using MATLAB's fitgoetrans and imwarp transformed the image, but didn't create a new image containing just the shape.

Gil
  • 143
  • 2
  • 9
  • if they were 3 corners, it would be easy, but mathematically speaking, 4 points may not define an euclidean plane in general, thus you can not get a transformation that moves them to a square. With 3, some kind of homography/affine transformation woudl work. All this in euclidean space. Perhaps in Riemann space you can do it, but that too far from my expertise :P. If you choose your example poorly, and you actually have a perspective view of a rectangle, the try the mentioned transformations – Ander Biguri Jul 20 '17 at 13:34
  • The duplicates will most certainly help - especially the first one. The first one however has 4 points on a rectangle and you are to warp it so that it appears as a quadrilateral. You want the reverse, so all you have to do is swap the input and output points. The same can be said for the second post, but is not as direct like the first point. I put the second post up as a reference if you'd like to use newer functions from the image processing toolbox. – rayryeng Jul 20 '17 at 17:12

0 Answers0