自定义直方图平滑函数cvSmoothHist

本文介绍了一个自定义的直方图平滑函数cvSmoothHist,该函数通过平均相邻直方图值来实现平滑效果。适用于图像处理中对直方图进行平滑处理的场景。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

自定义直方图平滑函数cvSmoothHist

CvHistogram* cvSmoothHist(CvHistogram* Histogram_src, CvHistogram* Histogram_dst, int step) 
{
    int start = step - step/2;
    int end = 256 - step/2 ;
    double temp = 0;

    int res[256];
    memset(res,0,256*sizeof(int));

    for (int i = start; i < end; i++) 
    {
        temp = 0;
        for (int j = 0-step/2; j < step/2; j++) 
        {
            temp +=((CvMatND *) Histogram_src->bins)->data.fl[i + j];
        }
        temp /= step;
        res[i] = (int)temp;
    }

    for (int i = 0; i <= 255; i++) 
    {
        ((CvMatND *) Histogram_dst->bins)->data.fl[i] = res[i];
    }
    return Histogram_dst;
}

参考资料:http://www.cnblogs.com/elaron/archive/2012/06/11/2545119.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值