Python|使用opencv对彩色图像进行去噪
图像去噪是指从噪声图像中重建信号的过程。进行去噪是为了从图像中去除不需要的噪声,以便以更好的形式对其进行分析。它指的是主要的预处理步骤之一。 opencv中有四个函数用于对不同图像进行去噪。
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.
下面是实现:
# importing libraries
import numpy as np
import cv2
from matplotlib import pyplot as plt
# Reading image from folder where it is stored
img = cv2.imread('bear.png')
# denoising of image saving it into dst image
dst = cv2.fastNlMeansDenoisingColored(img, None, 10, 10, 7, 15)
# Plotting of source and destination image
plt.subplot(121), plt.imshow(img)
plt.subplot(122), plt.imshow(dst)
plt.show()
输出: