[英]How to create add gaussian noise on an image
I want to create a function to add gaussian noise to a single input that I will later use.我想创建一个 function 以将高斯噪声添加到我稍后将使用的单个输入。 I'm using the imageio module in Python.
我在 Python 中使用 imageio 模块。
def gaussian_noise(x, var):
I thought x is the tensor you want to add gaussian noise to, and var is the variance of gaussian noise.我认为 x 是要添加高斯噪声的张量,而 var 是高斯噪声的方差。
Your question is vague, but you can add gaussian noise like this:你的问题含糊不清,但你可以像这样添加高斯噪声:
import torch
def gaussian_noise(x, var):
return torch.normal(0, var, size=x.shape)
T = torch.ones(4, 5)
T += gaussian_noise(T, 0.1)
print(T)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.