亲,双击屏幕即可自动滚动
4.2.4 图像平移
    4.2.4 图像平移
    图像平移的物理意义,可以理解为摄像头或者相机和物体的水平及垂直距离发生了变化。
    import numpy as np
    img=cv2.imread("../picture/pig.jpg")
    img1 = cv2.cvtcolor(img, cv2.color_bgr2rgb)
    rows,cols,_ = img.shape
    matrix = np.float32([[1,0,25],[0,1,25]])
    img2 = cv2.warpaffine(img1,matrix,(cols,rows))
    matrix = np.float32([[1,0,50],[0,1,50]])
    img3 = cv2.warpaffine(img1,matrix,(cols,rows))
    matrix = np.float32([[1,0,75],[0,1,75]])
    img4 = cv2.warpaffine(img1,matrix,(cols,rows))
    图4-9 图像旋转示例
    如图4-10所示,把图像分别移动不同的距离,移动的中心是原图像的原点。