opencv 学习笔记3.1 高斯双边滤波(EPF) 常用于美颜

函数说明:

/** @brief Applies the bilateral filter to an image.

The function applies bilateral filtering to the input image, as described in
http://www.dai.ed.ac.uk/CVonline/LOCAL_COPIES/MANDUCHI1/Bilateral_Filtering.html
bilateralFilter can reduce unwanted noise very well while keeping edges fairly sharp. However, it is
very slow compared to most filters.

_Sigma values_: For simplicity, you can set the 2 sigma values to be the same. If they are small (\<
10), the filter will not have much effect, whereas if they are large (\> 150), they will have a very
strong effect, making the image look "cartoonish".

_Filter size_: Large filters (d \> 5) are very slow, so it is recommended to use d=5 for real-time
applications, and perhaps d=9 for offline applications that need heavy noise filtering.

This filter does not work inplace.
@param src Source 8-bit or floating-point, 1-channel or 3-channel image.
@param dst Destination image of the same size and type as src .
@param d Diameter of each pixel neighborhood that is used during filtering. If it is non-positive,
it is computed from sigmaSpace.
@param 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.
@param 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.
@param borderType border mode used to extrapolate pixels outside of the image, see #BorderTypes
 */
CV_EXPORTS_W void bilateralFilter( InputArray src, OutputArray dst, int d,
                                   double sigmaColor, double sigmaSpace,
                                   int borderType = BORDER_DEFAULT );

@param src 输入图像

@param dst 输出图像

@param d 过滤过程中每个像素领域的直径范围,若非正数,则从sigmaspace计算

@param sigmaColor  值越大,表示像素领域内就有多宽的颜色会被混在一起

@param sigmaSpace  值越大,就代表有更大范围的相同颜色像素会相互影响,从而使更大区域的相似颜色,获取到相同的颜色

程序源码: 

#include <iostream>
#include <opencv2/opencv.hpp>
#include <opencv2/core.hpp>
#include <opencv2/highgui.hpp>
#include <stdio.h>

using namespace cv;
using namespace std;               


RNG rng(12345);
Scalar color[7] = {
    (Scalar(0,0,255)),//红色
    (Scalar(0,255,0)),//绿色
    (Scalar(255,0,0)),//蓝色
    (Scalar(255,255,0)),//浅蓝色
    (Scalar(255,0,255)),//紫色
    (Scalar(0,255,255)),//黄色
    (Scalar(128,128,192)),//浅粉色
};
int main()
{
    Mat image,img_bilFilter;

    image = imread("../face.jpg", 1);
    if (image.empty()) {
        cout << "无此图片" << endl;
        return 0;
    }

    img_bilFilter = image.clone();
    

    while (1) 
    {
        imshow("原图", image);
        waitKey(1);

    

        bilateralFilter(image, img_bilFilter, 0, 100, 5);
        imshow("高斯双边模糊", img_bilFilter);
        waitKey(1);
    }
    return 1;
}

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

逐梦者-未来

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值