1 #include "itkBinaryThinningImageFilter.h"
3 #include "itkImageFileReader.h"
4 #include "itkImageFileWriter.h"
5 #include "itkRescaleIntensityImageFilter.h"
7 typedef itk::Image<short, 3> ImageType;
9 int main(int argc, char *argv[])
12 typedef itk::ImageFileReader<ImageType> ImageReader;
13 ImageReader::Pointer reader = ImageReader::New();
14 std::string fileName = argv[1];
15 reader->SetFileName(fileName);
17 ImageType::Pointer image = reader->GetOutput();
19 typedef itk::BinaryThinningImageFilter <ImageType, ImageType> BinaryThinningImageFilterType;
20 BinaryThinningImageFilterType::Pointer binaryThinningImageFilter = BinaryThinningImageFilterType::New();
21 binaryThinningImageFilter->SetInput(image);
22 binaryThinningImageFilter->Update();
24 // Rescale the image so that it can be seen (the output is 0 and 1, we want 0 and 255)
25 typedef itk::RescaleIntensityImageFilter< ImageType, ImageType > RescaleType;
26 RescaleType::Pointer rescaler = RescaleType::New();
27 rescaler->SetInput( binaryThinningImageFilter->GetOutput() );
28 rescaler->SetOutputMinimum(0);
29 rescaler->SetOutputMaximum(255);
32 typedef itk::ImageFileWriter< ImageType > WriterType;
33 WriterType::Pointer writer = WriterType::New();
34 writer->SetFileName(argv[2]);
35 writer->SetInput(rescaler->GetOutput());