ITK  4.0.0
Insight Segmentation and Registration Toolkit
itkTernaryMagnitudeImageFilter.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 __itkTernaryMagnitudeImageFilter_h
00019 #define __itkTernaryMagnitudeImageFilter_h
00020 
00021 #include "itkTernaryFunctorImageFilter.h"
00022 
00023 namespace itk
00024 {
00025 namespace Functor
00026 {
00032 template< class TInput1, class TInput2, class TInput3, class TOutput >
00033 class Modulus3
00034 {
00035 public:
00036   Modulus3() {}
00037   ~Modulus3() {}
00038   bool operator!=(const Modulus3 &) const
00039   {
00040     return false;
00041   }
00043 
00044   bool operator==(const Modulus3 & other) const
00045   {
00046     return !( *this != other );
00047   }
00048 
00049   inline TOutput operator()(const TInput1 & A,
00050                             const TInput2 & B,
00051                             const TInput3 & C) const
00052   { return (TOutput)vcl_sqrt( (double)( A * A + B * B + C * C ) ); }
00053 };
00054 }
00065 template< class TInputImage1, class TInputImage2,
00066           class TInputImage3, class TOutputImage >
00067 class ITK_EXPORT TernaryMagnitudeImageFilter:
00068   public
00069   TernaryFunctorImageFilter< TInputImage1, TInputImage2,
00070                              TInputImage3, TOutputImage,
00071                              Functor::Modulus3<
00072                                typename TInputImage1::PixelType,
00073                                typename TInputImage2::PixelType,
00074                                typename TInputImage3::PixelType,
00075                                typename TOutputImage::PixelType >   >
00076 {
00077 public:
00079   typedef TernaryMagnitudeImageFilter Self;
00080   typedef TernaryFunctorImageFilter<
00081     TInputImage1, TInputImage2,
00082     TInputImage3, TOutputImage,
00083     Functor::Modulus3<
00084       typename TInputImage1::PixelType,
00085       typename TInputImage2::PixelType,
00086       typename TInputImage3::PixelType,
00087       typename TOutputImage::PixelType >
00088     >                                   Superclass;
00089 
00090   typedef SmartPointer< Self >       Pointer;
00091   typedef SmartPointer< const Self > ConstPointer;
00092 
00094   itkNewMacro(Self);
00095 
00097   itkTypeMacro(TernaryMagnitudeImageFilter,
00098                TernaryFunctorImageFilter);
00099 protected:
00100   TernaryMagnitudeImageFilter() {}
00101   virtual ~TernaryMagnitudeImageFilter() {}
00102 private:
00103   TernaryMagnitudeImageFilter(const Self &); //purposely not implemented
00104   void operator=(const Self &);              //purposely not implemented
00105 };
00106 } // end namespace itk
00108 
00109 #endif
00110