旋转图像而不裁剪 OpenCV

Rotate image without cropping OpenCV

问题是如何使用 OpenCV 旋转图像并保持原始尺寸。当前使用此功能:

def rotateImage(image, angle):
   (h, w) = image.shape[:2]
   center = (w / 2, h / 2)
   M = cv2.getRotationMatrix2D(center,angle,1.0)
   rotated_image = cv2.warpAffine(image, M, (w,h))
   return rotated_image

另外warpAffine(Bicubic?)使用了什么样的算法

创建尺寸为初始图像对角线的新方形图像。
将初始图像绘制到新图像的中心。
旋转新图像