Geodesic Active contour Level set image filter error

Hello,
I am trying to use Geodesic Active contour Level set image filter from
https://itk.org/ITKExamples/src/Segmentation/LevelSets/SegmentWithGeodesicActiveContourLevelSet/Documentation.html

First I was trying to work with only one dicom image. And now working with 3D series of slices . But got the same following error.

Exception thrown while writing the series

itk::ExceptionObject (0x558e6c20f260)
Location: “void itk::ImageToImageFilter<TInputImage, TOutputImage>::VerifyInputInformation() const [with TInputImage = itk::Image<float, 3>; TOutputImage = itk::Image<float, 3>]”
File: /usr/local/include/ITK-5.0/itkImageToImageFilter.hxx
Line: 233
Description: itk::ERROR: GeodesicActiveContourLevelSetImageFilter(0x558e6c203290): Inputs do not occupy the same physical space!
InputImage Origin: [-1.9612988e+02, -3.3912988e+02, -9.7220000e+02], InputImageInitialImage Origin: [0.0000000e+00, 0.0000000e+00, 0.0000000e+00]
Tolerance: 7.4023437e-07
InputImage Spacing: [7.4023438e-01, 7.4023438e-01, 1.0000000e+00], InputImageInitialImage Spacing: [1.0000000e+00, 1.0000000e+00, 1.0000000e+00]
Tolerance: 7.4023437e-07

I don’t understand why is it coming.
Anyone knows what is the solution.
Thanks in advance.

Both the origin and spacing of your two images ‘InputImage’ and ‘InputImageInitialimage’ are different. Therefore, the error ’ inputs do not occupy the same physical space!’. I suggest you start with looking at functions set origin and set spacing. Hope this helps.

1 Like

The example works for me with following arguments: C:\Dev\ITKExamples\Build\src\Segmentation\LevelSets\SegmentWithGeodesicActiveContourLevelSet\BrainProtonDensitySlice.png C:/a/LeftVentricle.png 81 114 5.0 1.0 -0.5 3.0 2.0 100

It looks like you modified the source code to run in 3D. Can you share it?

the code is working with PNG file. But not with DICOM.

  1. First I have tried this example with only single DICOM image. Just added GDCMIO in my code.
    These are my arguments -
    ./GeodesicActiveContourLevelSet IMG075.dcm contour.dcm 81 114 5.0 1.0 -0.5 3.0 2.0 100

And I got following Error:
itk::ExceptionObject (0x55d65388f360)
Location: “void itk::ImageToImageFilter<TInputImage, TOutputImage>::VerifyInputInformation() const [with TInputImage = itk::Image<float, 2>; TOutputImage = itk::Image<float, 2>]”
File: /usr/local/include/ITK-5.0/itkImageToImageFilter.hxx
Line: 233
Description: itk::ERROR: GeodesicActiveContourLevelSetImageFilter(0x55d65388e630): Inputs do not occupy the same physical space!
InputImage Origin: [-1.9631494e+02, -3.3931494e+02], InputImageInitialImage Origin: [0.0000000e+00, 0.0000000e+00]
Tolerance: 3.7011700e-07
InputImage Spacing: [3.7011700e-01, 3.7011700e-01], InputImageInitialImage Spacing: [1.0000000e+00, 1.0000000e+00]
Tolerance: 3.7011700e-07

Is it problem with my data type?
I am getting those Output1.png, output2.png, output3.png in my directory. But not output4.png. why?
If I am working with DICOM images, then what changes should I do in my code?

Yes I have modified the code to work with Volume of DICOM slices.
Here i have attached it.
GeodesicActiveContourLevelSetImageFilter3d.cxx (7.2 KB)

Could you please check the code and tell me what is wrong with it?
Because I am getting the same error i have mentioned before. (problem with physical space)

Could you please tell me how to do use those functions? Should I need to change my Input image origin and set it to 0)?
How to do it?

It is likely that your DICOM file has non-identity index to physical transform matrix, and that is causing the problem.

When I try the original example, but as an input use .nrrd file which has slightly modified meta-data, I run into the issue too.

Proposed solution is in PR 126.

Thank you. It solved the issue.
But I am unable to understand how to set the values of sigma, alpha and beta?
I am trying to use this geodesic active contour level set image filter to segment the liver.
I have tried different values but still unable to achieve the good result.
Do you have any tips for how to select the values for sigma, alpha & beta?

The best advice in these kind of cases is to read the paper which the method implements, in this case “Geodesic Active Contours”, V. Caselles, R. Kimmel and G. Sapiro. International Journal on Computer Vision, Vol 22, No. 1, pp 61-97, 1997. Reading the paper usually helps you understand the parameters. Then you have to experiment with different values.

Okay. I will check it.
The code which I sent before which I modified to run in 3D, is it correct?
Could you please check that, and let me know where it has mistakes or not?
& what changes should I need to do?
Thank you so much.

Greatings I implemented your 3D code. I think it is correct since I wrote a similar code for Connected Threshold Image Filter in 3D.

I am getting segmentation fault with this one
Should I change the parameters?


(in Portuguese)