ITK/Examples/Morphology/BinaryPruningImageFilter: Difference between revisions

From KitwarePublic
< ITK‎ | Examples
Jump to navigationJump to search
(Created page with "==BinaryPruningImageFilter.cxx== <source lang="cpp"> #include "itkImage.h" #include "itkBinaryPruningImageFilter.h" #include "itkImageFileReader.h" #include "itkBinaryBallStructu...")
 
(Deprecated content that is moved to sphinx)
 
(6 intermediate revisions by 3 users not shown)
Line 1: Line 1:
==BinaryPruningImageFilter.cxx==
{{warning|1=The media wiki content on this page is no longer maintained.  The examples presented on the https://itk.org/Wiki/* pages likely require ITK version 4.13 or earlier releases.   In many cases, the examples on this page no longer conform to the best practices for modern ITK versions.}}
<source lang="cpp">
#include "itkImage.h"
#include "itkBinaryPruningImageFilter.h"
#include "itkImageFileReader.h"
#include "itkBinaryBallStructuringElement.h"
#include "itkImageFileWriter.h"
 
int main(int argc, char *argv[])
{
  if(argc < 3)
    {
    std::cerr << "Usage: " << std::endl;
    std::cerr << argv[0] << " InputImageFile OutputImageFile [iteration]" << std::endl;
    return EXIT_FAILURE;
    }
 
  unsigned int iteration = 1;
  if (argc > 3)
    {
    iteration = atoi(argv[3]);
    }
 
  const unsigned Dimension = 3;
  typedef unsigned char                      PixelType;
  typedef itk::Image< PixelType, Dimension > ImageType;
  typedef itk::ImageFileReader<ImageType>    ReaderType;
  ReaderType::Pointer reader = ReaderType::New();
  reader->SetFileName(argv[1]);
   reader->Update();
 
  typedef itk::BinaryPruningImageFilter <ImageType, ImageType >
          BinaryPruningImageFilterType;
 
  BinaryPruningImageFilterType::Pointer pruneFilter
          = BinaryPruningImageFilterType::New();
  pruneFilter->SetInput(reader->GetOutput());
  pruneFilter->SetIteration(iteration);
 
  typedef itk::ImageFileWriter< ImageType > WriterType;
  WriterType::Pointer writer = WriterType::New();
  writer->SetInput( pruneFilter->GetOutput() );
  writer->SetFileName( argv[2] );
  writer->Update();
 
  return EXIT_SUCCESS;
}
</source>

Latest revision as of 17:59, 6 June 2019

Warning: The media wiki content on this page is no longer maintained. The examples presented on the https://itk.org/Wiki/* pages likely require ITK version 4.13 or earlier releases. In many cases, the examples on this page no longer conform to the best practices for modern ITK versions.