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
你没有提供很多关于你的代码当前状态的信息,以及你想要什么样的噪音。但通常人们会使用基于numpy的图像,然后根据一些分布简单地添加一些随机样本。
示例:
相关问题 更多 >
编程相关推荐