Adding random Gaussian noise to images

We can use the random_noise() function to add different types of noise to an image. The next code example shows how Gaussian noise with different variances can be added to an image:

im = img_as_float(imread("../images/parrot.png"))plt.figure(figsize=(15,12))sigmas = [0.1, 0.25, 0.5, 1]for i in range(4):  noisy = random_noise(im, var=sigmas[i]**2) plt.subplot(2,2,i+1) plt.imshow(noisy) plt.axis('off') plt.title('Gaussian noise with sigma=' + str(sigmas[i]), size=20)plt.tight_layout()plt.show()

The next figure shows the output image generated by adding Gaussian noises with different variance by running the previous code snippet. As can be seen, the more the standard deviation of the Gaussian noise, the ...

Get Hands-On Image Processing with Python now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.