Transforming a trapezium to a rectangle

623 Views Asked by At

I need to transform a certain area of an image to a rectangle. I know the 4 corner coordinates of the trapezium area.

For example, this is the original image:

enter image description here

The x and y coordinates of points A, B, C, D are KNOWN.

I want to get an image like this:

enter image description here

A'B'C'D' is a rectangle and the x and y coordinates of points A', B', C', D' are also KNOWN.

The pixel A should move to A',

The pixel B should move to B',

The pixel C should move to C',

The pixel D should move to D'.

And the whole trapezium area should be transformed.

I'm sorry for bad English, I hope I could explain my question properly.