0

First: here is a little sketch

enter image description here

I'm working on a project where I get an image with a quadrilateral on it (the red one). I know the positions of all four points.

Now I want to deskew this quadrilateral to a rectangle with the same size like the original image. Its only allowed to move the corners of the whole image (marked with a blue cycle) each one independently.

I tried with a little bit of math. I created a system of linear equations, but I never get a solution.

I tried to move the edges of the image a little bit and recalculate the edges of the quadrilateral. This isn't working by now but consumed a lot of time.

Now I thought there has to be a algorithm to solve this problem more efficient.

I hope you know a algorithm or have an idea for me.

sincerely, Xean

P.S.: Only core frameworks should be used. Not something like OpenCV.

Omar Wagih
  • 8,504
  • 7
  • 59
  • 75
Obenland
  • 856
  • 16
  • 28
  • I'm a little confused - you know the corner coordinates of the red quad. So, if you rasterize the image then you can morph it into another image using the enclosing rectangle. Would that suffice? I know of no library that will do this, and I'm pretty sure Quartz cannot do it, but I guess if it were me I'd spend a bit of time looking at say C++ libraries before I coded it myself. – David H Jun 15 '13 at 00:25
  • I'm planning to use CATransform3D and CATransform3DConcat, and some other methods. But therefor the I have to calculate the position of each edge of the image. Here is a screenshot where I did this by hand. https://www.dropbox.com/s/30tnz6gub1m79zo/Bildschirmfoto%202013-06-15%20um%2002.58.28.png Hope it helps a little bit to get in to my problem – Obenland Jun 15 '13 at 01:00
  • See my answer and the others [here](http://stackoverflow.com/questions/9608600/how-can-i-render-a-square-bitmap-to-an-arbitrary-four-sided-polygon-using-gdi/9609615#9609615). – user1118321 Jun 15 '13 at 03:01
  • hfossli presents a method for going in the opposite direction here: http://stackoverflow.com/questions/9470493/transforming-a-rectangle-image-into-a-quadrilateral-using-a-catransform3d , so you can probably reverse the calculation to go the other way from quadrilateral to rectangle. – Brad Larson Jun 15 '13 at 22:56

0 Answers0