# module 'SimpleITK' has no attribute 'LabelSetDilateImageFilter' despite using version 1.2.0

**URL:** <https://discourse.itk.org/t/module-simpleitk-has-no-attribute-labelsetdilateimagefilter-despite-using-version-1-2-0/1880>\
**Category:** Engineering\
**Tags:** simpleitk, python\
**Created:** [May 15, 2019, 3:25pm UTC](https://discourse.itk.org/t/module-simpleitk-has-no-attribute-labelsetdilateimagefilter-despite-using-version-1-2-0/1880 "2019-05-15T15:25:39Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![abertelsen](https://discourse.itk.org/user_avatar/discourse.itk.org/abertelsen/32/768_2.png) [@abertelsen](https://discourse.itk.org/u/abertelsen)\
**Post date:** [May 15, 2019, 3:25pm UTC](https://discourse.itk.org/t/module-simpleitk-has-no-attribute-labelsetdilateimagefilter-despite-using-version-1-2-0/1880/1 "2019-05-15T15:25:39Z")

</div>

Hello everyone,

First of all, greeting to all of you as this is my first question on ITK’s Discourse.

What I wanted to ask is the following: I want to use the [LabelSetDilateImageFilter](https://itk.org/Doxygen/html/classitk_1_1LabelSetDilateImageFilter.html) class in Python (version 3.7.2) with SimpleITK (version 1.2.0). For an unknown reason, that particular class does not seem to be available, although I think that I am using the correct versions:

```
>>> import SimpleITK as sitk
>>> sitk.Version.VersionString()
'1.2.0'
>>> dilater = sitk.LabelSetDilateImageFilter()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'SimpleITK' has no attribute 'LabelSetDilateImageFilter'

```

Could you please indicate what am I doing wrong? Any help will be greatly appreciated!

Best,  
Álvaro B.

---

<div class="post-metadata">

**Author:** ![blowekamp](https://discourse.itk.org/user_avatar/discourse.itk.org/blowekamp/32/79_2.png) [@blowekamp](https://discourse.itk.org/u/blowekamp)\
**Post date:** [May 15, 2019, 3:49pm UTC](https://discourse.itk.org/t/module-simpleitk-has-no-attribute-labelsetdilateimagefilter-despite-using-version-1-2-0/1880/2 "2019-05-15T15:49:51Z")

</div>

Welcome Álvaro,

That error message indicates the filter is not wrapped in your SimpleITK library.

This particular filter is a “remote” module of ITK, and is found in this repository:

> **[InsightSoftwareConsortium/ITKLabelErodeDilate](https://github.com/InsightSoftwareConsortium/ITKLabelErodeDilate)**
>
> Erode and dilate operations on label images. Contribute to InsightSoftwareConsortium/ITKLabelErodeDilate development by creating an account on GitHub.

Remote modules are not enabled for the binary distributions of SimpleITK. We do have wrapping support for some; this one happens to be one. You will have to [compile SimpleITK yourself](https://simpleitk.readthedocs.io/en/master/Documentation/docs/source/building.html#) to enable this module. This can be done by adding `-DModule_LabelErodeDilate:BOOL=ON` to your initial Superbuild configuration of SimpleITK.

---

<div class="post-metadata">

**Author:** ![abertelsen](https://discourse.itk.org/user_avatar/discourse.itk.org/abertelsen/32/768_2.png) [@abertelsen](https://discourse.itk.org/u/abertelsen)\
**Post date:** [May 15, 2019, 4:02pm UTC](https://discourse.itk.org/t/module-simpleitk-has-no-attribute-labelsetdilateimagefilter-despite-using-version-1-2-0/1880/3 "2019-05-15T16:02:49Z")

</div>

Thanks Bradley for your response.

I understand what you are saying. However, I suggest that filters not included by default in the SimpleITK binaries should be indicated in the [documentation](https://simpleitk.readthedocs.io/en/master/Documentation/docs/source/filters.html). As the LabelSetDilateImageFilter is listed there, that led me to think that it was available.

By the way, I was able to get the result I wanted by using the `GrayscaleDilate` function. Is there any reason for which `LabelSetDilateImageFilter` should be preferred over `GrayscaleDilate`?

Thanks for your quick reply,  
Álvaro B.

---

<div class="post-metadata">

**Author:** ![blowekamp](https://discourse.itk.org/user_avatar/discourse.itk.org/blowekamp/32/79_2.png) [@blowekamp](https://discourse.itk.org/u/blowekamp)\
**Post date:** [May 15, 2019, 4:09pm UTC](https://discourse.itk.org/t/module-simpleitk-has-no-attribute-labelsetdilateimagefilter-despite-using-version-1-2-0/1880/4 "2019-05-15T16:09:51Z")

</div>

> [@abertelsen](#):
>
> By the way, I was able to get the result I wanted by using the `GrayscaleDilate` function. Is there any reason for which `LabelSetDilateImageFilter` should be preferred over `GrayscaleDilate` ?

The `LabelSetDilateImageFilter` operates on a set of labels. That is to say if you have an image with multiple segmented objects with different label, then this filter will dilate all labels, not just one like the binary morphological filters.

> [@abertelsen](#):
>
> I suggest that filters not included by default in the SimpleITK binaries should be indicated in the [documentation](https://simpleitk.readthedocs.io/en/master/Documentation/docs/source/filters.html).

That is a good idea. Can you please create an issue for that in the SimpleITK GitHub repo:

> **[Issues · SimpleITK/SimpleITK](https://github.com/SimpleITK/SimpleITK/issues)**
>
> SimpleITK: a layer built on top of the Insight Toolkit (ITK), intended to simplify and facilitate ITK's use in rapid prototyping, education and interpreted languages. - Issues · SimpleITK/Simpl...

---

<div class="post-metadata">

**Author:** ![abertelsen](https://discourse.itk.org/user_avatar/discourse.itk.org/abertelsen/32/768_2.png) [@abertelsen](https://discourse.itk.org/u/abertelsen)\
**Post date:** [May 16, 2019, 9:18am UTC](https://discourse.itk.org/t/module-simpleitk-has-no-attribute-labelsetdilateimagefilter-despite-using-version-1-2-0/1880/5 "2019-05-16T09:18:23Z")

</div>

> The `LabelSetDilateImageFilter` operates on a set of labels. That is to say if you have an image with multiple segmented objects with different label, then this filter will dilate all labels, not just one like the binary morphological filters.

Precisely: as I have a label image with multiple labels using the GrayscaleDilate I get a dilation of _all_ labels. If I used a binary dilation I would have ended with a dilation of a single one. Again, I get the impression that the same dilation of all labels can be obtained using GrayscaleDilate or the LabelSetDilateImageFilter class.

> That is a good idea. Can you please create an issue for that in the SimpleITK GitHub repo:  
> [Issues · SimpleITK/SimpleITK · GitHub](https://github.com/SimpleITK/SimpleITK/issues)

I have checked SimpleITK’s GitHub issues and saw that this feature has already been requested:

> <https://github.com/SimpleITK/SimpleITK/issues/384>
>
> Add the list of remote modules available in SimpleITK to read-the-docs. The list… should specify whether the module is available as part of the binary release or requires a local build (is it on or off by default).

I have preferred not to post a duplicate issue, as this ones is already there.

Best,  
Álvaro B.
