其他分享
首页 > 其他分享> > OpenCV 里的sigma 是多少

OpenCV 里的sigma 是多少

作者:互联网

std::vector<double> createGaussianKernal( int kernal_size , float sigma=0 )
{
    int radius = kernal_size / 2;
    //sigma = sigma > 0 ? sigma : radius*0.3 + 0.8;
    std::vector<double> kernal;// (kernal_size);

    for (int i = -radius; i != radius + 1; ++i)
    {
        double x = i;
        double val = (1.0 / (sqrt(2 * M_PI) *sigma))   *  exp((-x*x) / (2 * sigma*sigma));
        kernal.push_back(val);
    }

    double sum = 0;
    for (int i = 0; i != kernal.size(); ++i) {
        sum += kernal[i];
    }

    for (int i = 0; i != kernal.size(); ++i) {
        kernal[i] /= sum;
    }
    return kernal;
}

 

OpenCV 使用的是这个 0.2 * filterWidth 

标签:int,sum,kernal,OpenCV,radius,sigma,多少,size
来源: https://www.cnblogs.com/luoyinjie/p/15801308.html