# itk.ApproximateSignedDistanceMapImageFilter error

**URL:** https://discourse.itk.org/t/itk-approximatesigneddistancemapimagefilter-error/361
**Category:** Beginner Questions
**Tags:** python, itkwheels
**Created:** [October 27, 2017, 2:25pm UTC](https://discourse.itk.org/t/itk-approximatesigneddistancemapimagefilter-error/361 "2017-10-27T14:25:38Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![mafuentes](https://discourse.itk.org/user_avatar/discourse.itk.org/mafuentes/32/647_2.png) [@mafuentes](https://discourse.itk.org/u/mafuentes)
#### Post date: [October 27, 2017, 2:25pm UTC](https://discourse.itk.org/t/itk-approximatesigneddistancemapimagefilter-error/361/1 "2017-10-27T14:25:39Z")

</div>

I am using the ITK python wheels and was doing a survey of the DistanceMap filters. While trying the `ApproximateSignedDistanceMapImageFilter` I got an error. Sample code and error below, can anyone give me a hint as to why this happens? Thanks in advance

Sample code:

```
input_image = itk.imread('sand-thresholded.bmp', itk.UC)

float_image = itk.Image[itk.F, 2]
image_caster = itk.CastImageFilter[input_image, float_image].New()
image_caster.SetInput(input_image)

mapping_filter = itk.ApproximateSignedDistanceMapImageFilter[float_image, float_image].New()
mapping_filter.SetInput(image_caster)
mapping_filter.SetInsideValue(0.0)
mapping_filter.SetOutsideValue(255.0)
mapping_filter.Update()

```

And the error:

```
/usr/bin/python3.6 /home/lab/PycharmProjects/distance_map_survey/survey.py
Traceback (most recent call last):
File "/home/lab/PycharmProjects/distance_map_survey/survey.py", line 34, in <module>
    mapping_filter.Update()
RuntimeError: /work/standalone-x64-build/ITK-source/Modules/Core/Common/src/itkMultiThreader.cxx:423:
itk::ERROR: MultiThreader(0x2823fd0): Exception occurred during SingleMethodExecute
```

---

<div class="post-metadata">

### Author: ![fbudin](https://discourse.itk.org/user_avatar/discourse.itk.org/fbudin/32/14_2.png) [@fbudin](https://discourse.itk.org/u/fbudin)
#### Post date: [October 27, 2017, 2:36pm UTC](https://discourse.itk.org/t/itk-approximatesigneddistancemapimagefilter-error/361/2 "2017-10-27T14:36:26Z")

</div>

Another error with this filter was reported. I’ll investigate the issue.

---

<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: [October 27, 2017, 2:45pm UTC](https://discourse.itk.org/t/itk-approximatesigneddistancemapimagefilter-error/361/3 "2017-10-27T14:45:12Z")

</div>

That error message is not very informative. You may get a better error message if you add:

```auto
mapping_filter.SetNumberOfThreads(1)

```

If that does not give a better error message, I’m inclined to thing that there may be something unexpected with your input image. Can you share your input data? Or can you procedurally produce an image which reproduces the problem?

---

<div class="post-metadata">

### Author: ![mafuentes](https://discourse.itk.org/user_avatar/discourse.itk.org/mafuentes/32/647_2.png) [@mafuentes](https://discourse.itk.org/u/mafuentes)
#### Post date: [October 27, 2017, 4:29pm UTC](https://discourse.itk.org/t/itk-approximatesigneddistancemapimagefilter-error/361/4 "2017-10-27T16:29:15Z")

</div>

Thanks @blowekamp, that solved the problem.

Though while testing I got an error because of image size, I scaled it down and works. The original image is a 1494x1494 8-bit image.

This was the error:

```
RuntimeError: /work/standalone-x64-build/ITK-source/Modules/Core/Common/src/itkMultiThreader.cxx:427:
itk::ERROR: MultiThreader(0x3589bd0): Exception occurred during SingleMethodExecute
/work/standalone-x64-build/ITK-source/Modules/Filtering/DistanceMap/include/itkIsoContourDistanceImageFilter.hxx:388:
itk::ERROR: IsoContourDistanceImageFilter(0x1593a90): Gradient norm is lower than pixel precision
```
