今天爱分享给大家带来高斯噪声图片 python opencv实现[附代码],希望能够帮助到大家。
方法
import cv2
import numpy as np
# sigma控制高斯噪声的比例
def noiseGauss(img,sigma):
temp_img = np.float64(np.copy(img))
h = temp_img.shape[0]
w = temp_img.shape[1]
noise = np.random.randn(h,w) * sigma
noisy_img = np.zeros(temp_img.shape, np.float64)
if len(temp_img.shape) == 2:
noisy_img = temp_img + noise
else:
noisy_img[:,:,0] = temp_img[:,:,0] + noise
noisy_img[:,:,1] = temp_img[:,:,1] + noise
noisy_img[:,:,2] = temp_img[:,:,2] + noise
return noisy_img
img = cv2.imread('test.jpg')
# 第二个参数控制高斯噪声的比例
result = noiseGauss(img, 50)
result = result.astype(np.uint8 )
cv2.imwrite('result.jpg',result)
效果


原文链接:http://blog.itblood.com/2514.html,转载请注明出处。

![奇异圣地v54.0b AI版[PC+安卓/7.58G/更新]BizzareHolyLand [v54.0b] [欧美SLG/汉化/动态]](/wp-content/uploads/replace/2025/09/22/1167e74a08adf63d3e5773ed47c5cd2a.webp)