I have a Python NumPy array like this:
array([[[ 0, 0, 0, 255],
[ 0, 0, 0, 255],
[ 0, 0, 0, 255],
[ 0, 0, 0, 255],
[ 0, 0, 0, 255],
[ 0, 0, 0, 255],
[ 0, 0, 0, 255],
[ 0, 0, 0, 255]],
[[ 0, 0, 0, 255],
[ 0, 0, 0, 255],
[ 0, 0, 0, 255],
[ 0, 0, 0, 255],
[ 0, 0, 0, 255],
[ 0, 0, 0, 255],
[ 0, 0, 0, 255],
[ 0, 0, 0, 255]],
[[ 0, 0, 125, 255],
[ 0, 0, 0, 255],
[ 0, 0, 0, 255],
[ 0, 0, 0, 255],
[ 0, 0, 0, 255],
[ 0, 0, 0, 255],
[ 0, 0, 0, 255],
[ 0, 0, 0, 255]],
[[ 0, 0, 0, 255],
[ 0, 0, 0, 255],
[ 0, 0, 0, 255],
[ 0, 0, 0, 255],
[ 0, 0, 0, 255],
[ 0, 0, 0, 255],
[ 0, 0, 0, 255],
[ 0, 0, 0, 255]]], dtype=uint8)
And I'm trying to get the index of 125 inside the array with 2 numbers in it. At first I had only 3 values, instead of 4, and this worked to get the indexed position:
p = np.unravel_index(tiles[tileindex].argmax(), tiles[tileindex].shape)
Can't seem to find what I need to use now instead of argmax()
;
the value 125, can be 255 as well, so I'd like to make my selection based on the number of non-zero values in the nested arrays instead of the value itself.
So basically, how to find the line with two values, and then get the position of 125 in this example.
Any help much appreciated.