首先对原图像加椒盐噪声,之后经中值滤波
import cv2 as cv
import numpy as np
def noise(img,snr):
h=img.shape[0]
w=img.shape[1]
img1=img.copy()
sp=h*w
NP=int(sp*(1-snr))
for i in range (NP):
randx=np.random.randint(1,h-1) # random
randy=np.random.randint(1,w-1)
if np.rand
1