itk.ApproximateSignedDistanceMapImageFilter error

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()

mapping_filter = itk.ApproximateSignedDistanceMapImageFilter[float_image, float_image].New()

And the error:

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

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

1 Like

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


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?

1 Like

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
itk::ERROR: IsoContourDistanceImageFilter(0x1593a90): Gradient norm is lower than pixel precision
1 Like