import cv2import numpy as npimg = cv2.imread('test0.png',1)cv2.imshow('src', img)imgInfo = img.shapeheight = imgInfo[0]width = imgInfo[1]deep = imgInfo[2]newImgInfo = (height*2,width,deep)dst = np.zeros(newImgInfo, np.uint8)for i in range(height): for j in range(width): dst[i,j] = img[i,j] # 绘制上半部分 dst[height*2-i-1,j] = img[i,j] # 绘制镜像部分for i in range(width): # 绘制中间红线 dst[height,i] = (0,0,255) # Redcv2.imshow('image',dst)cv2.waitKey(0)
效果如下: