旋转图像而不裁剪OpenCV [英] Rotate image without cropping OpenCV
本文介绍了旋转图像而不裁剪OpenCV的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
问题是如何使用OpenCV旋转图像并保持原始尺寸.当前正在使用此功能:
The question is how to rotate image using OpenCV and keep original dimensions. Currently using this function:
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?)中使用了哪种算法
Additionally what kind of algorithm utilised in warpAffine (Bicubic?)
推荐答案
创建尺寸为初始图像对角线的新正方形图像.
将初始图像绘制到新图像的中心.
旋转新图片
Create new square image with dimension = diagonal of your initial image.
Draw initial image into the center of new image.
Rotate new image
这篇关于旋转图像而不裁剪OpenCV的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文