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 __itkDiscreteHessianGaussianImageFunction_h 00019 #define __itkDiscreteHessianGaussianImageFunction_h 00020 00021 #include "itkNeighborhoodOperatorImageFunction.h" 00022 #include "itkGaussianDerivativeOperator.h" 00023 #include "itkSymmetricSecondRankTensor.h" 00024 00025 namespace itk 00026 { 00045 template< class TInputImage, class TOutput = double > 00046 class ITK_EXPORT DiscreteHessianGaussianImageFunction: 00047 public ImageFunction< TInputImage, 00048 SymmetricSecondRankTensor< TOutput, ::itk::GetImageDimension< TInputImage >::ImageDimension >, 00049 TOutput > 00050 { 00051 public: 00052 00054 typedef DiscreteHessianGaussianImageFunction Self; 00055 00057 typedef ImageFunction< TInputImage, 00058 SymmetricSecondRankTensor< TOutput, ::itk::GetImageDimension< TInputImage >::ImageDimension >, 00059 TOutput > Superclass; 00060 00062 typedef SmartPointer< Self > Pointer; 00063 typedef SmartPointer< const Self > ConstPointer; 00064 00066 itkNewMacro(Self); 00067 00069 itkTypeMacro(DiscreteHessianGaussianImageFunction, ImageFunction); 00070 00072 typedef typename Superclass::InputImageType InputImageType; 00073 typedef typename Superclass::InputPixelType InputPixelType; 00074 typedef typename Superclass::IndexType IndexType; 00075 typedef typename Superclass::IndexValueType IndexValueType; 00076 typedef typename Superclass::ContinuousIndexType ContinuousIndexType; 00077 typedef typename Superclass::PointType PointType; 00078 00080 itkStaticConstMacro(ImageDimension2, unsigned int, 00081 InputImageType::ImageDimension); 00082 00084 typedef SymmetricSecondRankTensor< TOutput, 00085 ::itk::GetImageDimension< TInputImage >::ImageDimension > TensorType; 00086 typedef typename Superclass::OutputType OutputType; 00087 00088 typedef FixedArray< double, itkGetStaticConstMacro(ImageDimension2) > VarianceArrayType; 00089 00090 typedef itk::GaussianDerivativeOperator< TOutput, 00091 itkGetStaticConstMacro(ImageDimension2) > 00092 GaussianDerivativeOperatorType; 00093 00096 typedef FixedArray< GaussianDerivativeOperatorType, 00097 3 *itkGetStaticConstMacro(ImageDimension2) > GaussianDerivativeOperatorArrayType; 00098 00099 typedef Neighborhood< TOutput, itkGetStaticConstMacro(ImageDimension2) > KernelType; 00100 00103 typedef FixedArray< KernelType, itkGetStaticConstMacro(ImageDimension2) 00104 * ( itkGetStaticConstMacro(ImageDimension2) + 1 ) / 2 > KernelArrayType; 00105 00108 typedef NeighborhoodOperatorImageFunction 00109 < InputImageType, TOutput > OperatorImageFunctionType; 00110 typedef typename OperatorImageFunctionType::Pointer OperatorImageFunctionPointer; 00111 00113 enum InterpolationModeType { NearestNeighbourInterpolation, LinearInterpolation }; 00114 public: 00115 00117 virtual OutputType Evaluate(const PointType & point) const; 00118 00120 virtual OutputType EvaluateAtIndex(const IndexType & index) const; 00121 00123 virtual OutputType EvaluateAtContinuousIndex( 00124 const ContinuousIndexType & index) const; 00125 00130 itkSetMacro(Variance, VarianceArrayType); 00131 itkGetConstMacro(Variance, const VarianceArrayType); 00132 itkSetVectorMacro(Variance, double, VarianceArrayType::Length); 00134 00136 virtual void SetVariance(double variance) 00137 { 00138 m_Variance.Fill(variance); 00139 this->Modified(); 00140 } 00142 00145 void SetSigma(const double sigma) 00146 { 00147 SetVariance(sigma * sigma); 00148 } 00149 00155 itkSetClampMacro(MaximumError, double, 0.00001, 0.99999); 00156 itkGetConstMacro(MaximumError, double); 00158 00162 itkSetMacro(NormalizeAcrossScale, bool); 00163 itkGetConstMacro(NormalizeAcrossScale, bool); 00164 itkBooleanMacro(NormalizeAcrossScale); 00166 00168 itkSetMacro(UseImageSpacing, bool); 00169 itkGetConstMacro(UseImageSpacing, bool); 00170 itkBooleanMacro(UseImageSpacing); 00172 00177 itkSetMacro(MaximumKernelWidth, unsigned int); 00178 itkGetConstMacro(MaximumKernelWidth, unsigned int); 00180 00182 itkSetMacro(InterpolationMode, InterpolationModeType); 00183 itkGetConstMacro(InterpolationMode, InterpolationModeType); 00185 00190 virtual void SetInputImage(const InputImageType *ptr); 00191 00194 virtual void Initialize() { RecomputeGaussianKernel(); } 00195 protected: 00196 00197 DiscreteHessianGaussianImageFunction(); 00198 DiscreteHessianGaussianImageFunction(const Self &){} 00199 00200 ~DiscreteHessianGaussianImageFunction(){} 00201 00202 void operator=(const Self &){} 00203 void PrintSelf(std::ostream & os, Indent indent) const; 00204 00205 void RecomputeGaussianKernel(); 00206 00207 private: 00208 00210 VarianceArrayType m_Variance; 00211 00214 double m_MaximumError; 00215 00219 unsigned int m_MaximumKernelWidth; 00220 00225 mutable GaussianDerivativeOperatorArrayType m_OperatorArray; 00226 00230 KernelArrayType m_KernelArray; 00231 00233 OperatorImageFunctionPointer m_OperatorImageFunction; 00234 00236 bool m_NormalizeAcrossScale; 00237 00239 bool m_UseImageSpacing; 00240 00242 InterpolationModeType m_InterpolationMode; 00243 }; 00244 } // namespace itk 00245 00246 #if 0 //HACK: Not yet implemented 00247 // Define instantiation macro for this template. 00248 #define ITK_TEMPLATE_DiscreteHessianGaussianImageFunction(_, EXPORT, TypeX, TypeY) \ 00249 namespace itk \ 00250 { \ 00251 _( 2 ( class EXPORT DiscreteHessianGaussianImageFunction< ITK_TEMPLATE_2 TypeX > ) ) \ 00252 namespace Templates \ 00253 { \ 00254 typedef DiscreteHessianGaussianImageFunction< ITK_TEMPLATE_2 TypeX > \ 00255 DiscreteHessianGaussianImageFunction##TypeY; \ 00256 } \ 00257 } 00258 00259 #if ITK_TEMPLATE_EXPLICIT 00260 #include "Templates/itkDiscreteHessianGaussianImageFunction+-.h" 00261 #endif 00262 #endif 00263 00264 #if ITK_TEMPLATE_TXX 00265 #include "itkDiscreteHessianGaussianImageFunction.hxx" 00266 #endif 00267 00268 #endif 00269