Ball Binary Morphological filter with different spacing?


I want to generate a segmented image and want to do a 3D morphological closing operation just before the thresholding event. I already have a binary 3D image. The issue is that my 3D image x,y,z spacing is not same (x,y dimension is 0.41432 but z dimension is 1). Would it be OK to still OK to use a Ball structure with same radius? Or shall I first resample my image to match the z spacing to the x dimension and then treat the operation and then resample back?

Thank you very much in advance for any tips!

You can have a ball structuring element with different radii along different axes, see docs. If you pass a scalar, you will get a “square” neighborhood.

Also consider approximation to morphological closing via dilating and eroding using thresholding of distance field. Sample code:

1 Like

Thank you very much!! This is very helpful!!