Skip to content
Advertisement

Replace cv2.warpPerspective for big images

I use python OpenCV to register images, and once I’ve found the homography matrix H, I use cv2.warpPerspective to compute final the transformation.

However, it seems that cv2.warpPerspective is limited to short encoding for performance purposes, see here. I didn’t some test, and indeed the limit of image dimension is 32767 pixels so 2^15, which makes sense with the explanation given in the other discussion.

Is there an alternative to cv2.warpPerspective? I already have the homography matrix, I just need to do the transformation.

Advertisement

Answer

After looking at alternative libraries, there is a solution using skimage.

If H is the homography matrix, the this OpenCV code:

warped_img = cv2.warpPerspective(image, H, (width, height))

Becomes:

warped_imgnew = skimage.transform.warp(image, numpy(H), output_shape=(height, width)) * 255.0
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement