I have seen this question, but want to reduce the array created from mask = array == value
mask = array([[[ True, True, True],
[False, True, True]],
[[False, True, True],
[False, True, True]],
[[False, False, True],
[False, True, True]]])
which results in
where(mask) = (array([0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2]),
array([0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1]),
array([0, 1, 2, 1, 2, 1, 2, 1, 2, 2, 1, 2]))
and I want to reduce it to an array of the first occurrences of True
array([[0, 1],
[1, 1],
[2, 1]])
but can't work out how to go about this from the output of numpy.where
. Can anyone help me out?