'How to calculate affine transform matrix with cupy.ndimage

I want to do affine transform from source image to get a transformed image. I have some corresponding points, like

src_points = [[x1_src, y1_src], [x2_src, y2_src], [x3_src, y3_src]]
dst_points = [[x1_dst, y1_dst], [x2_dst, y2_dst], [x3_dst, y3_dst]]

In opencv, I know:

M = cv2.getAffineTransform(src_point, dst_point)
transformed = cv2.warpAffine(src, M, (w, h))

Now I want to it with cupy.ndimage for accelerating, but I do not known how to using ndimage API. I try to use affine_transform with M got from cv2.getAffineTransform, like:

ndimage.affine_transform(src, M[:, :2], M[:, 2:], (h, w))

The result is not the same. Actually, I wonder is there any API in ndimage do the same thing as cv2.getAffineTransform?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source