bilateralFilter() 函数
void cv::bilateralFilter ( InputArray src,
OutputArray dst,
int d,
double sigmaColor,
double sigmaSpace,
int borderType = BORDER_DEFAULT
)
src
输入图片需要是 8 位的数据类型,或者浮点型,可以是单通道,或者三通道。
Source 8-bit or floating-point, 1-channel or 3-channel image.
dst
输出图片和输入图片有相同的尺寸,数据类型,通道数
Destination image of the same size and type as src .
d
邻域的直径,如果是小于等于 0,则由 sigmaSpace 计算得到
Diameter of each pixel neighborhood that is used during filtering. If it is non-positive, it is computed from sigmaSpace.
sigmaColor
颜色空间滤波器的标准差。等大的值表示邻域中更多的颜色被混合,即半等价颜色的区域更大
Filter sigma in the color space. A larger value of the parameter means that farther colors within the pixel neighborhood (see sigmaSpace) will be mixed together, resulting in larger areas of semi-equal color.
sigmaSpace
空域滤波器的标准差。更大的值代表更大范围内的像素(颜色相近)会被相互影响。当 d 大于 0 的时候,sigmaSpace 被忽略,否则 d 由 sigmaSpace 计算得到。
Filter sigma in the coordinate space. A larger value of the parameter means that farther pixels will influence each other as long as their colors are close enough (see sigmaColor ). When d>0, it specifies the neighborhood size regardless of sigmaSpace. Otherwise, d is proportional to sigmaSpace.
borderType
外延模式
border mode used to extrapolate pixels outside of the image, see BorderTypes
使用注意点
-
双边滤波可以在去除噪声的同时,保持边缘信息相对清晰。但是,相比于大多数滤波器,双边滤波的速度是非常慢的。
-
关于 sigma 的值:
通常为了简化,两个 sigma 的值可以设置为相等。如果这两个值都非常小,比如小于 10,则滤波器没有什么太大的效果。如果大于 150,则会有非常强的影响&