Python | Notation for color images using opencv



Image desaturation refers to the process of signal recovery from noisy images. Noise removal is done to remove unwanted noise from an image in order to analyze it in the best possible way. This is one of the main preprocessing steps. Opencv has four functions that can be used to denoise various images.

Syntax: cv2.fastNlMeansDenoisingColored (P1, P2, float P3, float P4, int P5, int P6)

Parameters:
P1 – Source Image Array
P2 – Destination Image Array
P3 – Size in pixels of the template patch that is used to compute weights.
P4 – Size in pixels of the window that is used to compute a weighted average for the given pixel.
P5 – Parameter regulating filter strength for luminance component.
P6 – Same as above but for color components // Not used in a grayscale image.

Here`s the implementation:

# import libraries

import numpy as np

import cv2

from matplotlib import pyplot as plt

 
# Reading images from the folder where it is stored

img = cv2.imread ( ` bear.png` )

 
# remove noise from the image, saving it to dst image

dst = cv2.fastNlMeansDenoisingColored (img, None , 10 , 10 , 7 , 15 )

 
# Build source and destination images

plt.subplot ( 121 ), plt.imshow (img)

plt.subplot ( 122 ), plt.imshow (dst)

 
plt.show ()

Output: