18 #ifndef __itkPSMImageDomainWithHessians_h 19 #define __itkPSMImageDomainWithHessians_h 22 #include "itkPSMImageDomainWithGradients.h" 23 #include "itkLinearInterpolateImageFunction.h" 24 #include "itkGradientImageFilter.h" 25 #include "itkFixedArray.h" 26 #include "itkImageDuplicator.h" 27 #include "itkDiscreteGaussianImageFilter.h" 28 #include "itkDerivativeImageFilter.h" 29 #include "vnl/vnl_matrix_fixed.h" 44 template <
class T,
unsigned int VDimension>
52 typedef SmartPointer<Self> Pointer;
53 typedef SmartPointer<const Self> ConstPointer;
54 typedef WeakPointer<const Self> ConstWeakPointer;
59 typedef typename Superclass::ImageType
ImageType;
60 typedef typename Superclass::ScalarInterpolatorType ScalarInterpolatorType;
61 typedef vnl_matrix_fixed<T, VDimension, VDimension> VnlMatrixType;
70 itkStaticConstMacro(Dimension,
unsigned int, VDimension);
76 Superclass::SetImage(I);
78 typename DiscreteGaussianImageFilter<ImageType, ImageType>::Pointer
79 gaussian = DiscreteGaussianImageFilter<ImageType, ImageType>::New();
80 gaussian->SetVariance(m_Sigma * m_Sigma);
81 gaussian->SetInput(this->GetImage());
82 gaussian->SetUseImageSpacingOn();
86 for (
unsigned int i = 0; i < VDimension; i++)
88 typename DerivativeImageFilter<ImageType, ImageType>::Pointer
89 deriv = DerivativeImageFilter<ImageType, ImageType>::New();
90 deriv->SetInput(gaussian->GetOutput());
91 deriv->SetDirection(i);
93 deriv->SetUseImageSpacingOn();
96 m_PartialDerivatives[i] = deriv->GetOutput();
98 m_Interpolators[i] = ScalarInterpolatorType::New();
99 m_Interpolators[i]->SetInputImage(m_PartialDerivatives[i]);
103 unsigned int k = VDimension;
104 for (
unsigned int i = 0; i < VDimension; i++)
106 for (
unsigned int j = i+1; j < VDimension; j++, k++)
108 typename DerivativeImageFilter<ImageType, ImageType>::Pointer
109 deriv1 = DerivativeImageFilter<ImageType, ImageType>::New();
110 deriv1->SetInput(gaussian->GetOutput());
111 deriv1->SetDirection(i);
112 deriv1->SetUseImageSpacingOn();
116 typename DerivativeImageFilter<ImageType, ImageType>::Pointer
117 deriv2 = DerivativeImageFilter<ImageType, ImageType>::New();
118 deriv2->SetInput(deriv1->GetOutput());
119 deriv2->SetDirection(j);
120 deriv2->SetUseImageSpacingOn();
125 m_PartialDerivatives[k] = deriv2->GetOutput();
126 m_Interpolators[k] = ScalarInterpolatorType::New();
127 m_Interpolators[k]->SetInputImage(m_PartialDerivatives[k]);
138 for (
unsigned int i = 0; i < VDimension; i++)
139 { ans[i][i] = m_Interpolators[i]->Evaluate(p); }
142 unsigned int k = VDimension;
143 for (
unsigned int i =0; i < VDimension; i++)
145 for (
unsigned int j = i+1; j < VDimension; j++, k++)
147 ans[i][j] = ans[j][i] = m_Interpolators[k]->Evaluate(p);
157 itkSetMacro(Sigma,
double);
158 itkGetMacro(Sigma,
double);
162 {
return m_Interpolators; }
163 typename ImageType::Pointer *GetPartialDerivatives()
164 {
return m_PartialDerivatives; }
170 void PrintSelf(std::ostream& os, Indent indent)
const 172 Superclass::PrintSelf(os, indent);
176 void DeletePartialDerivativeImages()
178 for (
unsigned int i = 0; i < VDimension + ((VDimension * VDimension) - VDimension) / 2; i++)
180 m_PartialDerivatives[i]=0;
181 m_Interpolators[i]=0;
189 void operator=(
const Self&);
196 typename ImageType::Pointer m_PartialDerivatives[ VDimension + ((VDimension * VDimension) - VDimension) / 2];
198 typename ScalarInterpolatorType::Pointer m_Interpolators[VDimension + ((VDimension * VDimension) - VDimension) / 2];
Image< T, VDimension > ImageType
PSMImageDomainWithHessians Self
VnlMatrixType SampleHessianVnl(const PointType &p) const
void SetImage(ImageType *I)
ScalarInterpolatorType::Pointer * GetInterpolators()
Superclass::PointType PointType