How to do it

You need to complete the following steps:

  1. Import the necessary modules:
import cv2
import numpy as np
import matplotlib.pyplot as plt
  1. Load the test image:
img = cv2.imread('../data/Lena.png')
  1. Generate a random Gaussian noise:
noise = 30 * np.random.randn(*img.shape)
img = np.uint8(np.clip(img + noise, 0, 255))
  1. Perform denoising using the non-local means algorithm:
denoised_nlm = cv2.fastNlMeansDenoisingColored(img, None, 10)
  1. Visualize the results:
plt.figure(0, figsize=(10,6))
plt.subplot(121)
plt.axis('off')
plt.title('original')
plt.imshow(img[:,:,[2,1,0]])
plt.subplot(122)
plt.axis('off')
plt.title('denoised')
plt.imshow(denoised_nlm[:,:,[2,1,0]])
plt.show()