How to add noise

I have a mat file dataset(128 x 128). how can I add noise? please explain.

  1. add noise in any particular place.
  2. add noise in the file where values are non zero.

You have have to convert that into a torch tensor (but please add more detail), if you have torch tensor 128 x 128, then you can use:

image = image + torch.randn(image.size()) *1 + 0

where 1 is the mean and 0 is the standard deviation

1 Like