ITK  4.0.0
Insight Segmentation and Registration Toolkit
itkPowImageFilter.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 __itkPowImageFilter_h
00019 #define __itkPowImageFilter_h
00020 
00021 #include "itkBinaryFunctorImageFilter.h"
00022 #include "itkNumericTraits.h"
00023 
00024 namespace itk
00025 {
00026 namespace Functor
00027 {
00033 template< class TInput1, class TInput2 = TInput1, class TOutput = TInput1 >
00034 class Pow
00035 {
00036 public:
00037   ;
00038   Pow() {}
00039   bool operator!=(const Pow &) const
00040   {
00041     // we contain no data, so we are always the same
00042     return false;
00043   }
00045 
00046   bool operator==(const Pow & other) const
00047   {
00048     return !( *this != other );
00049   }
00050 
00051   inline TOutput operator()(const TInput1 & A, const TInput2 & B) const
00052   {
00053 
00054     typedef typename NumericTraits< TInput1 >::RealType RealType;
00055     return static_cast< TOutput >( vcl_pow(static_cast<RealType>(A),static_cast<RealType>(B)) );
00056   }
00057 };
00058 }
00091 template< class TInputImage1, class TInputImage2 = TInputImage1, class TOutputImage = TInputImage1 >
00092 class ITK_EXPORT PowImageFilter:
00093   public
00094   BinaryFunctorImageFilter< TInputImage1, TInputImage2, TOutputImage,
00095                             Functor::Pow<
00096                               typename TInputImage1::PixelType,
00097                               typename TInputImage2::PixelType,
00098                               typename TOutputImage::PixelType >   >
00099 
00100 {
00101 public:
00103   typedef PowImageFilter Self;
00104   typedef BinaryFunctorImageFilter< TInputImage1, TInputImage2, TOutputImage,
00105                                     Functor::Pow<
00106                                       typename TInputImage1::PixelType,
00107                                       typename TInputImage2::PixelType,
00108                                       typename TOutputImage::PixelType > > Superclass;
00109 
00110   typedef SmartPointer< Self >       Pointer;
00111   typedef SmartPointer< const Self > ConstPointer;
00112 
00114   itkNewMacro(Self);
00115 
00117   itkTypeMacro(PowImageFilter,
00118                BinaryFunctorImageFilter);
00119 
00120 #ifdef ITK_USE_CONCEPT_CHECKING
00121 
00124 #endif
00125 protected:
00126   PowImageFilter() {}
00127   // virtual ~PowImageFilter() {} default implementation OK
00128 private:
00129   PowImageFilter(const Self &); //purposely not implemented
00130   void operator=(const Self &); //purposely not implemented
00131 };
00132 } // end namespace itk
00134 
00135 #endif
00136