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);
138 port->save(this->getNominalOutputImage(), this->addFullPath(filename));
143 port->save(mTestImage, this->addFullPath(filename));
146 QString SyntheticVolumeComparer::addFullPath(QString filename)
148 QDir dir(QDir::homePath() +
"/test/");
150 QString fullFilename = dir.absoluteFilePath(filename);