[ITK] [ITK-users] itk::BinaryThinningImageFilter3D

Matt McCormick matt.mccormick at kitware.com
Wed Nov 11 07:45:28 EST 2015


Hello,

>From the screenshot, it is unclear whether the thinning worked or not
-- it would be better to visualize in 3D instead of 2D planes.

HTH,
Matt

On Wed, Nov 11, 2015 at 3:33 AM, Daoued23 <mlt.khawla at gmail.com> wrote:
> 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.
> _____________________________________
> 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.php
>
> 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://public.kitware.com/mailman/listinfo/insight-users
_____________________________________
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.php

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://public.kitware.com/mailman/listinfo/insight-users


More information about the Community mailing list