Considering an histogram of shape 100x100x100, I would like to find the 2 highest values a and b, and their indices (a1, a2, a3) and (b1, b2, b3), such as:
hist[a1][a2][a3] = a
hist[b1][b2][b3] = b
We can easily get the highest value with hist.max(), but how can we get the X highest values in a ndarray?
I understand that one normally uses np.argmax to retrieve the value indices, but in that case:
hist.argmax().shape = () # single value
for i in range(3):
hist.argmax(i).shape = (100, 100)
How can I get a shape (3), a tuple with one value per dimension?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…