ITK/Release 4/Why Switch to ITKv4/SimplifiedITK/DiscreteGaussianFilter
From KitwarePublic
< ITK | Release 4 | Why Switch to ITKv4 | SimplifiedITK(Redirected from ITK Release 4/Why Switch to ITKv4/SimplifiedITK/DiscreteGaussianFilter)
Jump to navigationJump to search
C++
<source lang="cpp">
- include <iostream>
- include "itkDiscreteGaussianImageFilter.h"
- include "itkImageFileReader.h"
- include "itkImageFileWriter.h"
int main( int argc, char* argv[] ) {
if( argc < 3 ) { std::cerr << "Usage: " << argv[0] << " inputImage outputImage" << std::endl; return 1; }
// Define types typedef float InputPixelType; typedef float OutputPixelType; typedef itk::Image<InputPixelType, 2> InputImageType; typedef itk::Image<OutputPixelType,2> OutputImageType;
typedef itk::ImageFileReader< InputImageType > ReaderType; typedef itk::DiscreteGaussianImageFilter< InputImageType, OutputImageType > FilterType; typedef itk::ImageFileWriter< OutputImageType > WriterType;
// Create filters ReaderType::Pointer reader = ReaderType::New(); FilterType::Pointer filter = FilterType::New(); WriterType::Pointer writer = WriterType::New();
// Set the filter parameters reader->SetFileName( argv[1] ); filter->SetVariance( 4.0 ); filter->SetMaximumKernelWidth( 10 ); writer->SetFileName( argv[2] );
// Connect the pipeline filter->SetInput( reader->GetOutput() ); writer->SetInput( filter->GetOutput() ); try { writer->Update(); } catch( const itk::ExceptionObject & e ) { std::cerr << "Error: " << e.what() << std::endl; return 1; }
return 0;
} </source>
WrapITK
SimpleITK
<source lang="python"> import SimpleITK input = SimpleITK.ReadImage ( filename ) output = SimpleITK.DiscreteGaussianFilter( input, 1.0, 5 ) </source>