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

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 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.

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:

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 to enable this module. This can be done by adding -DModule_LabelErodeDilate:BOOL=ON to your initial Superbuild configuration of SimpleITK.

1 Like

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. 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.

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.

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

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

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

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

Best,
Álvaro B.

1 Like