ITK  4.0.0
Insight Segmentation and Registration Toolkit
itkMedianImageFunction.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 __itkMedianImageFunction_h
00019 #define __itkMedianImageFunction_h
00020 
00021 #include "itkImageFunction.h"
00022 #include "itkNumericTraits.h"
00023 
00024 namespace itk
00025 {
00046 template< class TInputImage, class TCoordRep = float >
00047 class ITK_EXPORT MedianImageFunction:
00048   public ImageFunction< TInputImage, typename TInputImage::PixelType,
00049                         TCoordRep >
00050 {
00051 public:
00052 
00054   typedef MedianImageFunction Self;
00055   typedef ImageFunction< TInputImage, typename TInputImage::PixelType,
00056                          TCoordRep >                     Superclass;
00057 
00058   typedef SmartPointer< Self >       Pointer;
00059   typedef SmartPointer< const Self > ConstPointer;
00060 
00062   itkTypeMacro(MedianImageFunction, ImageFunction);
00063 
00065   itkNewMacro(Self);
00066 
00068   typedef TInputImage                         InputImageType;
00069   typedef typename Superclass::InputPixelType InputPixelType;
00070 
00072   typedef typename Superclass::OutputType OutputType;
00073 
00075   typedef typename Superclass::IndexType IndexType;
00076 
00078   typedef typename Superclass::ContinuousIndexType ContinuousIndexType;
00079 
00081   typedef typename Superclass::PointType PointType;
00082 
00084   itkStaticConstMacro(ImageDimension, unsigned int,
00085                       InputImageType::ImageDimension);
00086 
00088   virtual OutputType EvaluateAtIndex(const IndexType & index) const;
00089 
00091   virtual OutputType Evaluate(const PointType & point) const
00092   {
00093     IndexType index;
00094 
00095     this->ConvertPointToNearestIndex(point, index);
00096     return this->EvaluateAtIndex(index);
00097   }
00098 
00099   virtual OutputType EvaluateAtContinuousIndex(
00100     const ContinuousIndexType & cindex) const
00101   {
00102     IndexType index;
00103 
00104     this->ConvertContinuousIndexToNearestIndex(cindex, index);
00105     return this->EvaluateAtIndex(index);
00106   }
00107 
00110   itkSetMacro( NeighborhoodRadius, unsigned int );
00111   itkGetConstReferenceMacro( NeighborhoodRadius, unsigned int );
00113 
00114 protected:
00115   MedianImageFunction();
00116   ~MedianImageFunction(){}
00117   void PrintSelf(std::ostream & os, Indent indent) const;
00118 
00119 private:
00120   MedianImageFunction(const Self &); //purposely not implemented
00121   void operator=(const Self &);      //purposely not implemented
00122 
00123   unsigned int m_NeighborhoodRadius;
00124 
00125 };
00126 } // end namespace itk
00127 
00128 // Define instantiation macro for this template.
00129 #define ITK_TEMPLATE_MedianImageFunction(_, EXPORT, TypeX, TypeY)     \
00130   namespace itk                                                       \
00131   {                                                                   \
00132   _( 2 ( class EXPORT MedianImageFunction< ITK_TEMPLATE_2 TypeX > ) ) \
00133   namespace Templates                                                 \
00134   {                                                                   \
00135   typedef MedianImageFunction< ITK_TEMPLATE_2 TypeX >                 \
00136   MedianImageFunction##TypeY;                                       \
00137   }                                                                   \
00138   }
00139 
00140 #if ITK_TEMPLATE_EXPLICIT
00141 #include "Templates/itkMedianImageFunction+-.h"
00142 #endif
00143 
00144 #if ITK_TEMPLATE_TXX
00145 #include "itkMedianImageFunction.hxx"
00146 #endif
00147 
00148 #endif
00149