ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkSubtractImageFilter.h
Go to the documentation of this file.
00001 /*=========================================================================
00002  *
00003  *  Copyright Insight Software Consortium
00004  *
00005  *  Licensed under the Apache License, Version 2.0 (the "License");
00006  *  you may not use this file except in compliance with the License.
00007  *  You may obtain a copy of the License at
00008  *
00009  *         http://www.apache.org/licenses/LICENSE-2.0.txt
00010  *
00011  *  Unless required by applicable law or agreed to in writing, software
00012  *  distributed under the License is distributed on an "AS IS" BASIS,
00013  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  *  See the License for the specific language governing permissions and
00015  *  limitations under the License.
00016  *
00017  *=========================================================================*/
00018 #ifndef __itkSubtractImageFilter_h
00019 #define __itkSubtractImageFilter_h
00020 
00021 #include "itkBinaryFunctorImageFilter.h"
00022 
00023 namespace itk
00024 {
00025 namespace Functor
00026 {
00032 template< class TInput1, class TInput2 = TInput1, class TOutput = TInput1 >
00033 class Sub2
00034 {
00035 public:
00036   Sub2() {}
00037   ~Sub2() {}
00038   bool operator!=(const Sub2 &) const
00039   {
00040     return false;
00041   }
00043 
00044   bool operator==(const Sub2 & other) const
00045   {
00046     return !( *this != other );
00047   }
00048 
00049   inline TOutput operator()(const TInput1 & A, const TInput2 & B) const
00050   { return (TOutput)( A - B ); }
00051 };
00052 }
00093 template< class TInputImage1, class TInputImage2 = TInputImage1, class TOutputImage = TInputImage1 >
00094 class ITK_EXPORT SubtractImageFilter:
00095   public
00096   BinaryFunctorImageFilter< TInputImage1, TInputImage2, TOutputImage,
00097                             Functor::Sub2<
00098                               typename TInputImage1::PixelType,
00099                               typename TInputImage2::PixelType,
00100                               typename TOutputImage::PixelType >   >
00101 {
00102 public:
00104   typedef SubtractImageFilter Self;
00105   typedef BinaryFunctorImageFilter<
00106     TInputImage1, TInputImage2, TOutputImage,
00107     Functor::Sub2< typename TInputImage1::PixelType,
00108                    typename TInputImage2::PixelType,
00109                    typename TOutputImage::PixelType > >  Superclass;
00110 
00111   typedef SmartPointer< Self >       Pointer;
00112   typedef SmartPointer< const Self > ConstPointer;
00113 
00115   itkNewMacro(Self);
00116 
00118   itkTypeMacro(SubtractImageFilter,
00119                BinaryFunctorImageFilter);
00120 
00121 #ifdef ITK_USE_CONCEPT_CHECKING
00122 
00123   itkConceptMacro( Input1Input2OutputAdditiveOperatorsCheck,
00124                    ( Concept::AdditiveOperators< typename TInputImage1::PixelType,
00125                                                  typename TInputImage2::PixelType,
00126                                                  typename TOutputImage::PixelType > ) );
00127 
00129 #endif
00130 protected:
00131   SubtractImageFilter() {}
00132   virtual ~SubtractImageFilter() {}
00133 private:
00134   SubtractImageFilter(const Self &); //purposely not implemented
00135   void operator=(const Self &);      //purposely not implemented
00136 };
00137 } // end namespace itk
00139 
00140 #endif
00141