17 #include <vtkImageData.h> 34 mNominalImage.reset();
40 mNominalImage.reset();
59 cx::ImagePtr SyntheticVolumeComparer::getNominalOutputImage()
const 65 Eigen::Array3i dim(mTestImage->getBaseVtkImageData()->GetDimensions());
66 cx::Vector3D spacing(mTestImage->getBaseVtkImageData()->GetSpacing());
68 mNominalImage->get_rMd_History()->setRegistration(mTestImage->get_rMd());
70 mPhantom->fillVolume(mNominalImage);
78 float sse = this->getRMS();
80 std::cout <<
"RMS value: " << sse << std::endl;
81 CHECK(sse < threshold);
84 double SyntheticVolumeComparer::getRMS()
const 86 double sse =
cx::calculateRMSError(mTestImage->getBaseVtkImageData(), this->getNominalOutputImage()->getBaseVtkImageData());
97 double difference = (c_n-c_r).norm();
100 std::cout <<
"c_n=[" << c_n <<
"] c_r=[" << c_r <<
"] diff=[" << difference <<
"]" << std::endl;
102 CHECK(difference < val);
109 double normalized_difference = fabs(v_n-v_r)/(v_n+v_r);
112 std::cout <<
"v_n=[" << v_n <<
"] v_r=[" << v_r <<
"] diff=[" << normalized_difference <<
"]" << std::endl;
114 CHECK(normalized_difference<val);
119 int val = this->getValue(mTestImage, p_r);
121 std::cout << QString(
"p_r[%1]=%2, limit=[%3, %4]").arg(
qstring_cast(p_r)).arg(val).arg(lowerLimit).arg(upperLimit) << std::endl;
122 CHECK(val>=lowerLimit);
123 CHECK(val<=upperLimit);
130 Eigen::Array3d spacing(raw->GetSpacing());
131 Eigen::Array3i voxel =
cx::round(p_r.array() / spacing).cast<int>();
132 double val = raw->GetScalarComponentAsDouble(voxel.data()[0],voxel.data()[1],voxel.data()[2], 0);
146 QString SyntheticVolumeComparer::addFullPath(QString filename)
148 QDir dir(QDir::homePath() +
"/test/");
150 QString fullFilename = dir.absoluteFilePath(filename);
QString qstring_cast(const T &val)
double calculateMass(cx::ImagePtr image)
boost::shared_ptr< class Image > ImagePtr
void setTestImage(cx::ImagePtr image)
static cx::ImagePtr create3DImage(Eigen::Array3i dim=Eigen::Array3i(3, 3, 3), const unsigned int voxelValue=100)
void checkCentroidDifferenceBelow(double val)
void checkValueWithin(cx::Vector3D p_r, int lowerLimit, int upperLimit)
boost::shared_ptr< cxSyntheticVolume > cxSyntheticVolumePtr
cx::Vector3D calculateCentroid(cx::ImagePtr image)
void setPhantom(cx::cxSyntheticVolumePtr phantom)
void checkRMSBelow(double threshold)
double calculateRMSError(vtkImageDataPtr a, vtkImageDataPtr b)
Eigen::Vector3d Vector3D
Vector3D is a representation of a point or vector in 3D.
void checkMassDifferenceBelow(double val)
void saveOutputToFile(QString filename)
void saveNominalOutputToFile(QString filename)
SyntheticVolumeComparer()
Vector3D round(const Vector3D &a)