Opencv随笔5----马赛克,给你的脸打上马赛克

代码

import cv2
import os
path = os.path.join(os.getcwd(),'pic/b.jpg')
img = cv2.imread(path, 1)
shape = img.shape
height = shape[0]
width = shape[1]
print shape
h = int(height * 0.5)
w = int(width * 0.2)
for r in range(h, h+100):
    for c in range(w, w+100):
        if r%10 ==0 and c%10 ==0:
            (b, g ,f)= img[r][c]
            for i in range(10):
                for j in range(10):
                    img[r+i][c+j]=(b,g ,f)
cv2.imshow('dd',img)
cv2.imwrite('dama.jpg',img)
cv2.waitKey(0)

猜你喜欢

转载自blog.csdn.net/qq_42105426/article/details/89476407