ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkMagnitudeAndPhaseToComplexImageFilter.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 __itkMagnitudeAndPhaseToComplexImageFilter_h
00019 #define __itkMagnitudeAndPhaseToComplexImageFilter_h
00020 
00021 #include "itkBinaryFunctorImageFilter.h"
00022 
00023 namespace itk
00024 {
00053 namespace Functor
00054 {
00055 template< class TInput1, class TInput2, class TOutput >
00056 class MagnitudeAndPhaseToComplex
00057 {
00058 public:
00059   MagnitudeAndPhaseToComplex() {}
00060   ~MagnitudeAndPhaseToComplex() {}
00061   bool operator!=(const MagnitudeAndPhaseToComplex &) const
00062   {
00063     return false;
00064   }
00065 
00066   bool operator==(const MagnitudeAndPhaseToComplex & other) const
00067   {
00068     return !( *this != other );
00069   }
00070 
00071   inline std::complex< TOutput > operator()(const TInput1 & A, const TInput2 & B) const
00072   {
00073     return std::complex< TOutput >( std::polar( static_cast< TOutput >( A ),  static_cast< TOutput >( B ) ) );
00074   }
00075 };
00076 }
00077 
00078 template< class TInputImage1,
00079           class TInputImage2 = TInputImage1,
00080           class TOutputImage = itk::Image< std::complex< typename TInputImage1::PixelType>,
00081                                            TInputImage1::ImageDimension > >
00082 class ITK_EXPORT MagnitudeAndPhaseToComplexImageFilter:
00083   public BinaryFunctorImageFilter<
00084     TInputImage1,
00085     TInputImage2,
00086     TOutputImage,
00087     Functor::MagnitudeAndPhaseToComplex<
00088       typename TInputImage1::PixelType,
00089       typename TInputImage2::PixelType,
00090       typename TOutputImage::PixelType::value_type > >
00091 
00092 {
00093 public:
00095   typedef MagnitudeAndPhaseToComplexImageFilter Self;
00096 
00097   typedef BinaryFunctorImageFilter<
00098     TInputImage1,
00099     TInputImage2,
00100     TOutputImage,
00101     Functor::MagnitudeAndPhaseToComplex<
00102       typename TInputImage1::PixelType,
00103       typename TInputImage2::PixelType,
00104       typename TOutputImage::PixelType::value_type > > Superclass;
00105 
00106   typedef typename TInputImage1::PixelType InputPixel1Type;
00107   typedef typename TInputImage2::PixelType InputPixel2Type;
00108   typedef typename TOutputImage::PixelType OutputPixelType;
00109 
00110   typedef SmartPointer< Self >       Pointer;
00111   typedef SmartPointer< const Self > ConstPointer;
00112 
00114   itkNewMacro(Self);
00115 
00117   itkTypeMacro(MagnitudeAndPhaseToComplexImageFilter, BinaryFunctorImageFilter);
00118 
00119 #ifdef ITK_USE_CONCEPT_CHECKING
00120 
00121   itkConceptMacro( Input1ConvertibleToDoubleCheck,
00122                    ( Concept::Convertible< InputPixel1Type, double > ) );
00123   itkConceptMacro( Input2ConvertibleToDoubleCheck,
00124                    ( Concept::Convertible< InputPixel2Type, double > ) );
00125   itkConceptMacro( DoubleConvertibleToOutputCheck,
00126                    ( Concept::Convertible< double, OutputPixelType > ) );
00127 
00129 #endif
00130 protected:
00131   MagnitudeAndPhaseToComplexImageFilter() {}
00132   virtual ~MagnitudeAndPhaseToComplexImageFilter() {}
00133 private:
00134   MagnitudeAndPhaseToComplexImageFilter(const Self &); //purposely not
00135                                                        // implemented
00136   void operator=(const Self &);                        //purposely not
00137                                                        // implemented
00138 };
00139 } // end namespace itk
00141 
00142 #endif
00143