plenoptic.process.add_noise#
- plenoptic.process.add_noise(img, noise_mse)[source]#
Add normally distributed noise to an image.
This adds normally-distributed noise to an image so that the resulting noisy version has the specified mean-squared error.
- Parameters:
- Return type:
- Returns:
noisy_img – The noisy image. If
noise_msecontains only one element, this will be the same size asimg. Else, each separate value fromnoise_msewill be along the batch dimension.
Examples
Basic usage:
>>> import plenoptic as po >>> import torch >>> img = po.data.einstein() >>> img.shape torch.Size([1, 1, 256, 256]) >>> noisy = po.process.add_noise(img, noise_mse=0.1) >>> noisy.shape torch.Size([1, 1, 256, 256]) >>> po.plot.imshow([img, noisy]) <PyrFigure ...>
With multiple elements in
noise_mse:>>> noisy_multi = po.process.add_noise(img, noise_mse=[0.01, 0.1, 1.0]) >>> noisy_multi.shape torch.Size([3, 1, 256, 256]) >>> po.plot.imshow([img, noisy_multi]) <PyrFigure ...>