38 #include <vtkImageData.h>
55 mNominalImage.reset();
61 mNominalImage.reset();
80 cx::ImagePtr SyntheticVolumeComparer::getNominalOutputImage()
const
86 Eigen::Array3i dim(mTestImage->getBaseVtkImageData()->GetDimensions());
87 cx::Vector3D spacing(mTestImage->getBaseVtkImageData()->GetSpacing());
89 mNominalImage->get_rMd_History()->setRegistration(mTestImage->get_rMd());
91 mPhantom->fillVolume(mNominalImage);
99 float sse = this->getRMS();
101 std::cout <<
"RMS value: " << sse << std::endl;
102 CHECK(sse < threshold);
105 double SyntheticVolumeComparer::getRMS()
const
107 double sse =
cx::calculateRMSError(mTestImage->getBaseVtkImageData(), this->getNominalOutputImage()->getBaseVtkImageData());
118 double difference = (c_n-c_r).norm();
121 std::cout <<
"c_n=[" << c_n <<
"] c_r=[" << c_r <<
"] diff=[" << difference <<
"]" << std::endl;
123 CHECK(difference < val);
130 double normalized_difference = fabs(v_n-v_r)/(v_n+v_r);
133 std::cout <<
"v_n=[" << v_n <<
"] v_r=[" << v_r <<
"] diff=[" << normalized_difference <<
"]" << std::endl;
135 CHECK(normalized_difference<val);
140 int val = this->getValue(mTestImage, p_r);
142 std::cout << QString(
"p_r[%1]=%2, limit=[%3, %4]").arg(
qstring_cast(p_r)).arg(val).arg(lowerLimit).arg(upperLimit) << std::endl;
143 CHECK(val>=lowerLimit);
144 CHECK(val<=upperLimit);
151 Eigen::Array3d spacing(raw->GetSpacing());
152 Eigen::Array3i voxel =
cx::round(p_r.array() / spacing).cast<int>();
153 double val = raw->GetScalarComponentAsDouble(voxel.data()[0],voxel.data()[1],voxel.data()[2], 0);
167 QString SyntheticVolumeComparer::addFullPath(QString filename)
169 QDir dir(QDir::homePath() +
"/test/");
171 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)