ITK/Examples/Smoothing/BinaryMinMaxCurvatureFlowImageFilter

From KitwarePublic
< ITK‎ | Examples
Revision as of 21:05, 11 January 2012 by Arnaudgelas (talk | contribs) (Created page with "#include "itkImage.h" #include "itkImageFileReader.h" #include "itkImageFileWriter.h" #include "itkBinaryMinMaxCurvatureFlowImageFilter.h" int main(int argc, char* argv[]) { i...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search
  1. include "itkImage.h"
  2. include "itkImageFileReader.h"
  3. include "itkImageFileWriter.h"
  4. include "itkBinaryMinMaxCurvatureFlowImageFilter.h"

int main(int argc, char* argv[]) {

 if( argc != 4 )
   {
   std::cerr << argv[0] << " InputFileName OutputFileName NumberOfIterations" <<std ::endl;
   return EXIT_FAILURE;
   }
 const unsigned int Dimension = 3;
 typedef unsigned char InputPixelType;
 typedef float         OutputPixelType;
 typedef itk::Image< InputPixelType, Dimension >   InputImageType;
 typedef itk::ImageFileReader< InputImageType >    ReaderType;
 ReaderType::Pointer reader = ReaderType::New();
 reader->SetFileName( argv[1] );
 reader->Update();
 typedef itk::Image< OutputPixelType, Dimension > OutputImageType;
 typedef itk::BinaryMinMaxCurvatureFlowImageFilter< InputImageType, OutputImageType >    FilterType;
 FilterType::Pointer filter = FilterType::New();
 filter->SetInput( reader->GetOutput() );
 filter->SetThreshold( 255 );
 filter->SetNumberOfIterations( atoi( argv[3] ) );
 filter->Update();

/*

 typedef itk::BinaryThresholdImageFilter< OutputImageType, InputImageType >
   BinaryThresholdImageFilterType;
 BinaryThresholdImageFilterType::Pointer thresholdFilter
   = BinaryThresholdImageFilterType::New();
 thresholdFilter->SetInput(filter->GetOutput());
 thresholdFilter->SetLowerThreshold(0.);
 thresholdFilter->SetInsideValue(255);
 thresholdFilter->SetOutsideValue(0);
  • /
 typedef itk::ImageFileWriter< OutputImageType > WriterType;
 WriterType::Pointer writer = WriterType::New();
 writer->SetInput( filter->GetOutput() );
 writer->SetFileName( argv[2] );
 writer->Update();
 return EXIT_SUCCESS;

}