个性化阅读
专注于IT技术分析

Python使用OpenCV对彩色图像进行去噪

去噪图像的”噪声”是指从噪声图像中重建信号的过程。进行降噪以从图像中去除不需要的噪声, 以更好的形式对其进行分析。它指的是主要的预处理步骤之一。 opencv中有四个函数, 用于对不同的图像进行去噪。

语法:
cv2.fastNlMeansDenoisingColored(P1, P2, float P3, float P4, int P5, int P6)
参数:
P1 –源图像阵列
P2 –目标图像阵列
P3 –用于计算权重的模板补丁的像素大小。
P4 –窗口的像素大小, 用于计算给定像素的加权平均值。
P5 –参数调整滤光片强度的亮度分量。
P6 –与上述相同, 但用于颜色成分//不用于灰度图像中。

下面是实现:

# 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()

输出如下:

Python使用opencv对彩色图像进行去噪1

首先, 你的面试准备可通过以下方式增强你的数据结构概念:Python DS课程。


赞(0)
未经允许不得转载:srcmini » Python使用OpenCV对彩色图像进行去噪

评论 抢沙发

评论前必须登录!