20 #include "itkImageFileReader.h" 21 #include "itkPSMMeanCurvatureAttribute.h" 22 #include "itkPSMSurfaceNeighborhood.h" 26 int itkPSMMeanCurvatureAttributeTest(
int argc,
char* argv[] )
29 std::string errstring =
"";
34 std::cout <<
"Wrong number of arguments. You need one image file." << std::endl;
40 typedef itk::Point<double, 3> PointType;
41 typedef itk::Image<float, 3> ImageType;
43 itk::PSMMeanCurvatureAttribute<float, 3>::Pointer P
47 itk::ImageFileReader<ImageType>::Pointer reader
48 = itk::ImageFileReader<ImageType>::New();
49 reader->SetFileName(argv[1]);
50 reader->UpdateLargestPossibleRegion();
52 itk::PSMSurfaceNeighborhood<ImageType>::Pointer sn
56 itk::PSMImageDomainWithCurvature<float, 3>::Pointer domain
58 domain->
SetImage(reader->GetOutput());
62 PointType ptu = domain->GetUpperBound();
64 itk::PSMParticleSystem<3>::Pointer ps =
71 unsigned int SZ = 100;
73 double range[3] = { ptu[0]-ptl[0], ptu[1]-ptl[1], ptu[2]-ptl[2] };
74 for (
unsigned int i = 0; i < SZ; i++)
76 pt[0] =
static_cast<double>(i)/static_cast<double>(SZ)*range[0]+ptl[0]+0.1;
77 pt[1] =
static_cast<double>(i)/static_cast<double>(SZ)*range[1]+ptl[1]+0.1;
78 pt[2] =
static_cast<double>(i)/static_cast<double>(SZ)*range[2]+ptl[2]+0.1;
84 if (P->GetMeanCurvature(0) == 0.0f)
87 errstring += std::string(
"GetMeanCurvature method failed. ");
89 if (P->GetCurvatureStandardDeviation(0) == 0.0f)
92 errstring += std::string(
"GetCurvatureStandardDeviation method failed. ");
95 catch(itk::ExceptionObject &e)
97 errstring =
"ITK exception with description: " + std::string(e.GetDescription())
98 + std::string(
"\n at location:") + std::string(e.GetLocation())
99 + std::string(
"\n in file:") + std::string(e.GetFile());
104 errstring =
"Unknown exception thrown";
110 std::cout <<
"All tests passed" << std::endl;
115 std::cout <<
"Test failed with the following error:" << std::endl;
116 std::cout << errstring << std::endl;
PSMSurfaceNeighborhood is a general purpose neighborhood object that computes neighborhoods based on ...
virtual void ComputeCurvatureStatistics(const ParticleSystemType *, unsigned int d)
void AddDomain(DomainType *, int threadId=0)
void SetNeighborhood(unsigned int, NeighborhoodType *, int threadId=0)
void RegisterAttribute(PSMAttribute< VDimension > *)
const PointType & AddPosition(const PointType &, unsigned int d=0, int threadId=0)
virtual const PointType & GetLowerBound() const
A facade class that manages interactions with a particle system.
void SetImage(ImageType *I)