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