ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkComplexToModulusImageFilter.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 __itkComplexToModulusImageFilter_h
00019 #define __itkComplexToModulusImageFilter_h
00020 
00021 #include "itkUnaryFunctorImageFilter.h"
00022 #include "vnl/vnl_math.h"
00023 
00024 namespace itk
00025 {
00032 namespace Functor
00033 {
00034 template< class TInput, class TOutput >
00035 class ComplexToModulus
00036 {
00037 public:
00038   ComplexToModulus() {}
00039   ~ComplexToModulus() {}
00040   bool operator!=(const ComplexToModulus &) const
00041   {
00042     return false;
00043   }
00044 
00045   bool operator==(const ComplexToModulus & other) const
00046   {
00047     return !( *this != other );
00048   }
00049 
00050   inline TOutput operator()(const TInput & A) const
00051   {
00052     return (TOutput)( vcl_sqrt( A.real() * A.real()
00053                                 + A.imag() * A.imag() ) );
00054   }
00055 };
00056 }
00057 
00058 template< class TInputImage, class TOutputImage >
00059 class ITK_EXPORT ComplexToModulusImageFilter:
00060   public
00061   UnaryFunctorImageFilter< TInputImage, TOutputImage,
00062                            Functor::ComplexToModulus<
00063                              typename TInputImage::PixelType,
00064                              typename TOutputImage::PixelType >   >
00065 {
00066 public:
00068   typedef ComplexToModulusImageFilter Self;
00069   typedef UnaryFunctorImageFilter<
00070     TInputImage, TOutputImage,
00071     Functor::ComplexToModulus< typename TInputImage::PixelType,
00072                                typename TOutputImage::PixelType > > Superclass;
00073 
00074   typedef SmartPointer< Self >       Pointer;
00075   typedef SmartPointer< const Self > ConstPointer;
00076 
00078   itkNewMacro(Self);
00079 
00081   itkTypeMacro(ComplexToModulusImageFilter,
00082                UnaryFunctorImageFilter);
00083 
00084   typedef typename TInputImage::PixelType                     InputPixelType;
00085   typedef typename TOutputImage::PixelType                    OutputPixelType;
00086   typedef typename NumericTraits< InputPixelType >::ValueType InputPixelValueType;
00087 
00088 #ifdef ITK_USE_CONCEPT_CHECKING
00089 
00090   itkConceptMacro( InputMultiplyOperatorCheck,
00091                    ( Concept::MultiplyOperator< InputPixelValueType > ) );
00092 
00094 #endif
00095 protected:
00096   ComplexToModulusImageFilter() {}
00097   virtual ~ComplexToModulusImageFilter() {}
00098 private:
00099   ComplexToModulusImageFilter(const Self &); //purposely not implemented
00100   void operator=(const Self &);              //purposely not implemented
00101 };
00102 } // end namespace itk
00104 
00105 #endif
00106