Hi,<br><div class="gmail_quote">I&#39;m trying to use ConnectedThresholdImageFilter.cxx on a 3D image (a .mhd file). I inserted one seed point with 3 coordinates an tried different values of threshold. When I run the program, I save the output results in a .mhd file but i obtain only a black image. So i don&#39;t obtain a true segmentation. <br>

The code is this:<br><br><br>#include &quot;itkConnectedThresholdImageFilter.h&quot;<br><br><br>#include &quot;itkImage.h&quot;<br>#include &quot;itkCastImageFilter.h&quot;<br>#include &quot;itkCurvatureFlowImageFilter.h&quot;<br>

#include &quot;itkImageFileReader.h&quot;<br>#include &quot;itkImageFileWriter.h&quot;<br><br><br>int main( int argc, char *argv[])<br>{<br>if( argc &lt; 8 )<br>    {<br>    std::cerr &lt;&lt; &quot;Missing Parameters &quot; &lt;&lt; std::endl;<br>

    std::cerr &lt;&lt; &quot;Usage: &quot; &lt;&lt; argv[0];<br>    std::cerr &lt;&lt; &quot; inputImage  outputImage seedX seedY seedZ lowerThreshold upperThreshold&quot; &lt;&lt; std::endl;<br>    return 1;<br>    }<br>

<br>  typedef   float           InternalPixelType;<br>  const     unsigned int    Dimension = 3;<br>  typedef itk::Image&lt; InternalPixelType, Dimension &gt;  InternalImageType;<br><br><br>  typedef unsigned char                            OutputPixelType;<br>

  typedef itk::Image&lt; OutputPixelType, Dimension &gt; OutputImageType;<br>  typedef itk::CastImageFilter&lt; InternalImageType, OutputImageType &gt;<br>                                                   CastingFilterType;<br>

  CastingFilterType::Pointer caster = CastingFilterType::New();<br>                        <br><br>  typedef  itk::ImageFileReader&lt; InternalImageType &gt; ReaderType;<br>  typedef  itk::ImageFileWriter&lt;  OutputImageType  &gt; WriterType;<br>

<br>  ReaderType::Pointer reader = ReaderType::New();<br>  WriterType::Pointer writer = WriterType::New();<br><br>  reader-&gt;SetFileName( argv[1] );<br>  writer-&gt;SetFileName( argv[2] );<br>  typedef itk::CurvatureFlowImageFilter&lt; InternalImageType, InternalImageType &gt;<br>

    CurvatureFlowImageFilterType;<br><br>  CurvatureFlowImageFilterType::Pointer smoothing = <br>                         CurvatureFlowImageFilterType::New();<br> <br>  typedef itk::ConnectedThresholdImageFilter&lt; InternalImageType, <br>

                                    InternalImageType &gt; ConnectedFilterType;<br>  <br>  ConnectedFilterType::Pointer connectedThreshold = ConnectedFilterType::New();<br> <br><br>  smoothing-&gt;SetInput( reader-&gt;GetOutput() );<br>

  connectedThreshold-&gt;SetInput( smoothing-&gt;GetOutput() );<br>  caster-&gt;SetInput( connectedThreshold-&gt;GetOutput() );<br>  writer-&gt;SetInput( caster-&gt;GetOutput() );<br><br>  smoothing-&gt;SetNumberOfIterations( 5 );<br>

  smoothing-&gt;SetTimeStep( 0.125 );<br><br>  const InternalPixelType lowerThreshold = atof( argv[6] );<br>  const InternalPixelType upperThreshold = atof( argv[7] );<br><br> connectedThreshold-&gt;SetLower(  lowerThreshold  );<br>

  connectedThreshold-&gt;SetUpper(  upperThreshold  );<br><br>  connectedThreshold-&gt;SetReplaceValue( 255 );<br> <br>  InternalImageType::IndexType  index;<br>  index[0] = atoi( argv[3] );<br>  index[1] = atoi( argv[4] );<br>

  index[2] = atoi( argv[5] );<br>  connectedThreshold-&gt;SetSeed( index );<br><br>  //InternalImageType::IndexType  index1;<br>  //index1[0] = atoi( argv[3] );<br>  //index1[1] = atoi( argv[4] );<br>  //connectedThreshold-&gt;AddSeed( index1 );<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>return 0;<br>}<br><br><br>Can someone explain me if this is a problem of thresholding or a problem of image format?! I don&#39;t really know what to do.<br>Thanks,<br><font color="#888888">Marco<br>
</font></div><br>