# Ball Binary Morphological filter with different spacing?

**URL:** https://discourse.itk.org/t/ball-binary-morphological-filter-with-different-spacing/5228
**Category:** Beginner Questions
**Created:** [July 30, 2022, 1:52am UTC](https://discourse.itk.org/t/ball-binary-morphological-filter-with-different-spacing/5228 "2022-07-30T01:52:39Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![chlee](https://discourse.itk.org/user_avatar/discourse.itk.org/chlee/32/3788_2.png) [@chlee](https://discourse.itk.org/u/chlee)
#### Post date: [July 30, 2022, 1:52am UTC](https://discourse.itk.org/t/ball-binary-morphological-filter-with-different-spacing/5228/1 "2022-07-30T01:52:40Z")

</div>

Hi,

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!

---

<div class="post-metadata">

### Author: ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)
#### Post date: [July 30, 2022, 2:31pm UTC](https://discourse.itk.org/t/ball-binary-morphological-filter-with-different-spacing/5228/2 "2022-07-30T14:31:05Z")

</div>

You can have a ball structuring element with different radii along different axes, see [docs](https://itk.org/Doxygen/html/classitk_1_1Neighborhood.html#aaaca932400993b5d5faf6448dfd856bf). 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:

> <https://github.com/KitwareMedical/HASI/blob/v0.2.2/include/itkSegmentBonesInMicroCTFilter.hxx#L82-L112>

---

<div class="post-metadata">

### Author: ![chlee](https://discourse.itk.org/user_avatar/discourse.itk.org/chlee/32/3788_2.png) [@chlee](https://discourse.itk.org/u/chlee)
#### Post date: [August 2, 2022, 7:55am UTC](https://discourse.itk.org/t/ball-binary-morphological-filter-with-different-spacing/5228/3 "2022-08-02T07:55:37Z")

</div>

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