3-9 图片镜像

import cv2
import numpy as np
img = cv2.imread('image3.png',1)
cv2.imshow('src',img)
imgInfo = img.shape
height = imgInfo[0]
width = imgInfo[1]
deep = imgInfo[2]
newImgInfo = (height*2,width,deep)
#dst = np.zeros(newImgInfo,uint8)
dst = np.zeros(newImgInfo,np.uint8)
for i in range(0,height):
    for j in range(0,width):
        dst[i,j] = img[i,j]
        # x y = 2*h-y-1
        # x轴表明的是横坐标,横坐标描述的是宽度信息,所以x值对应的是j
        # y值描述的是高度信息,高度信息对应的是height,所以y值对应的是i
        dst[height*2-i-1,j] = img[i,j]
for i in range(0,width):
    dst[height,i] = (0,0,255) #BGR
cv2.imshow('dst',dst)
cv2.waitKey(0)
原文地址:https://www.cnblogs.com/ZHONGZHENHUA/p/9684501.html