[ITK-users] itk::BinaryThinningImageFilter3D

Daoued23 mlt.khawla at gmail.com
Wed Nov 11 03:33:17 EST 2015


Hello everyone,

I want to get an Hybrid Skeleton. So I started by testing itk's filter
"itk::BinaryThinningImageFilter3D" to obtain the curve skeleton, but it
doesn't seem to work. Here is my code.

#include "itkImage.h"
#include "itkImageFileReader.h"
#include "itkImageFileWriter.h"

#include "itkConnectedThresholdImageFilter.h"
#include "itkImageRegionIterator.h"
#include "itkBinaryThinningImageFilter3D.h"

#include <iostream>
#include <stdlib.h>  
using namespace std;

int main(int argc, char* argv[])
{
  // Verify the number of parameters in the command line
  if( argc <= 2 )
  {
    std::cerr << "Usage: " << std::endl;
    std::cerr << argv[0] << " inputImageFile outputImageFile" << std::endl;
    return EXIT_FAILURE;
  }
  char* infilename  = argv[1];
  char* outfilename = argv[2];

  const   unsigned int Dimension = 3;
  typedef signed short PixelType;   
  typedef itk::Image< PixelType, Dimension > ImageType;

  // Read image
  typedef itk::ImageFileReader< ImageType > ReaderType;
  ReaderType::Pointer reader = ReaderType::New();
  reader->SetFileName( infilename );
  try
  {
    reader->Update();
  }
  catch (itk::ExceptionObject &ex)
  {
    std::cout << ex << std::endl;
    return EXIT_FAILURE;
  }
  cout << infilename << " sucessfully read." << endl;

  // Define the thinning filter
  typedef itk::BinaryThinningImageFilter3D< ImageType, ImageType >
ThinningFilterType;
  ThinningFilterType::Pointer thinningFilter = ThinningFilterType::New();
  thinningFilter->SetInput( reader->GetOutput() );
  thinningFilter->Update();

  // output to file
  typedef itk::ImageFileWriter< ImageType > WriterType;
  WriterType::Pointer writer = WriterType::New();
  writer->SetInput( thinningFilter->GetOutput() );
  writer->SetFileName( outfilename );

  try
  {
    writer->Update();
  }
  catch (itk::ExceptionObject &ex)
  {
    std::cout << ex << std::endl;
    return EXIT_FAILURE;
  }
  cout << outfilename << " sucessfully written." << endl;

  cout << "Program terminated normally." << endl;
  return EXIT_SUCCESS;
}


And here is the volume I get in return, the initial volume is a region of
trabecular bone of size 30x30x30 voxels.
<http://itk-users.7.n7.nabble.com/file/n36449/thinningitk.png> 



--
View this message in context: http://itk-users.7.n7.nabble.com/itk-BinaryThinningImageFilter3D-tp36449.html
Sent from the ITK - Users mailing list archive at Nabble.com.


More information about the Insight-users mailing list