【问题标题】:In python what is the most efficient way to get the sum of values in a 2d numpy array?在 python 中,获取 2d numpy 数组中的值总和的最有效方法是什么?
【发布时间】:2014-08-28 04:37:56
【问题描述】:

我正在使用 opencv mats,它们是代表图像的 numpy 数组。

有没有办法得到一个框架中所有 x,y 坐标的总和,即 1) 最有效 2) 最 Pythonic?

frame[xpos][ypos][0]   #note there are really 3 values for each pixel but i want [0]

【问题讨论】:

    标签: python arrays opencv numpy


    【解决方案1】:

    没有:

    np.sum(frame[:, :, 0])
    

    返回你想要的?

    【讨论】:

      猜你喜欢
      • 2016-07-27
      • 2011-10-28
      • 2013-12-05
      • 1970-01-01
      • 2018-07-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-06-30
      相关资源
      最近更新 更多