Opencv Matrix 元素的列总和 [英] Column sum of Opencv Matrix elements

查看:20
本文介绍了Opencv Matrix 元素的列总和的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要分别计算所有列中元素的总和.

I need to compute sum of elements in all columns separately.

现在我正在使用:

矩阵 cross_corr 应该相加.

Matrix cross_corr should be summed.

Mat cross_corr_summed;
for (int i=0;i<cross_corr.cols;i++)                                                     
    {
        double column_sum=0;
        for (int k=0;k<cross_corr.rows;k++)
        {
            column_sum +=cross_corr.at<float>(k,i);             
        }
        cross_corr_summed.push_back(column_sum);
    }

问题是我的程序需要很长时间才能运行.这是导致此问题的可疑部分之一.你能建议任何可能的更快实施吗???

The problem is that my program takes quite a long time to run. This is one of parts that is suspicious to cause this. Can you advise any possible faster implementation???

谢谢!!!

推荐答案

你需要一个简历::减少:

cv::reduce(cross_corr, cross_corr_summed, 0, CV_REDUCE_SUM, CV_32S);

这篇关于Opencv Matrix 元素的列总和的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆