[英]How to add gaussian noise in an image in Python using PyMorph
我是Python的新手,我想在灰度图像中添加高斯噪声。 我已经将原始图像转换为灰度以测试一些形态学方法去噪(使用PyMorph)但我不知道如何添加噪声。
您没有提供有关代码当前状态以及您想要的确切类型噪声的大量信息。 但通常会使用基于numpy的图像,然后只是根据某些分布添加一些随机样本。
例:
import numpy as np
# ...
img = ... # numpy-array of shape (N, M); dtype=np.uint8
# ...
mean = 0.0 # some constant
std = 1.0 # some constant (standard deviation)
noisy_img = img + np.random.normal(mean, std, img.shape)
noisy_img_clipped = np.clip(noisy_img, 0, 255) # we might get out of bounds due to noise
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.