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...")
 
No edit summary
Line 47: Line 47:
}
}
</source>
</source>
==CMakeLists.txt==
{{#tag:syntaxhighlight
|
cmake_minimum_required(VERSION 2.6)
project(BinaryPruningImageFilter)
find_package(ITK REQUIRED)
include(${ITK_USE_FILE})
add_executable(BinaryPruningImageFilter BinaryPruningImageFilter.cxx)
target_link_libraries(BinaryPruningImageFilter ${ITK_LIBRARIES})
|lang=cmake}}

Revision as of 16:17, 15 December 2011

BinaryPruningImageFilter.cxx

<source lang="cpp">

  1. include "itkImage.h"
  2. include "itkBinaryPruningImageFilter.h"
  3. include "itkImageFileReader.h"
  4. include "itkBinaryBallStructuringElement.h"
  5. 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>

CMakeLists.txt

<syntaxhighlight lang="cmake"> cmake_minimum_required(VERSION 2.6)

project(BinaryPruningImageFilter)

find_package(ITK REQUIRED) include(${ITK_USE_FILE})

add_executable(BinaryPruningImageFilter BinaryPruningImageFilter.cxx) target_link_libraries(BinaryPruningImageFilter ${ITK_LIBRARIES})

</syntaxhighlight>