NifTK  16.4.1 - 0798f20
CMIC's Translational Medical Imaging Platform
itkDivideOrZeroImageFilter.h
Go to the documentation of this file.
1 /*=============================================================================
2 
3  NifTK: A software platform for medical image computing.
4 
5  Copyright (c) University College London (UCL). All rights reserved.
6 
7  This software is distributed WITHOUT ANY WARRANTY; without even
8  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
9  PURPOSE.
10 
11  See LICENSE.txt in the top level directory for details.
12 
13 =============================================================================*/
14 
15 #ifndef itkDivideOrZeroImageFilter_h
16 #define itkDivideOrZeroImageFilter_h
17 
18 #include <itkBinaryFunctorImageFilter.h>
19 #include <itkNumericTraits.h>
20 
21 namespace itk
22 {
23 
28 namespace Function {
29 
30 template< class TInput1, class TInput2, class TOutput>
31 class DivOrZero
32 {
33 public:
34  DivOrZero() {};
35  ~DivOrZero() {};
36  bool operator!=( const DivOrZero & ) const
37  {
38  return false;
39  }
40  bool operator==( const DivOrZero & other ) const
41  {
42  return !(*this != other);
43  }
44  inline TOutput operator()( const TInput1 & A, const TInput2 & B) const
45  {
46  if(B != (TInput2) 0)
47  {
48  return (TOutput)(A / B);
49  }
50  else
51  {
52  return 0;
53  }
54  }
55 };
56 }
57 
58 template <class TInputImage1, class TInputImage2, class TOutputImage>
59 class ITK_EXPORT DivideOrZeroImageFilter :
60  public
61 BinaryFunctorImageFilter<TInputImage1,TInputImage2,TOutputImage,
62  Function::DivOrZero<
63  typename TInputImage1::PixelType,
64  typename TInputImage2::PixelType,
65  typename TOutputImage::PixelType> >
66 {
67 public:
72 
76  typedef BinaryFunctorImageFilter<TInputImage1,TInputImage2,TOutputImage,
78  typename TInputImage1::PixelType,
79  typename TInputImage2::PixelType,
80  typename TOutputImage::PixelType>
82 
86  typedef SmartPointer<Self> Pointer;
87  typedef SmartPointer<const Self> ConstPointer;
88 
92  itkNewMacro(Self);
93 
95  itkTypeMacro(DivideOrZeroImageFilter,
96  BinaryFunctorImageFilter);
97 
98 #ifdef ITK_USE_CONCEPT_CHECKING
99 
100  itkConceptMacro(IntConvertibleToInput2Check,
101  (Concept::Convertible<int, typename TInputImage2::PixelType>));
102  itkConceptMacro(Input1Input2OutputDivisionOperatorsCheck,
103  (Concept::DivisionOperators<typename TInputImage1::PixelType,
104  typename TInputImage2::PixelType,
105  typename TOutputImage::PixelType>));
107 #endif
108 
109 protected:
112  DivideOrZeroImageFilter(const Self&) {}
113  void operator=(const Self&) {}
114 
115 };
116 
117 } // end namespace itk
118 
119 
120 #endif
SmartPointer< Self > Pointer
Definition: itkDivideOrZeroImageFilter.h:86
DivOrZero()
Definition: itkDivideOrZeroImageFilter.h:34
DivideOrZeroImageFilter()
Definition: itkDivideOrZeroImageFilter.h:110
bool operator!=(const DivOrZero &) const
Definition: itkDivideOrZeroImageFilter.h:36
Definition: niftkITKAffineResampleImage.cxx:74
TOutput operator()(const TInput1 &A, const TInput2 &B) const
Definition: itkDivideOrZeroImageFilter.h:44
~DivOrZero()
Definition: itkDivideOrZeroImageFilter.h:35
SmartPointer< const Self > ConstPointer
Definition: itkDivideOrZeroImageFilter.h:87
void operator=(const Self &)
Definition: itkDivideOrZeroImageFilter.h:113
float PixelType
Definition: niftkBreastDCEandADC.cxx:88
bool operator==(const DivOrZero &other) const
Definition: itkDivideOrZeroImageFilter.h:40
virtual ~DivideOrZeroImageFilter()
Definition: itkDivideOrZeroImageFilter.h:111
Definition: itkDivideOrZeroImageFilter.h:31
DivideOrZeroImageFilter(const Self &)
Definition: itkDivideOrZeroImageFilter.h:112
BinaryFunctorImageFilter< TInputImage1, TInputImage2, TOutputImage, Function::DivOrZero< typename TInputImage1::PixelType, typename TInputImage2::PixelType, typename TOutputImage::PixelType > > Superclass
Definition: itkDivideOrZeroImageFilter.h:81
DivideOrZeroImageFilter Self
Definition: itkDivideOrZeroImageFilter.h:71
Implements an operator for pixel-wise division of two images, and where divisor is zero...
Definition: itkDivideOrZeroImageFilter.h:59