马赛克图像处理
import cv2
def mosaic(image, x, y, width, height, size):
roi = image[y:y+height, x:x+width]
roi = cv2.resize(roi, (size, size), interpolation=cv2.INTER_NEAREST)
roi = cv2.resize(roi, (width, height), interpolation=cv2.INTER_NEAREST)
image[y:y+height, x:x+width] = roi
imgpath = 'demo.jpg'
img = cv2.imread(imgpath)
mosaic(x1,y1,w,h) # 左上角坐标,宽和高
cv2.imwrite('mosaic_demo.jpg',img)