Replace cv2.warpPerspective for big images
Question:
I use Python OpenCV to register images, and once I’ve found the homography matrix H
, I use cv2.warpPerspective
to compute the final transformation.
However, it seems that cv2.warpPerspective
is limited to short
encoding for performance purposes, see here. I did some tests, and indeed the limit of image dimension is 32,767 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.
Answers:
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
I use Python OpenCV to register images, and once I’ve found the homography matrix H
, I use cv2.warpPerspective
to compute the final transformation.
However, it seems that cv2.warpPerspective
is limited to short
encoding for performance purposes, see here. I did some tests, and indeed the limit of image dimension is 32,767 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.
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