[Insight-users] ConnectedThresholdImageFilter.cxx on a 3D mhd image file

Luis Ibanez luis.ibanez at kitware.com
Fri Feb 5 13:39:04 EST 2010


Hi Marco

1) What are the coordinates of the "index"
     that you are passing to this program ?

     please add

            std::cout << "Seed index = " << index << std::endl;

     just after

             connectedThreshold->SetSeed( index );


2) What are the values of Upper and Lower threshold
    that you are passing to the program ?


3) What the the value of the pixel identified by
    the "index" position at the output of the
    smoothing filter ?

    You can find out by doing :

     std::cout << "pixel Value "
       << smoothing->GetOutput()->GetPixel( index )
       << std::endl;

    just after

            writer->Update();


It is likely that the pixel value of the see point that
you are providing is outside of the range defined
by the Lower and Upper threshold values.


    Regards,


          Luis


----------------------------------------------------------------------
On Wed, Feb 3, 2010 at 4:48 AM, Marco Gheza
<marcogheza4mailinglists at gmail.com> wrote:
> Hi,
> I'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't obtain a true
> segmentation.
> The code is this:
>
>
> #include "itkConnectedThresholdImageFilter.h"
>
>
> #include "itkImage.h"
> #include "itkCastImageFilter.h"
> #include "itkCurvatureFlowImageFilter.h"
> #include "itkImageFileReader.h"
> #include "itkImageFileWriter.h"
>
>
> int main( int argc, char *argv[])
> {
> if( argc < 8 )
>     {
>     std::cerr << "Missing Parameters " << std::endl;
>     std::cerr << "Usage: " << argv[0];
>     std::cerr << " inputImage  outputImage seedX seedY seedZ lowerThreshold
> upperThreshold" << std::endl;
>     return 1;
>     }
>
>   typedef   float           InternalPixelType;
>   const     unsigned int    Dimension = 3;
>   typedef itk::Image< InternalPixelType, Dimension >  InternalImageType;
>
>
>   typedef unsigned char                            OutputPixelType;
>   typedef itk::Image< OutputPixelType, Dimension > OutputImageType;
>   typedef itk::CastImageFilter< InternalImageType, OutputImageType >
>                                                    CastingFilterType;
>   CastingFilterType::Pointer caster = CastingFilterType::New();
>
>
>   typedef  itk::ImageFileReader< InternalImageType > ReaderType;
>   typedef  itk::ImageFileWriter<  OutputImageType  > WriterType;
>
>   ReaderType::Pointer reader = ReaderType::New();
>   WriterType::Pointer writer = WriterType::New();
>
>   reader->SetFileName( argv[1] );
>   writer->SetFileName( argv[2] );
>   typedef itk::CurvatureFlowImageFilter< InternalImageType,
> InternalImageType >
>     CurvatureFlowImageFilterType;
>
>   CurvatureFlowImageFilterType::Pointer smoothing =
>                          CurvatureFlowImageFilterType::New();
>
>   typedef itk::ConnectedThresholdImageFilter< InternalImageType,
>                                     InternalImageType > ConnectedFilterType;
>
>   ConnectedFilterType::Pointer connectedThreshold =
> ConnectedFilterType::New();
>
>
>   smoothing->SetInput( reader->GetOutput() );
>   connectedThreshold->SetInput( smoothing->GetOutput() );
>   caster->SetInput( connectedThreshold->GetOutput() );
>   writer->SetInput( caster->GetOutput() );
>
>   smoothing->SetNumberOfIterations( 5 );
>   smoothing->SetTimeStep( 0.125 );
>
>   const InternalPixelType lowerThreshold = atof( argv[6] );
>   const InternalPixelType upperThreshold = atof( argv[7] );
>
>  connectedThreshold->SetLower(  lowerThreshold  );
>   connectedThreshold->SetUpper(  upperThreshold  );
>
>   connectedThreshold->SetReplaceValue( 255 );
>
>   InternalImageType::IndexType  index;
>   index[0] = atoi( argv[3] );
>   index[1] = atoi( argv[4] );
>   index[2] = atoi( argv[5] );
>   connectedThreshold->SetSeed( index );
>
>   //InternalImageType::IndexType  index1;
>   //index1[0] = atoi( argv[3] );
>   //index1[1] = atoi( argv[4] );
>   //connectedThreshold->AddSeed( index1 );
>
>   try
>     {
>     writer->Update();
>     }
>   catch( itk::ExceptionObject & excep )
>     {
>     std::cerr << "Exception caught !" << std::endl;
>     std::cerr << excep << std::endl;
>     }
> return 0;
> }
>
>
> Can someone explain me if this is a problem of thresholding or a problem of
> image format?! I don't really know what to do.
> Thanks,
> Marco
>
>
> _____________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Kitware offers ITK Training Courses, for more information visit:
> http://www.kitware.com/products/protraining.html
>
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-users
>
>


More information about the Insight-users mailing list