import cv2
import numpy as np
img = cv2.imread('face.jpg', 1)
imgInfo = img.shape
height = imgInfo[0]
width = imgInfo[1]
cv2.imshow('src', img)
for m in range(100, 300):
for n in range(100, 200):
# 用一个像素点表示小矩形框 pixel-> 10*10
if m % 10 == 0 and n % 10 == 0:
for i in range(0, 10):
for j in range(0, 10):
(b, g, r) = img[m, n]
img[i + m, j + n] = (b, g, r)
cv2.imshow('dst', img)
cv2.waitKey(0)
图像中的局部马赛克效果如下:
image.png
网友评论