Affine transformation from a parallelogram to a square

118 Views Asked by At

I need to transform an area of an image so that a parallelogram defined as $((x0,y0), (x1,y1), (x2,y2), (x0+x2-x1, y0+y2-y1))$ is mapped on a square $((0,0),(0,128),(128,128),(128,0))$. Apparently, Python OpenCV can read and save images as well as perform affine transformations. What would be the algorithm for such transform?