Hi,<div>I&#39;m trying to use GeodesicActiveContoursSegmentation with a 3D volume. I want to use a PET gradient image as the feature image and the CT image as the image to be segmented.</div><div>This is my code:</div><div>
<br></div><div><div>#include &quot;itkImage.h&quot;</div><div>#include &quot;itkGeodesicActiveContourLevelSetImageFilter.h&quot;</div><div><br></div><div>#include &quot;itkCurvatureAnisotropicDiffusionImageFilter.h&quot;</div>
<div>#include &quot;itkGradientMagnitudeRecursiveGaussianImageFilter.h&quot;</div><div>#include &quot;itkSigmoidImageFilter.h&quot;</div><div>#include &quot;itkFastMarchingImageFilter.h&quot;</div><div>#include &quot;itkRescaleIntensityImageFilter.h&quot;</div>
<div>#include &quot;itkBinaryThresholdImageFilter.h&quot;</div><div>#include &quot;itkImageFileReader.h&quot;</div><div>#include &quot;itkImageFileWriter.h&quot;</div><div><br></div><div><br></div><div>int main( int argc, char *argv[] )</div>
<div>{</div><div>  if( argc &lt; 7 )</div><div>    {</div><div>    std::cerr &lt;&lt; &quot;Missing Parameters &quot; &lt;&lt; std::endl;</div><div>    std::cerr &lt;&lt; &quot;Usage: &quot; &lt;&lt; argv[0];</div><div>    std::cerr &lt;&lt; &quot; inputImageCT  inputImagePT outputImage&quot;;</div>
<div>    std::cerr &lt;&lt; &quot; seedX seedY seedZ&quot;;</div><div>    return 1;</div><div>    }</div><div><br></div><div><br></div><div>  typedef   float           InternalPixelType;</div><div>  const     unsigned int    Dimension = 3;</div>
<div>  typedef itk::Image&lt; InternalPixelType, Dimension &gt;  InternalImageType;</div><div><br></div><div>  typedef unsigned char                            OutputPixelType;</div><div>  typedef itk::Image&lt; OutputPixelType, Dimension &gt; OutputImageType;</div>
<div>  typedef itk::BinaryThresholdImageFilter&lt; </div><div>                        InternalImageType, </div><div>                        OutputImageType    &gt;       ThresholdingFilterType;</div><div>  </div><div>  ThresholdingFilterType::Pointer thresholder = ThresholdingFilterType::New();</div>
<div>                        </div><div>  thresholder-&gt;SetLowerThreshold( -1000.0 );</div><div>  thresholder-&gt;SetUpperThreshold(     0.0 );</div><div><br></div><div>  thresholder-&gt;SetOutsideValue(  0  );</div><div>
  thresholder-&gt;SetInsideValue(  255 );</div><div><br></div><div><br></div><div>  typedef  itk::ImageFileReader&lt; InternalImageType &gt; ReaderType;</div><div>  typedef  itk::ImageFileWriter&lt;  OutputImageType  &gt; WriterType;</div>
<div><br></div><div>  ReaderType::Pointer reader = ReaderType::New();</div><div>  ReaderType::Pointer readerPT = ReaderType::New();</div><div>  WriterType::Pointer writer = WriterType::New();</div><div><br></div><div>  reader-&gt;SetFileName( argv[1] );</div>
<div>  readerPT-&gt;SetFileName( argv[2] );</div><div>  writer-&gt;SetFileName( argv[3] );</div><div><br></div><div><br></div><div>  typedef itk::RescaleIntensityImageFilter&lt; </div><div>                               InternalImageType, </div>
<div>                               OutputImageType &gt;   CastFilterType;</div><div><br></div><div>///filter in order to obtain the feature image///</div><div>  typedef   itk::CurvatureAnisotropicDiffusionImageFilter&lt; </div>
<div>                               InternalImageType, </div><div>                               InternalImageType &gt;  SmoothingFilterType;</div><div>  typedef   itk::GradientMagnitudeRecursiveGaussianImageFilter&lt; </div>
<div>                               InternalImageType, </div><div>                               InternalImageType &gt;  GradientFilterType;</div><div>  typedef   itk::SigmoidImageFilter&lt;</div><div>                               InternalImageType, </div>
<div>                               InternalImageType &gt;  SigmoidFilterType;</div><div><br></div><div>  SmoothingFilterType::Pointer smoothing = SmoothingFilterType::New();</div><div>  GradientFilterType::Pointer  gradientMagnitude = GradientFilterType::New();</div>
<div>  SigmoidFilterType::Pointer sigmoid = SigmoidFilterType::New();</div><div><br></div><div>  smoothing-&gt;SetTimeStep( 0.0625 );</div><div>  smoothing-&gt;SetNumberOfIterations(  5 );</div><div>  smoothing-&gt;SetConductanceParameter( 9.0 );</div>
<div><br></div><div>  const double sigma = 1.0;</div><div>  gradientMagnitude-&gt;SetSigma(  sigma  );</div><div><br></div><div>  const double alpha =  -0.5;</div><div>  const double beta  =  3.0;</div><div>  sigmoid-&gt;SetAlpha( alpha );</div>
<div>  sigmoid-&gt;SetBeta(  beta  );</div><div>  sigmoid-&gt;SetOutputMinimum(  0.0  );</div><div>  sigmoid-&gt;SetOutputMaximum(  1.0  );</div><div>///filter in order to obtain the feature image///</div><div><br></div><div>
<br></div><div>///level set///</div><div>  typedef  itk::FastMarchingImageFilter&lt; </div><div>                              InternalImageType, </div><div>                              InternalImageType &gt;    FastMarchingFilterType;  </div>
<div>  typedef  itk::GeodesicActiveContourLevelSetImageFilter&lt; InternalImageType, </div><div>                InternalImageType &gt;    GeodesicActiveContourFilterType;</div><div><br></div><div>  FastMarchingFilterType::Pointer  fastMarching = FastMarchingFilterType::New();</div>
<div>  GeodesicActiveContourFilterType::Pointer geodesicActiveContour = </div><div>                                     GeodesicActiveContourFilterType::New();</div><div><br></div><div>  const double propagationScaling = 2.0;</div>
<div><br></div><div>  geodesicActiveContour-&gt;SetPropagationScaling( propagationScaling );</div><div>  geodesicActiveContour-&gt;SetCurvatureScaling( 1.0 );</div><div>  geodesicActiveContour-&gt;SetAdvectionScaling( 1.0 );</div>
<div><br></div><div>  geodesicActiveContour-&gt;SetMaximumRMSError( 0.02 );</div><div>  geodesicActiveContour-&gt;SetNumberOfIterations( 800 );</div><div>///level set///</div><div><br></div><div><br></div><div>///utility for the fast marching///</div>
<div>  typedef FastMarchingFilterType::NodeContainer  NodeContainer;</div><div>  typedef FastMarchingFilterType::NodeType       NodeType;</div><div><br></div><div>  NodeContainer::Pointer seeds = NodeContainer::New();</div>
<div><br></div><div>  InternalImageType::IndexType  seedPosition;</div><div>  </div><div>  seedPosition[0] = atoi( argv[4] );</div><div>  seedPosition[1] = atoi( argv[5] );</div><div>  seedPosition[1] = atoi( argv[6] );</div>
<div><br></div><div>  const double initialDistance = 5.0;</div><div><br></div><div>  NodeType node;</div><div><br></div><div>  const double seedValue = - initialDistance;</div><div>  </div><div>  node.SetValue( seedValue );</div>
<div>  node.SetIndex( seedPosition );</div><div><br></div><div>  seeds-&gt;Initialize();</div><div>  seeds-&gt;InsertElement( 0, node );</div><div><br></div><div>  fastMarching-&gt;SetTrialPoints(  seeds  );</div><div><br>
</div><div>  fastMarching-&gt;SetSpeedConstant( 1.0 );</div><div>///utility for the fast marching///</div><div><br></div><div><br></div><div>  //<span class="Apple-tab-span" style="white-space:pre">        </span>1° step</div><div>
  smoothing-&gt;SetInput( readerPT-&gt;GetOutput() );</div><div>  gradientMagnitude-&gt;SetInput( smoothing-&gt;GetOutput() );</div><div>  sigmoid-&gt;SetInput( gradientMagnitude-&gt;GetOutput() );</div><div><br></div><div>
  //<span class="Apple-tab-span" style="white-space:pre">        </span>2° step</div><div>  geodesicActiveContour-&gt;SetInput(  fastMarching-&gt;GetOutput() );</div><div>  geodesicActiveContour-&gt;SetFeatureImage( sigmoid-&gt;GetOutput() );</div>
<div><br></div><div>  //<span class="Apple-tab-span" style="white-space:pre">        </span>3° step</div><div>  thresholder-&gt;SetInput( geodesicActiveContour-&gt;GetOutput() );</div><div>  writer-&gt;SetInput( thresholder-&gt;GetOutput() );</div>
<div> </div><div><br></div><div>  try</div><div>    {</div><div>    writer-&gt;Update();</div><div>    }</div><div>  catch( itk::ExceptionObject &amp; excep )</div><div>    {</div><div>    std::cerr &lt;&lt; &quot;Exception caught !&quot; &lt;&lt; std::endl;</div>
<div>    std::cerr &lt;&lt; excep &lt;&lt; std::endl;</div><div>    }</div><div>}</div><div><br></div><div><br></div><div>unfortunatly, when i try to run it, i obtain this output message:</div><div><br></div><div><div>Exception caught !</div>
<div><br></div><div>itk::ExceptionObject (009EEB20)</div><div>Location: &quot;__thiscall itk::ImageConstIterator&lt;class itk::Image&lt;class itk::FixedArray&lt;float,3&gt;,3&gt; &gt;:</div><div>ImageConstIterator(const class itk::Image&lt;class itk::FixedArray&lt;float,3&gt;,3&gt; *,const class itk::Imag</div>
<div>Region&lt;3&gt; &amp;)&quot;</div><div>File: c:\insighttoolkit-3.16.0\code\common\itkImageConstIterator.h</div><div>Line: 182</div><div>Description: itk::ERROR: Region ImageRegion (009EE8DC)</div><div>  Dimension: 3</div>
<div>  Index: [0, 0, 0]</div><div>  Size: [128, 128, 287]</div><div> is outside of buffered region ImageRegion (024035E0)</div><div>  Dimension: 3</div><div>  Index: [0, 0, 0]</div><div>  Size: [16, 16, 16]</div><div><br>
</div><div><br></div><div>i don&#39;t know why. Please help me, thanks, bye,</div><div><br></div><div>Marco</div></div></div>