Last Updated : 11 Aug, 2025
Images often contain unwanted noise due to poor lighting, low-quality sensors or high ISO settings. This noise can affect further image processing tasks such as edge detection, segmentation or object recognition
Denoising is a crucial pre-processing step that reconstructs a clean signal from a noisy image, helping improve analysis such as edge detection, segmentation and object recognition.
Function UsedBefore diving into code, let’s understand core function we’ll be using for noise removal.
fastNlMeansDenoisingColored()
This function removes noise from RGB images using Non-Local Means algorithm. It averages similar patches to reduce grain while preserving edges and textures ideal for improving low-light or noisy photos.
Syntaxcv2.fastNlMeansDenoisingColored(src, dst, h, hColor, templateWindowSize, searchWindowSize)
Parameters:
This example shows how to denoise a color image using OpenCV’s fastNlMeansDenoisingColored() function. It removes noise while preserving details and displays original and denoised images side by side using Matplotlib.
Python
# Importing required libraries
import numpy as np
import cv2
from matplotlib import pyplot as plt
# Reading the noisy image from file
img = cv2.imread('bear.png')
# Applying denoising filter
dst = cv2.fastNlMeansDenoisingColored(img, None, 10, 10, 7, 15)
# Displaying original and denoised images
plt.subplot(121), plt.imshow(img), plt.title('Original Image')
plt.subplot(122), plt.imshow(dst), plt.title('Denoised Image')
plt.show()
Output
Output of above exampleExplanation: cv2.fastNlMeansDenoisingColored(img, None, 10, 10, 7, 15): Applies non-local means denoising to color image img and stores the result in dst.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4