问题
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