
The principle of bilateral filtering is to keep the image edge with a large color difference, and filter the images on both sides of the edge. Bilateral filtering has two cores, airspace core and range core.
Bilateral filter api: bilateralFilter (img, d, sigmaColor, sigmaSpace,...)
Img: filtered picture
d: Filter size
SigmaColor: the control range of the edge, which is not set as an edge at this value
SigmaSpace: the control range of the value field, similar to sigmaColor
import cv2 import numpy as np # 导入一张图 img=cv2.imread('C:\\Users\\mk\\Desktop\\20220720224350.jpg') # 进行双边滤波 dst=cv2.bilateralFilter(img,20,20,50) # 显示图片 cv2.imshow('img',img) cv2.imshow('dst',dst) cv2.waitKey(0)