ITK
4.1.0
Insight Segmentation and Registration Toolkit
|
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 __itkDiscreteGaussianDerivativeImageFunction_h 00019 #define __itkDiscreteGaussianDerivativeImageFunction_h 00020 00021 #include "itkNeighborhoodOperatorImageFunction.h" 00022 #include "itkGaussianDerivativeOperator.h" 00023 00024 namespace itk 00025 { 00046 template< class TInputImage, class TOutput = double > 00047 class ITK_EXPORT DiscreteGaussianDerivativeImageFunction: 00048 public ImageFunction< TInputImage, TOutput, TOutput > 00049 { 00050 public: 00051 00053 typedef DiscreteGaussianDerivativeImageFunction Self; 00054 00056 typedef ImageFunction< TInputImage, TOutput, TOutput > Superclass; 00057 00059 typedef SmartPointer< Self > Pointer; 00060 typedef SmartPointer< const Self > ConstPointer; 00061 00063 itkNewMacro(Self); 00064 00066 itkTypeMacro(DiscreteGaussianDerivativeImageFunction, ImageFunction); 00067 00069 typedef typename Superclass::InputImageType InputImageType; 00070 typedef typename Superclass::InputPixelType InputPixelType; 00071 typedef typename Superclass::IndexType IndexType; 00072 typedef typename Superclass::IndexValueType IndexValueType; 00073 typedef typename Superclass::ContinuousIndexType ContinuousIndexType; 00074 typedef typename Superclass::PointType PointType; 00075 00077 itkStaticConstMacro(ImageDimension2, unsigned int, 00078 InputImageType::ImageDimension); 00079 00081 typedef typename Superclass::OutputType OutputType; 00082 00084 typedef FixedArray< double, itkGetStaticConstMacro(ImageDimension2) > VarianceArrayType; 00085 typedef FixedArray< unsigned int, itkGetStaticConstMacro(ImageDimension2) > OrderArrayType; 00087 00088 typedef itk::GaussianDerivativeOperator< TOutput, 00089 itkGetStaticConstMacro(ImageDimension2) > GaussianDerivativeOperatorType; 00090 00092 typedef FixedArray< GaussianDerivativeOperatorType, 00093 itkGetStaticConstMacro(ImageDimension2) > GaussianDerivativeOperatorArrayType; 00094 00096 typedef Neighborhood< TOutput, itkGetStaticConstMacro(ImageDimension2) > KernelType; 00097 00100 typedef NeighborhoodOperatorImageFunction 00101 < InputImageType, TOutput > OperatorImageFunctionType; 00102 typedef typename OperatorImageFunctionType::Pointer OperatorImageFunctionPointer; 00103 00105 enum InterpolationModeType { NearestNeighbourInterpolation, LinearInterpolation }; 00106 public: 00107 00109 virtual OutputType Evaluate(const PointType & point) const; 00110 00112 virtual OutputType EvaluateAtIndex(const IndexType & index) const; 00113 00115 virtual OutputType EvaluateAtContinuousIndex( 00116 const ContinuousIndexType & index) const; 00117 00124 itkSetMacro(Variance, VarianceArrayType); 00125 itkGetConstMacro(Variance, const VarianceArrayType); 00126 itkSetVectorMacro(Variance, double, VarianceArrayType::Length); 00128 00130 virtual void SetVariance(double variance) 00131 { 00132 m_Variance.Fill(variance); 00133 this->Modified(); 00134 } 00136 00140 void SetSigma(const double sigma) 00141 { 00142 SetVariance(sigma * sigma); 00143 } 00144 00151 itkSetClampMacro(MaximumError, double, 0.00001, 0.99999); 00152 itkGetConstMacro(MaximumError, double); 00154 00156 itkSetMacro(Order, OrderArrayType); 00157 itkGetConstMacro(Order, const OrderArrayType); 00158 itkSetVectorMacro(Order, unsigned int, OrderArrayType::Length); 00160 00162 virtual void SetOrder(unsigned int order) 00163 { 00164 m_Order.Fill(order); 00165 this->Modified(); 00166 } 00168 00172 itkSetMacro(NormalizeAcrossScale, bool); 00173 itkGetConstMacro(NormalizeAcrossScale, bool); 00174 itkBooleanMacro(NormalizeAcrossScale); 00176 00178 itkSetMacro(UseImageSpacing, bool); 00179 itkGetConstMacro(UseImageSpacing, bool); 00180 itkBooleanMacro(UseImageSpacing); 00182 00187 itkSetMacro(MaximumKernelWidth, unsigned int); 00188 itkGetConstMacro(MaximumKernelWidth, unsigned int); 00190 00192 itkSetMacro(InterpolationMode, InterpolationModeType); 00193 itkGetConstMacro(InterpolationMode, InterpolationModeType); 00195 00200 virtual void SetInputImage(const InputImageType *ptr); 00201 00205 virtual void Initialize() { RecomputeGaussianKernel(); } 00206 protected: 00207 00208 DiscreteGaussianDerivativeImageFunction(); 00209 DiscreteGaussianDerivativeImageFunction(const Self &){} 00210 00211 ~DiscreteGaussianDerivativeImageFunction(){} 00212 00213 void operator=(const Self &){} 00214 void PrintSelf(std::ostream & os, Indent indent) const; 00215 00216 void RecomputeGaussianKernel(); 00217 00218 private: 00219 00221 VarianceArrayType m_Variance; 00222 00224 OrderArrayType m_Order; 00225 00228 double m_MaximumError; 00229 00233 unsigned int m_MaximumKernelWidth; 00234 00236 GaussianDerivativeOperatorArrayType m_OperatorArray; 00237 00240 KernelType m_DerivativeKernel; 00241 00243 OperatorImageFunctionPointer m_OperatorImageFunction; 00244 00246 bool m_NormalizeAcrossScale; 00247 00249 bool m_UseImageSpacing; 00250 00252 InterpolationModeType m_InterpolationMode; 00253 }; 00254 } // namespace itk 00255 00256 #if 0 //HACK: Not yet implemented 00257 // Define instantiation macro for this template. 00258 #define ITK_TEMPLATE_DiscreteGaussianDerivativeImageFunction(_, EXPORT, TypeX, TypeY) \ 00259 namespace itk \ 00260 { \ 00261 _( 2 ( class EXPORT DiscreteGaussianDerivativeImageFunction< ITK_TEMPLATE_2 TypeX > ) ) \ 00262 namespace Templates \ 00263 { \ 00264 typedef DiscreteGaussianDerivativeImageFunction< ITK_TEMPLATE_2 TypeX > \ 00265 DiscreteGaussianDerivativeImageFunction##TypeY; \ 00266 } \ 00267 } 00268 00269 #if ITK_TEMPLATE_EXPLICIT 00270 #include "Templates/itkDiscreteGaussianDerivativeImageFunction+-.h" 00271 #endif 00272 #endif 00273 00274 #if ITK_TEMPLATE_TXX 00275 #include "itkDiscreteGaussianDerivativeImageFunction.hxx" 00276 #endif 00277 00278 #endif 00279