75 #include <DGtal/base/Common.h>
76 #include <DGtal/io/readers/GenericReader.h>
77 #include <DGtal/io/writers/GenericWriter.h>
78 #include <DGtal/helpers/StdDefs.h>
79 #include <DGtal/images/Image.h>
80 #include <DGtal/images/ImageContainerBySTLVector.h>
81 #include <DGtal/images/imagesSetsUtils/SetFromImage.h>
82 #include <DGtal/math/Statistic.h>
87 using namespace DGtal;
97 sumDiff+=(imageA(*it)-imageB(*it))*(imageA(*it)-imageB(*it));
99 return sqrt(sumDiff/imageA.
domain().size());
103 getPSNR(
const Image3D & imageA,
const Image3D &imageB,
double rmsd){
104 unsigned long long int d = std::numeric_limits<Image3D::Value>::max();
105 return 10.0*log10(d*d/rmsd);
109 int main(
int argc,
char**argv)
114 std::string inputFileNameVolA;
115 std::string inputFileNameVolB;
117 app.description(
"Apply basic image measures (RMSE, PSNR) between two volumetric images A and B. \n Basic usage:\n \t volImageMetrics --volA <volAFilename> --volB <volBFilename> \n Typical use :\n volImageMetrics -a imageA.vol -b imageB.vol \n");
118 app.add_option(
"-a,--volA,1", inputFileNameVolA,
"Input filename of volume A (vol format, and other pgm3d can also be used)." )
120 ->check(CLI::ExistingFile);
121 app.add_option(
"-b,--volB,2", inputFileNameVolB,
"Input filename of volume B (vol format, and other pgm3d can also be used)." )
123 ->check(CLI::ExistingFile);
125 app.get_formatter()->column_width(40);
126 CLI11_PARSE(app, argc, argv);
132 std::cout <<
"# Image based measures (generated with volImageMetrics) given with the image A: "<< inputFileNameVolA<<
" and the image B: "<< inputFileNameVolB << endl;
133 std::cout <<
"# RMSE PSNR "<< endl;
135 double rmse= getRMSE(imageA, imageB);
136 double psnr= getPSNR(imageA, imageB, rmse);
138 std::cout <<
" " << rmse <<
" " << psnr << endl;
int main(int argc, char **argv)
const Domain & domain() const
std::vector< Value >::const_iterator ConstIterator