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->SetLowerThreshold( -1000.0 );<br>  thresholder->SetUpperThreshold(     0.0 );<br><br>
  thresholder->SetOutsideValue(  0  );<br>  thresholder->SetInsideValue(  255 );<br><br> <br>  ReaderType::Pointer reader = ReaderType::New();<br>  reader->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->SetOutputMinimum(  0.0  );<br>  sigmoid->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->SetFileName( "result_z.png" );<br>     <br><br>  const double propagationScaling =  ui->doubleSpinBox_propagationScaling->value();<br>
  geodesicActiveContour->SetPropagationScaling( propagationScaling );<br>  geodesicActiveContour->SetCurvatureScaling( 1.0 );<br>  geodesicActiveContour->SetAdvectionScaling( 1.0 );<br><br><br>  geodesicActiveContour->SetMaximumRMSError( 0.02 );<br>
  geodesicActiveContour->SetNumberOfIterations( 800 );<br><br><br>  smoothing->SetInput( reader->GetOutput() );<br>  gradientMagnitude->SetInput( smoothing->GetOutput() );<br>  sigmoid->SetInput( gradientMagnitude->GetOutput() );<br>
<br>  geodesicActiveContour->SetInput(  fastMarching->GetOutput() );<br>  geodesicActiveContour->SetFeatureImage( sigmoid->GetOutput() );<br><br>  thresholder->SetInput( geodesicActiveContour->GetOutput() );<br>
<br>  //////////////////////////<br>  thresholder->Update();<br>  InputImageType::RegionType inputRegion =<br>           thresholder->GetOutput()->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->verticalScrollBar_z->setRange(0,size_z-1);<br>  unsigned int sliceNumber = ui->verticalScrollBar_z->value();<br>  start[2] = sliceNumber;<br> // ui->verticalScrollBar_z->setValue(sliceNumber);<br>
 <br><br>  InputImageType::RegionType desiredRegion;<br>  desiredRegion.SetSize( size );<br>  desiredRegion.SetIndex( start );<br><br>  filter_extract->SetExtractionRegion( desiredRegion );<br><br>  ////////////////////////////<br>
<br>  filter_extract->SetInput( thresholder->GetOutput() );<br>  writer->SetInput( filter_extract->GetOutput() );<br><br><br>  smoothing->SetTimeStep( 0.0625 );<br>  smoothing->SetNumberOfIterations(  5 );<br>
  smoothing->SetConductanceParameter( 9.0 );<br><br>  const double sigma = ui->doubleSpinBox_sigma->value();   <br>  gradientMagnitude->SetSigma(  sigma  );<br><br>  const double alpha =  ui->doubleSpinBox_alpha->value(); <br>
  const double beta  =  ui->doubleSpinBox_beta->value(); <br>  sigmoid->SetAlpha( alpha );<br>  sigmoid->SetBeta(  beta  );<br><br><br>  NodeContainer::Pointer seeds = NodeContainer::New();<br><br>  InputImageType::IndexType  seedPosition;<br>
  <br>  seedPosition[0] = ui->doubleSpinBox_seed_x->value(); <br>  seedPosition[1] = ui->doubleSpinBox_seed_y->value();<br>  seedPosition[2] = ui->doubleSpinBox_seed_z->value();<br><br>  const double initialDistance = ui->doubleSpinBox_initial_distance->value();<br>
<br>  NodeType node;<br><br>  const double seedValue = - initialDistance;<br>  <br>  node.SetValue( seedValue );<br>  node.SetIndex( seedPosition );<br><br><br>  seeds->Initialize();<br>  seeds->InsertElement( 0, node );<br>
<br>   fastMarching->SetTrialPoints(  seeds  );<br><br>   fastMarching->SetSpeedConstant( 1.0 );<br><br>    try<br>    {<br>        writer->Update();<br>    }<br>  catch( itk::ExceptionObject & excep )<br>    {<br>
    std::cerr << "Exception caught !" << std::endl;<br>    std::cerr << excep << 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>