I'm working with Python. I want to know if there is a python way to mask a 3d array XYZ (volumetric image) to perform a segmentation analysis such as skeletonization.
I'm handling a 600x600x300 array so reducing the number of candidates to be analyzed is key to performance. I tried np.array[mask] but the array dimension changes to 1. The where method such as this How to Correctly mask 3D Array with numpy performs the change to one value at the time, but skeletonization needs to analyze the neighbors to be performed.
Edit: This is something simple but it might help you to get the idea. It's to create a 3d AOI inside a volume.
# create array with random numbers
Array = np.random.random([10, 10,10])
# create a boolean mask of zeros
maskArr=np.zeros_like(Array, dtype=bool)
# set a few values in the mask to true
maskArr[1:8,1:5,1:3] = 1
# Try to analise the data with mask
process= morphology.skeletonize(Array[maskArr])
this is the error due to the 1-d array:
ValueError: skeletonize requires a 2D or 3D image as input, got 1D.