18 #ifndef __itkPSMMeanCurvatureAttribute_hxx 19 #define __itkPSMMeanCurvatureAttribute_hxx 20 #include "itkPSMMeanCurvatureAttribute.h" 22 #include "itkZeroCrossingImageFilter.h" 23 #include "itkImageRegionConstIteratorWithIndex.h" 28 template <
class TNumericType,
unsigned int VDimension>
34 typedef typename DomainType::ImageType ImageType;
38 typedef itk::ZeroCrossingImageFilter<ImageType, ImageType> ZeroCrossingImageFilterType;
39 typename ZeroCrossingImageFilterType::Pointer zc = ZeroCrossingImageFilterType::New() ;
40 zc->SetInput( dynamic_cast<const DomainType *>(system->
GetDomain(d))->GetImage() );
43 itk::ImageRegionConstIteratorWithIndex<ImageType> it(zc->GetOutput(),
44 zc->GetOutput()->GetRequestedRegion());
45 std::vector<double> datalist;
46 m_MeanCurvatureList[d] = 0.0;
47 m_CurvatureStandardDeviationList[d] = 0.0;
48 const DomainType *domain =
static_cast<const DomainType *
>(system->
GetDomain(d));
50 for (; ! it.IsAtEnd(); ++it)
56 domain->GetImage()->TransformIndexToPhysicalPoint(it.GetIndex(), pos);
62 domain->ApplyConstraints(pos);
66 double mc = domain->GetCurvature(pos);
67 m_MeanCurvatureList[d] += mc;
68 datalist.push_back(mc);
71 double n =
static_cast<double>(datalist.size());
72 m_MeanCurvatureList[d] /= n;
75 for (
unsigned int i = 0; i < datalist.size(); i++)
77 m_CurvatureStandardDeviationList[d] += (datalist[i] - m_MeanCurvatureList[d]) * (datalist[i] - m_MeanCurvatureList[d]);
79 m_CurvatureStandardDeviationList[d] = sqrt(m_CurvatureStandardDeviationList[d] / (n-1));
virtual void ComputeCurvatureStatistics(const ParticleSystemType *, unsigned int d)
A facade class that manages interactions with a particle system.
DomainType * GetDomain(unsigned int i)