ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkVectorMagnitudeImageFilter.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 __itkVectorMagnitudeImageFilter_h
00019 #define __itkVectorMagnitudeImageFilter_h
00020 
00021 #include "itkUnaryFunctorImageFilter.h"
00022 
00023 namespace itk
00024 {
00044 namespace Functor
00045 {
00046 template< class TInput, class TOutput >
00047 class VectorMagnitude
00048 {
00049 public:
00050   VectorMagnitude() {}
00051   ~VectorMagnitude() {}
00052 
00053   bool operator!=(const VectorMagnitude &) const
00054   {
00055     return false;
00056   }
00057 
00058   bool operator==(const VectorMagnitude & other) const
00059   {
00060     return !( *this != other );
00061   }
00062 
00063   inline TOutput operator()(const TInput & A) const
00064   {
00065     return static_cast< TOutput >( A.GetNorm() );
00066   }
00067 };
00068 }
00069 
00070 template< class TInputImage, class TOutputImage >
00071 class ITK_EXPORT VectorMagnitudeImageFilter:
00072   public
00073   UnaryFunctorImageFilter< TInputImage, TOutputImage,
00074                            Functor::VectorMagnitude< typename TInputImage::PixelType,
00075                                                      typename TOutputImage::PixelType >   >
00076 {
00077 public:
00079   typedef VectorMagnitudeImageFilter Self;
00080   typedef UnaryFunctorImageFilter<
00081     TInputImage, TOutputImage,
00082     Functor::VectorMagnitude< typename TInputImage::PixelType,
00083                               typename TOutputImage::PixelType > > Superclass;
00084 
00085   typedef SmartPointer< Self >       Pointer;
00086   typedef SmartPointer< const Self > ConstPointer;
00087 
00089   itkNewMacro(Self);
00090 
00092   itkTypeMacro(VectorMagnitudeImageFilter,
00093                UnaryFunctorImageFilter);
00094 
00095 #ifdef ITK_USE_CONCEPT_CHECKING
00096 
00097   itkConceptMacro( InputHasNumericTraitsCheck,
00098                    ( Concept::HasNumericTraits< typename TInputImage::PixelType::ValueType > ) );
00099 
00101 #endif
00102 protected:
00103   VectorMagnitudeImageFilter() {}
00104   virtual ~VectorMagnitudeImageFilter() {}
00105 private:
00106   VectorMagnitudeImageFilter(const Self &); //purposely not implemented
00107   void operator=(const Self &);                 //purposely not implemented
00108 };
00109 } // end namespace itk
00111 
00112 #endif
00113