Hello,<br><br>I am trying to run itkGeodesicActiveContourLevelSetImageFilter to a 3D volume and then extract a slice using the ExtractImageFilter.Considering the pipeline, first I need to set a reader , then the filter GAC, then the extract image filter and finally a writer to get a 2D png image. To set the input region of the ExtractImageFilter I think that I need to update the thresholder firstly (according with the theory of itk manual). But when I debugging I get an excetion (in the highligted point of my code). Could somebody help me? What I am doning wrong in the code or in the pipeline that I am using?<br>
<br><br>ThresholdingFilterType::Pointer thresholder = ThresholdingFilterType::New();<br>                        <br>  thresholder-&gt;SetLowerThreshold( -1000.0 );<br>  thresholder-&gt;SetUpperThreshold(     0.0 );<br><br>
  thresholder-&gt;SetOutsideValue(  0  );<br>  thresholder-&gt;SetInsideValue(  255 );<br><br> <br>  ReaderType::Pointer reader = ReaderType::New();<br>  reader-&gt;SetFileName(fileName.toStdString());<br><br><br>  SmoothingFilterType::Pointer smoothing = SmoothingFilterType::New();<br>
<br>  GradientFilterType::Pointer  gradientMagnitude = GradientFilterType::New();<br><br>  SigmoidFilterType::Pointer sigmoid = SigmoidFilterType::New();<br><br>  sigmoid-&gt;SetOutputMinimum(  0.0  );<br>  sigmoid-&gt;SetOutputMaximum(  1.0  );<br>
<br><br>   FastMarchingFilterType::Pointer  fastMarching = FastMarchingFilterType::New();<br><br>   GeodesicActiveContourFilterType::Pointer geodesicActiveContour = <br>                                     GeodesicActiveContourFilterType::New();<br>
<br>     FilterType_extract::Pointer filter_extract = FilterType_extract::New();<br><br>         WriterType::Pointer writer = WriterType::New();<br>    writer-&gt;SetFileName( &quot;result_z.png&quot; );<br>     <br><br>  const double propagationScaling =  ui-&gt;doubleSpinBox_propagationScaling-&gt;value();<br>
  geodesicActiveContour-&gt;SetPropagationScaling( propagationScaling );<br>  geodesicActiveContour-&gt;SetCurvatureScaling( 1.0 );<br>  geodesicActiveContour-&gt;SetAdvectionScaling( 1.0 );<br><br><br>  geodesicActiveContour-&gt;SetMaximumRMSError( 0.02 );<br>
  geodesicActiveContour-&gt;SetNumberOfIterations( 800 );<br><br><br>  smoothing-&gt;SetInput( reader-&gt;GetOutput() );<br>  gradientMagnitude-&gt;SetInput( smoothing-&gt;GetOutput() );<br>  sigmoid-&gt;SetInput( gradientMagnitude-&gt;GetOutput() );<br>
<br>  geodesicActiveContour-&gt;SetInput(  fastMarching-&gt;GetOutput() );<br>  geodesicActiveContour-&gt;SetFeatureImage( sigmoid-&gt;GetOutput() );<br><br>  thresholder-&gt;SetInput( geodesicActiveContour-&gt;GetOutput() );<br>
<br>  //////////////////////////<br>  thresholder-&gt;Update();<br>  InputImageType::RegionType inputRegion =<br>           thresholder-&gt;GetOutput()-&gt;GetLargestPossibleRegion();<br><br>  InputImageType::SizeType size = inputRegion.GetSize();<br>
 <br>  // get the size of the hole 3D image<br>  size_x = size[0];<br>  size_y = size[1];<br>  size_z = size[2];<br>  <br>  // get slices of z coordinate<br>  size[2] = 0; <br><br>   InputImageType::IndexType start = inputRegion.GetIndex();<br>
 // const unsigned int sliceNumber = 90;<br>  ui-&gt;verticalScrollBar_z-&gt;setRange(0,size_z-1);<br>  unsigned int sliceNumber = ui-&gt;verticalScrollBar_z-&gt;value();<br>  start[2] = sliceNumber;<br> // ui-&gt;verticalScrollBar_z-&gt;setValue(sliceNumber);<br>
 <br><br>  InputImageType::RegionType desiredRegion;<br>  desiredRegion.SetSize( size );<br>  desiredRegion.SetIndex( start );<br><br>  filter_extract-&gt;SetExtractionRegion( desiredRegion );<br><br>  ////////////////////////////<br>
<br>  filter_extract-&gt;SetInput( thresholder-&gt;GetOutput() );<br>  writer-&gt;SetInput( filter_extract-&gt;GetOutput() );<br><br><br>  smoothing-&gt;SetTimeStep( 0.0625 );<br>  smoothing-&gt;SetNumberOfIterations(  5 );<br>
  smoothing-&gt;SetConductanceParameter( 9.0 );<br><br>  const double sigma = ui-&gt;doubleSpinBox_sigma-&gt;value();   <br>  gradientMagnitude-&gt;SetSigma(  sigma  );<br><br>  const double alpha =  ui-&gt;doubleSpinBox_alpha-&gt;value(); <br>
  const double beta  =  ui-&gt;doubleSpinBox_beta-&gt;value(); <br>  sigmoid-&gt;SetAlpha( alpha );<br>  sigmoid-&gt;SetBeta(  beta  );<br><br><br>  NodeContainer::Pointer seeds = NodeContainer::New();<br><br>  InputImageType::IndexType  seedPosition;<br>
  <br>  seedPosition[0] = ui-&gt;doubleSpinBox_seed_x-&gt;value(); <br>  seedPosition[1] = ui-&gt;doubleSpinBox_seed_y-&gt;value();<br>  seedPosition[2] = ui-&gt;doubleSpinBox_seed_z-&gt;value();<br><br>  const double initialDistance = ui-&gt;doubleSpinBox_initial_distance-&gt;value();<br>
<br>  NodeType node;<br><br>  const double seedValue = - initialDistance;<br>  <br>  node.SetValue( seedValue );<br>  node.SetIndex( seedPosition );<br><br><br>  seeds-&gt;Initialize();<br>  seeds-&gt;InsertElement( 0, node );<br>
<br>   fastMarching-&gt;SetTrialPoints(  seeds  );<br><br>   fastMarching-&gt;SetSpeedConstant( 1.0 );<br><br>    try<br>    {<br>        writer-&gt;Update();<br>    }<br>  catch( itk::ExceptionObject &amp; excep )<br>    {<br>
    std::cerr &lt;&lt; &quot;Exception caught !&quot; &lt;&lt; std::endl;<br>    std::cerr &lt;&lt; excep &lt;&lt; std::endl;<br>    }<br><div style="visibility: hidden; left: -5000px; position: absolute; z-index: 9999; padding: 0px; margin-left: 0px; margin-top: 0px; overflow: hidden; word-wrap: break-word; color: black; font-size: 10px; text-align: left; line-height: 130%;" id="avg_ls_inline_popup">
</div>