【问题标题】:Explain the working of shadow detection code implemented in opencv?解释opencv中实现的阴影检测代码的工作原理?
【发布时间】:2015-03-18 20:22:42
【问题描述】:

我正在尝试了解在 opencv 中实现的用于阴影检测的代码,其链接为 Here

代码是

detectShadowGMM(const float* data, int nchannels, int nmodes,
                const GMM* gmm, const float* mean,
                float Tb, float TB, float tau)
{
    float tWeight = 0;

    // check all the components  marked as background:
    for( int mode = 0; mode < nmodes; mode++, mean += nchannels )
    {
        GMM g = gmm[mode];

        float numerator = 0.0f;
        float denominator = 0.0f;
        for( int c = 0; c < nchannels; c++ )
        {
            numerator   += data[c] * mean[c];
            denominator += mean[c] * mean[c];
        }

        // no division by zero allowed
        if( denominator == 0 )
            return false;

        // if tau < a < 1 then also check the color distortion
        if( numerator <= denominator && numerator >= tau*denominator )
        {
            float a = numerator / denominator;
            float dist2a = 0.0f;

            for( int c = 0; c < nchannels; c++ )
            {
                float dD= a*mean[c] - data[c];
                dist2a += dD*dD;
            }

            if (dist2a < Tb*g.variance*a*a)
                return true;
        };

        tWeight += g.weight;
        if( tWeight > TB )
            return false;
    };
    return false;
}

我假设的 nchannels 是每个像素的 rgb 通道。我不确定 dist2a、分子和分母是什么。前景和背景可能是,但为什么我们要乘以“数据和平均值”和“平均值和平均值”。这里实现的论文是 Zivkovic。 “改进的背景减法自适应高斯混合模型”,国际会议模式识别,英国,2004 年 8 月,

逻辑是:在RGB色彩空间中,E代表背景,I代表每个像素i的前景。 E 和 I 之间的强度差异是通过最小化 (a) = (Ii-aEi)^2 给出的“a”来计算的 色差由 CDi = |Ii-aEi| 给出 如果值在阈值内,则像素被分类为阴影。 This image will better explain it

请帮我用代码映射逻辑。

【问题讨论】:

    标签: c++ opencv computer-vision shadow


    【解决方案1】:

    论文中解释了实现 一种实时鲁棒背景减除和阴影检测的统计方法 经过 Thanarat Horprasert David Harwood Larry S. Davis 这在上述论文的参考文献中有所体现。

    下面的链接显示了用于实现的公式。 Click here for image

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-08-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-05-15
      • 2015-12-29
      相关资源
      最近更新 更多