I have a 3D label matrix.
Using ndimage.sum
I can get the labeled objects sizes, which is great for filtering based on volume.
My question is : can I easily get objects sizes along each axis, to eliminate those that are only in one plane, for instance ?
A little code might be clearer...
from scipy import ndimage
labmat,n = ndimage.label(np.random.rand(30,30,30) > 0.99)
sizes = ndimage.sum(labmat.astype(bool),labmat,range(n+1))
Now instead of a 1-dimensional representing the volumes of the labeled objects, is there a way to have 3D array representing their surfaces in each dimension ? A 30-D array representing their surfaces in each plane would also be OK, though I would prefer the first option.