ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkInvertIntensityImageFilter.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 __itkInvertIntensityImageFilter_h
00019 #define __itkInvertIntensityImageFilter_h
00020 
00021 #include "itkUnaryFunctorImageFilter.h"
00022 
00023 namespace itk
00024 {
00025 namespace Functor
00026 {
00032 template< typename TInput, typename  TOutput >
00033 class InvertIntensityTransform
00034 {
00035 public:
00036   typedef typename NumericTraits< TInput >::RealType RealType;
00037   InvertIntensityTransform() { m_Maximum = NumericTraits< TInput >::max(); }
00038   ~InvertIntensityTransform() {}
00040 
00041   void SetMaximum(TOutput max) { m_Maximum = max; }
00042 
00043   bool operator!=(const InvertIntensityTransform & other) const
00044   {
00045     if ( m_Maximum != other.m_Maximum )
00046       {
00047       return true;
00048       }
00049     return false;
00050   }
00051 
00052   bool operator==(const InvertIntensityTransform & other) const
00053   {
00054     return !( *this != other );
00055   }
00056 
00057   inline TOutput operator()(const TInput & x) const
00058   {
00059     TOutput result = static_cast< TOutput >( m_Maximum - x );
00060 
00061     return result;
00062   }
00063 
00064 private:
00065   TInput m_Maximum;
00066 };
00067 }  // end namespace functor
00068 
00089 template< typename  TInputImage, typename  TOutputImage = TInputImage >
00090 class ITK_EXPORT InvertIntensityImageFilter:
00091   public
00092   UnaryFunctorImageFilter< TInputImage, TOutputImage,
00093                            Functor::InvertIntensityTransform<
00094                              typename TInputImage::PixelType,
00095                              typename TOutputImage::PixelType >   >
00096 {
00097 public:
00099   typedef InvertIntensityImageFilter Self;
00100   typedef UnaryFunctorImageFilter< TInputImage, TOutputImage,
00101                                    Functor::InvertIntensityTransform<
00102                                      typename TInputImage::PixelType,
00103                                      typename TOutputImage::PixelType > > Superclass;
00104   typedef SmartPointer< Self >       Pointer;
00105   typedef SmartPointer< const Self > ConstPointer;
00106 
00107   typedef typename TOutputImage::PixelType                   OutputPixelType;
00108   typedef typename TInputImage::PixelType                    InputPixelType;
00109   typedef typename NumericTraits< InputPixelType >::RealType RealType;
00110 
00112   itkNewMacro(Self);
00113 
00115   itkTypeMacro(InvertIntensityImageFilter,
00116                UnaryFunctorImageFilter);
00117 
00118   itkSetMacro(Maximum, InputPixelType);
00119   itkGetConstReferenceMacro(Maximum, InputPixelType);
00120 
00122   void PrintSelf(std::ostream & os, Indent indent) const;
00123 
00125   void BeforeThreadedGenerateData(void);
00126 
00127 #ifdef ITK_USE_CONCEPT_CHECKING
00128 
00129   itkConceptMacro( InputHasNumericTraitsCheck,
00130                    ( Concept::HasNumericTraits< InputPixelType > ) );
00131 
00133 #endif
00134 protected:
00135   InvertIntensityImageFilter();
00136   virtual ~InvertIntensityImageFilter() {}
00137 private:
00138   InvertIntensityImageFilter(const Self &); //purposely not implemented
00139   void operator=(const Self &);             //purposely not implemented
00141 
00142   InputPixelType m_Maximum;
00143 };
00144 } // end namespace itk
00145 
00146 #ifndef ITK_MANUAL_INSTANTIATION
00147 #include "itkInvertIntensityImageFilter.hxx"
00148 #endif
00149 
00150 #endif
00151