~ubuntu-branches/ubuntu/precise/insighttoolkit/precise

« back to all changes in this revision

Viewing changes to Testing/Code/Review/itkBoxMeanImageFilterTest.cxx

  • Committer: Bazaar Package Importer
  • Author(s): Steve M. Robbins
  • Date: 2008-12-19 20:16:49 UTC
  • mfrom: (1.2.1 upstream) (4.1.1 sid)
  • Revision ID: james.westby@ubuntu.com-20081219201649-drt97guwl2ryt0cn

* New upstream version.
  - patches/nifti-versioning.patch: Remove.  Applied upstream.
  - control:
  - rules: Update version numbers, package names.

* control: Build-depend on uuid-dev (gdcm uses it).

* copyright: Update download URL.

* rules: Adhere to parallel=N in DEB_BUILD_OPTIONS by setting MAKEFLAGS.

* compat: Set to 7.
* control: Update build-dep on debhelper to version >= 7.

* CMakeCache.txt.debian: Set CMAKE_BUILD_TYPE to "RELEASE" so that we
  build with -O3 (not -O2), necessary to optimize the templated code.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*=========================================================================
 
2
 
 
3
  Program:   Insight Segmentation & Registration Toolkit
 
4
  Module:    $RCSfile: itkBoxMeanImageFilterTest.cxx,v $
 
5
  Language:  C++
 
6
  Date:      $Date: 2008-08-07 09:19:55 $
 
7
  Version:   $Revision: 1.1 $
 
8
 
 
9
  Copyright (c) Insight Software Consortium. All rights reserved.
 
10
  See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
 
11
 
 
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.
 
15
 
 
16
=========================================================================*/
 
17
#if defined(_MSC_VER)
 
18
#pragma warning ( disable : 4786 )
 
19
#endif
 
20
 
 
21
#include <fstream>
 
22
#include "itkBoxMeanImageFilter.h"
 
23
#include "itkImageFileReader.h"
 
24
#include "itkImageFileWriter.h"
 
25
#include "itkTextOutput.h"
 
26
#include "itkNumericTraits.h"
 
27
#include "itkFilterWatcher.h"
 
28
 
 
29
int itkBoxMeanImageFilterTest(int ac, char* av[] )
 
30
{
 
31
  // Comment the following if you want to use the itk text output window
 
32
  itk::OutputWindow::SetInstance(itk::TextOutput::New());
 
33
 
 
34
  if(ac < 4)
 
35
    {
 
36
    std::cerr << "Usage: " << av[0] << " InputImage BaselineImage radius" << std::endl;
 
37
    return -1;
 
38
    }
 
39
 
 
40
  typedef itk::Image<unsigned char, 2> ImageType;
 
41
  
 
42
  typedef itk::ImageFileReader<ImageType> ReaderType;
 
43
  ReaderType::Pointer input  = ReaderType::New();
 
44
  input->SetFileName(av[1]);
 
45
  
 
46
  // Create a filter
 
47
  typedef itk::BoxMeanImageFilter<ImageType,ImageType> FilterType;
 
48
  FilterType::Pointer filter = FilterType::New();
 
49
  FilterWatcher filterWatch(filter);
 
50
 
 
51
  typedef FilterType::RadiusType RadiusType;
 
52
 
 
53
  // test default values
 
54
  RadiusType r1;
 
55
  r1.Fill( 1 );
 
56
  if ( filter->GetRadius() != r1 )
 
57
    {
 
58
    std::cerr << "Wrong default Radius." << std::endl;
 
59
    return EXIT_FAILURE;
 
60
    }
 
61
    
 
62
  // set radius with a radius type
 
63
  RadiusType r5;
 
64
  r5.Fill( 5 );
 
65
  filter->SetRadius( r5 );
 
66
  if ( filter->GetRadius() != r5 )
 
67
    {
 
68
    std::cerr << "Radius value is not the expected one:�r5." << std::endl;
 
69
    return EXIT_FAILURE;
 
70
    }
 
71
 
 
72
  // set radius with an integer
 
73
  filter->SetRadius( 1 );
 
74
  if ( filter->GetRadius() != r1 )
 
75
    {
 
76
    std::cerr << "Radius value is not the expected one:�r1." << std::endl;
 
77
    return EXIT_FAILURE;
 
78
    }
 
79
 
 
80
  try
 
81
    {
 
82
    int r = atoi( av[3] );
 
83
    filter->SetInput(input->GetOutput());
 
84
    filter->SetRadius( r );
 
85
    filter->Update();
 
86
    }
 
87
  catch (itk::ExceptionObject& e)
 
88
    {
 
89
    std::cerr << "Exception detected: "  << e.GetDescription();
 
90
    return EXIT_FAILURE;
 
91
    }
 
92
 
 
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] );
 
98
  writer->Update();
 
99
 
 
100
  return EXIT_SUCCESS;
 
101
}