【发布时间】:2018-11-05 19:58:03
【问题描述】:
我有以下旋转图像的方法(python):
> def rotateImage(image, angle):
> row,col = image.shape[0:2]
> center=tuple(np.array([row,col])/2)
> rot_mat = cv2.getRotationMatrix2D(center,angle,1.0)
> new_image = cv2.warpAffine(image, rot_mat, (col,row))
> return new_image
这是 OpenCV 返回的旋转(15 度角)图片: 这是我在 Photoshop 中围绕中心旋转图像时的图像:
显然是有区别的。我很确定 Photoshop 做得正确(或者更好——我在 Photoshop 中做得正确),我错过了什么?
【问题讨论】:
-
交换中心的 X 和 Y 坐标。
cv2.getRotationMatrix2D的第一个参数等价于cv::Point,其中 X 为第一,Y 为第二。
标签: opencv image-rotation