I have an n-dimensional numpy array of boolean values. I want to find the indices to be able to slice into the array with my slice containing all True values and as few False values as possible.
In less math terms, basically I have an image in 3D and I want to be able to autocrop it based on a given function I define (such as only care about sections labeled with green). What would be the best way to do this? n-dimensional solution preferred so I can use for all image types in the future.