- 深度学习实践:计算机视觉
- 缪鹏
- 104字
- 2021-04-03 13:34:53
2.4 平移
平移就是将图片向上下左右进行移动,主要参数为含有方向和距离的平移矩阵,如:
M = np.float32([[1, 0, 25], [0, 1, 50]]) shifted_image = cv2.warpAffine(image, M, (image.shape[1], image. shape[0]))
M中的参数[1,0,25]表示向[1,0]方向移动25像素,[0, 1, 50]意义类似,最终表示将图片向右移动25像素,向下移动50像素。