ITK  4.2.0
Insight Segmentation and Registration Toolkit
itkSubtractImageFilter.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 #ifndef __itkSubtractImageFilter_h
19 #define __itkSubtractImageFilter_h
20 
22 
23 namespace itk
24 {
25 namespace Functor
26 {
32 template< class TInput1, class TInput2 = TInput1, class TOutput = TInput1 >
33 class Sub2
34 {
35 public:
36  Sub2() {}
37  ~Sub2() {}
38  bool operator!=(const Sub2 &) const
39  {
40  return false;
41  }
43 
44  bool operator==(const Sub2 & other) const
45  {
46  return !( *this != other );
47  }
48 
49  inline TOutput operator()(const TInput1 & A, const TInput2 & B) const
50  { return (TOutput)( A - B ); }
51 };
52 }
93 template< class TInputImage1, class TInputImage2 = TInputImage1, class TOutputImage = TInputImage1 >
94 class ITK_EXPORT SubtractImageFilter:
95  public
96  BinaryFunctorImageFilter< TInputImage1, TInputImage2, TOutputImage,
97  Functor::Sub2<
98  typename TInputImage1::PixelType,
99  typename TInputImage2::PixelType,
100  typename TOutputImage::PixelType > >
101 {
102 public:
105  typedef BinaryFunctorImageFilter<
106  TInputImage1, TInputImage2, TOutputImage,
107  Functor::Sub2< typename TInputImage1::PixelType,
108  typename TInputImage2::PixelType,
109  typename TOutputImage::PixelType > > Superclass;
110 
113 
115  itkNewMacro(Self);
116 
118  itkTypeMacro(SubtractImageFilter,
120 
121 #ifdef ITK_USE_CONCEPT_CHECKING
122 
123  itkConceptMacro( Input1Input2OutputAdditiveOperatorsCheck,
124  ( Concept::AdditiveOperators< typename TInputImage1::PixelType,
125  typename TInputImage2::PixelType,
126  typename TOutputImage::PixelType > ) );
127 
129 #endif
130 protected:
132  virtual ~SubtractImageFilter() {}
133 private:
134  SubtractImageFilter(const Self &); //purposely not implemented
135  void operator=(const Self &); //purposely not implemented
136 };
137 } // end namespace itk
139 
140 #endif
141