regarding the failure of counting the number of array elements belonging to a given range

百般思念 提交于 2019-12-11 14:30:36

问题


I am trying to count the number of array elements that belong to a given range. Based on the following output, it can be seen most of the elements belongs to [0.0, 0.9].

frames_array[3,25,:,:].shape
(89, 92)
frames_array[3,25,:,:]
array([[0.79412902, 0.79412902, 0.79805059, ..., 0.52971725, 0.52971725,
        0.52971725],
       [0.79805059, 0.79412902, 0.79805059, ..., 0.52971725, 0.52971725,
        0.52971725],
       [0.79805059, 0.79412902, 0.79805059, ..., 0.52579569, 0.52579569,
        0.52579569],
       ...,
       [0.68040353, 0.68040353, 0.67648196, ..., 0.49834471, 0.49834471,
        0.49834471],
       [0.67648196, 0.67256039, 0.67256039, ..., 0.49050157, 0.49442314,
        0.49442314],
       [0.67256039, 0.67256039, 0.66863882, ..., 0.48658   , 0.48658   ,
        0.48658   ]])

However, when I use the following code to count the number of elements, the output is just a two element list. What's the problem of this?

b = np.where(np.logical_and(frames_array[3,25,:,:]>=0.0, frames_array[3,25,:,:]<=0.9))
b
(array([ 0,  0,  0, ..., 88, 88, 88], dtype=int64),
 array([ 0,  1,  2, ..., 89, 90, 91], dtype=int64))

来源:https://stackoverflow.com/questions/58585533/regarding-the-failure-of-counting-the-number-of-array-elements-belonging-to-a-gi

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!