#随机产生像素将当前像素替换掉
import cv2
import numpy as np
import random
img = cv2.imread('car.jpg', 1)
imgInfo = img.shape
height = imgInfo[0]
width = imgInfo[1]
dst = np.zeros((height, width, 3), np.uint8) #0-8
m = 8 #水平和竖直方向都可能是8
for i in range(0, height-m): #height-m防止越界
for j in range(0, width-m):
index = int(random.random()*8)
(b,g,r) = img[i+index,j+index] #毛玻璃
img[i, j] = (b, g, r)
cv2.imshow('dst',img)
cv2.waitKey(0)