(h, w) = image.shape[:2]
(cX, cY) = (w // 2, h // 2)
M = cv2.getRotationMatrix2D((cX, cY), -angle, a)
cos = np.abs(M[0, 0])
sin = np.abs(M[0, 1])
nW = int((h * sin) + (w * cos))
nH = int((h * cos) + (w * sin))
M[0, 2] += (nW / 2) - cX
M[1, 2] += (nH / 2) - cY
x=371#假设坐标为(371,68)
y=68
x=int(M[0,0]*x+M[0,1]*y+M[0,2])
y=int(M[1,0]*x+M[1,1]*y+M[1,2])
point=(x,y)
return (cv2.warpAffine(image, M, (nW, nH),borderValue=(255,255,255)),point)
在这个实现图像旋转的函数中用变换矩阵求得原坐标点的新坐标point,但得出的point的纵坐标与实际并不相符,求问题所在。
注意坐标系,程序里的纵坐标以顶部为原点向下扩张的。