# Resample small mask

**URL:** <https://discourse.itk.org/t/resample-small-mask/3950>\
**Category:** Uncategorized\
**Created:** [March 10, 2021, 11:42am UTC](https://discourse.itk.org/t/resample-small-mask/3950 "2021-03-10T11:42:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![vankhoa21991](https://discourse.itk.org/letter_avatar_proxy/v4/letter/v/e68b1a/32.png) [@vankhoa21991](https://discourse.itk.org/u/vankhoa21991)\
**Post date:** [March 10, 2021, 11:42am UTC](https://discourse.itk.org/t/resample-small-mask/3950/1 "2021-03-10T11:42:36Z")

</div>

Hello,

I would like to resample the volume and mask to a fixed spacing using simpleitk in python, but after I do that, the mask of small regions disappears completely. Do you have any idea about this phenomenon?

I tried a smaller spacing, and different interpolator but the results still the same.

---

<div class="post-metadata">

**Author:** ![zivy](https://discourse.itk.org/user_avatar/discourse.itk.org/zivy/32/1726_2.png) [@zivy](https://discourse.itk.org/u/zivy)\
**Post date:** [March 10, 2021, 2:46pm UTC](https://discourse.itk.org/t/resample-small-mask/3950/2 "2021-03-10T14:46:51Z")

</div>

Hello @vankhoa21991,

Welcome to ITK/SimpleITK!

I suspect what you are experiencing is [aliasing](https://en.wikipedia.org/wiki/Aliasing) (is your new spacing larger than the original mask spacing?). For a concrete code example illustrating aliasing in SimpleITK take a look at the first couple of cells in [this Jupyter notebook](https://github.com/InsightSoftwareConsortium/SimpleITK-Notebooks/blob/master/Python/70_Data_Augmentation.ipynb).

For the mask image you can try to use the sitkLabelGaussian interpolator instead of the sitkNearestNeighbor interpolator (see [full list of interpolator options](https://simpleitk.org/doxygen/latest/html/namespaceitk_1_1simple.html#a7cb1ef8bd02c669c02ea2f9f5aa374e5)).

If that doesn’t improve the result you can convert the binary mask image to a [distance map](https://simpleitk.org/doxygen/latest/html/classitk_1_1simple_1_1SignedMaurerDistanceMapImageFilter.html), resample the distance map using sitkLinear, or any other interpolator for continuous data, and convert the result back to a binary image (`resampled_distance_map<=0`).

---

<div class="post-metadata">

**Author:** ![vankhoa21991](https://discourse.itk.org/letter_avatar_proxy/v4/letter/v/e68b1a/32.png) [@vankhoa21991](https://discourse.itk.org/u/vankhoa21991)\
**Post date:** [March 10, 2021, 3:40pm UTC](https://discourse.itk.org/t/resample-small-mask/3950/3 "2021-03-10T15:40:12Z")

</div>

My new spacing is smaller than old spacing, I tried LabelGaussian but the result is still the same. I will try your suggestion of distance map. Thanks
