I have a 3D matrix, within which I have identified a "region of interest" - a bounding box - which I would like the indices for.
I have the upper and lower bound limits of each axis:
([x:13 y:5 z:21] [x:27 y:29 z:35])
numpy.where to find the indices of an array fulfilling a condition.
numpy.where returns a tuple, the first element contains the indices.
from __future__ import print_function import numpy a = numpy.arange(0, 100, 10) # 0, 10, 20, ... ind = numpy.where(a>30) print(ind) # [4 5 6 7 8 9]