1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
|
/*=========================================================================
Program: Insight Segmentation & Registration Toolkit
Module: $RCSfile: itkConvolutionImageFilterTestInt.cxx,v $
Language: C++
Date: $Date: 2009-02-17 20:08:45 $
Version: $Revision: 1.3 $
Copyright (c) Insight Software Consortium. All rights reserved.
See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#if defined(_MSC_VER)
#pragma warning ( disable : 4786 )
#endif
#include "itkConvolutionImageFilter.h"
#include "itkImageFileReader.h"
#include "itkImageFileWriter.h"
#include "itkSimpleFilterWatcher.h"
int itkConvolutionImageFilterTestInt(int argc, char * argv[])
{
if ( argc < 4 )
{
std::cout << "Usage: " << argv[0]
<< " inputImage kernelImage outputImage [normalizeImage]" << std::endl;
return EXIT_FAILURE;
}
const int ImageDimension = 2;
typedef unsigned char PixelType;
typedef itk::Image<PixelType, ImageDimension> ImageType;
typedef itk::ImageFileReader<ImageType> ReaderType;
ReaderType::Pointer reader1 = ReaderType::New();
reader1->SetFileName( argv[1] );
reader1->Update();
ReaderType::Pointer reader2 = ReaderType::New();
reader2->SetFileName( argv[2] );
reader2->Update();
typedef itk::ConvolutionImageFilter<ImageType> ConvolutionFilterType;
ConvolutionFilterType::Pointer convoluter
= ConvolutionFilterType::New();
convoluter->SetInput( reader1->GetOutput() );
convoluter->SetImageKernelInput( reader2->GetOutput() );
itk::SimpleFilterWatcher watcher(convoluter, "filter");
if( argc >= 5 )
{
convoluter->SetNormalize( static_cast<bool>( atoi( argv[4] ) ) );
}
typedef itk::ImageFileWriter<ImageType> WriterType;
WriterType::Pointer writer = WriterType::New();
writer->SetFileName( argv[3] );
writer->SetInput( convoluter->GetOutput() );
try
{
writer->Update();
}
catch ( itk::ExceptionObject & excp )
{
std::cerr << excp << std::endl;
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
|