我正在尝试向图像添加高斯噪声(“pepper.jpg”)。它有效,如结果所示(“noisy Pepper.png”);但噪音并没有覆盖“辣椒”,它就在它周围。我在应用噪音时缺少什么吗?任何意见,将不胜感激。
import cv2
import numpy as np
img = cv2.imread("pepper.jpg",0)
row, col = img.shape
mean = 0
var = 0.3
sigma = var ** 0.5
gauss = np.random.normal(mean, sigma, (row, col))
gauss = gauss.reshape(row, col)
noisyp = gauss + img
noisyp = noisyp.astype('uint8')
cv2.imwrite('noisy pepper.png', noisyp)
摇曳的蔷薇
相关分类