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