1
/*=========================================================================
3
Program: Insight Segmentation & Registration Toolkit
4
Module: $RCSfile: itkBoxMeanImageFilterTest.cxx,v $
6
Date: $Date: 2008-08-07 09:19:55 $
7
Version: $Revision: 1.1 $
9
Copyright (c) Insight Software Consortium. All rights reserved.
10
See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
12
This software is distributed WITHOUT ANY WARRANTY; without even
13
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14
PURPOSE. See the above copyright notices for more information.
16
=========================================================================*/
18
#pragma warning ( disable : 4786 )
22
#include "itkBoxMeanImageFilter.h"
23
#include "itkImageFileReader.h"
24
#include "itkImageFileWriter.h"
25
#include "itkTextOutput.h"
26
#include "itkNumericTraits.h"
27
#include "itkFilterWatcher.h"
29
int itkBoxMeanImageFilterTest(int ac, char* av[] )
31
// Comment the following if you want to use the itk text output window
32
itk::OutputWindow::SetInstance(itk::TextOutput::New());
36
std::cerr << "Usage: " << av[0] << " InputImage BaselineImage radius" << std::endl;
40
typedef itk::Image<unsigned char, 2> ImageType;
42
typedef itk::ImageFileReader<ImageType> ReaderType;
43
ReaderType::Pointer input = ReaderType::New();
44
input->SetFileName(av[1]);
47
typedef itk::BoxMeanImageFilter<ImageType,ImageType> FilterType;
48
FilterType::Pointer filter = FilterType::New();
49
FilterWatcher filterWatch(filter);
51
typedef FilterType::RadiusType RadiusType;
53
// test default values
56
if ( filter->GetRadius() != r1 )
58
std::cerr << "Wrong default Radius." << std::endl;
62
// set radius with a radius type
65
filter->SetRadius( r5 );
66
if ( filter->GetRadius() != r5 )
68
std::cerr << "Radius value is not the expected one:�r5." << std::endl;
72
// set radius with an integer
73
filter->SetRadius( 1 );
74
if ( filter->GetRadius() != r1 )
76
std::cerr << "Radius value is not the expected one:�r1." << std::endl;
82
int r = atoi( av[3] );
83
filter->SetInput(input->GetOutput());
84
filter->SetRadius( r );
87
catch (itk::ExceptionObject& e)
89
std::cerr << "Exception detected: " << e.GetDescription();
93
// Generate test image
94
typedef itk::ImageFileWriter<ImageType> WriterType;
95
WriterType::Pointer writer = WriterType::New();
96
writer->SetInput( filter->GetOutput() );
97
writer->SetFileName( av[2] );