ITK  4.0.0
Insight Segmentation and Registration Toolkit
itkMultiplyImageFilter.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 __itkMultiplyImageFilter_h
00019 #define __itkMultiplyImageFilter_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 Mult
00034 {
00035 public:
00036   Mult() {}
00037   ~Mult() {}
00038   bool operator!=(const Mult &) const
00039   {
00040     return false;
00041   }
00043 
00044   bool operator==(const Mult & 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 }
00069 template< class TInputImage1, class TInputImage2 = TInputImage1, class TOutputImage = TInputImage1 >
00070 class ITK_EXPORT MultiplyImageFilter:
00071   public
00072   BinaryFunctorImageFilter< TInputImage1, TInputImage2, TOutputImage,
00073                             Functor::Mult<
00074                               typename TInputImage1::PixelType,
00075                               typename TInputImage2::PixelType,
00076                               typename TOutputImage::PixelType >   >
00077 {
00078 public:
00080   typedef MultiplyImageFilter Self;
00081   typedef BinaryFunctorImageFilter< TInputImage1, TInputImage2, TOutputImage,
00082                                     Functor::Mult<
00083                                       typename TInputImage1::PixelType,
00084                                       typename TInputImage2::PixelType,
00085                                       typename TOutputImage::PixelType >
00086                                     >                                 Superclass;
00087   typedef SmartPointer< Self >       Pointer;
00088   typedef SmartPointer< const Self > ConstPointer;
00089 
00091   itkNewMacro(Self);
00092 
00094   itkTypeMacro(MultiplyImageFilter,
00095                BinaryFunctorImageFilter);
00096 
00097 #ifdef ITK_USE_CONCEPT_CHECKING
00098 
00099   itkConceptMacro( Input1Input2OutputMultiplyOperatorCheck,
00100                    ( Concept::MultiplyOperator< typename TInputImage1::PixelType,
00101                                                 typename TInputImage2::PixelType,
00102                                                 typename TOutputImage::PixelType > ) );
00103 
00105 #endif
00106 protected:
00107   MultiplyImageFilter() {}
00108   virtual ~MultiplyImageFilter() {}
00109 private:
00110   MultiplyImageFilter(const Self &); //purposely not implemented
00111   void operator=(const Self &);      //purposely not implemented
00112 };
00113 } // end namespace itk
00115 
00116 #endif
00117