31 #include "DGtal/base/Common.h"
32 #include "DGtal/helpers/StdDefs.h"
33 #include <DGtal/io/readers/GenericReader.h>
34 #include <DGtal/io/writers/GenericWriter.h>
37 #include <DGtal/images/Image.h>
38 #include <DGtal/images/ImageContainerBySTLVector.h>
39 #include <DGtal/images/imagesSetsUtils/SetFromImage.h>
40 #include <DGtal/io/writers/PPMWriter.h>
41 #include <DGtal/math/Statistic.h>
42 #include "DGtal/io/colormaps/GradientColorMap.h"
43 #include <DGtal/math/Statistic.h>
50 using namespace DGtal;
110 for(
auto const &point: imageA.
domain())
112 unsigned int error =
abs((imageA(point)-imageB(point)));
113 stat.addValue(error);
129 it!=imageA.
domain().end(); it++)
131 int error = (imageA(*it)-imageB(*it))*(imageA(*it)-imageB(*it));
132 stat.addValue(error);
144 template<
typename StatisticT>
146 displayStats(
const StatisticT &aStat,
const string &type)
148 std::cout <<
"# Stats on " << type <<
": mean max min unbiased_variance nb_samples " << std::endl;
149 std::cout << aStat.mean() <<
" " << aStat.max() <<
" " << aStat.min() <<
" "
150 <<
" " << aStat.unbiasedVariance() <<
" " << aStat.samples() << std::endl;
154 int main(
int argc,
char** argv )
159 std::string inputFileNameA;
160 std::string inputFileNameB;
161 std::string basenameOutput;
165 app.description(
"Compare images and displays differences (squared and absolute differences).\n Typical use example:\n \t 2dCompImage imageA.pgm imageB.pgm -e errorImage -S 100 \n");
166 app.add_option(
"-a,--imageA,1", inputFileNameA,
"Input filename of image A." )
168 ->check(CLI::ExistingFile);
169 app.add_option(
"-b,--imageB,2", inputFileNameA,
"Input filename of image B." )
171 ->check(CLI::ExistingFile);
174 app.add_option(
"--imageError,-e",basenameOutput,
"Output error image basename (will generate two images <basename>MSE.ppm and <basename>MAE.ppm).");
176 auto setMaxMSEOpt = app.add_option(
"--setMaxColorValueMSE,-S",maxValueMSE,
"Set the maximal color value for the scale display of MSE (else the scale is set the maximal MSE value).");
177 auto setMaxMAEOpt = app.add_option(
"--setMaxColorValueMAE,-A",maxValueMAE,
"Set the maximal color value for the scale display of MAE (else the scale is set from the maximal MAE value).");
180 app.get_formatter()->column_width(40);
181 CLI11_PARSE(app, argc, argv);
194 int maxVal = statMA.
max();
195 if(setMaxMAEOpt->count() > 0)
197 maxVal = maxValueMAE;
200 displayStats(statMA,
"Absolute errror");
201 stringstream maeName; maeName << basenameOutput;
202 maeName <<
"MAE.ppm";
207 maxVal = statMA.
max();
208 if(setMaxMSEOpt->count()>0)
210 maxVal = maxValueMSE;
213 displayStats(statSE,
"Squared error");
214 stringstream mseName; mseName << basenameOutput;
215 mseName <<
"MSE.ppm";
int main(int argc, char **argv)
const Domain & domain() const
void setValue(const Point &aPoint, const Value &aValue)
std::vector< Value >::const_iterator ConstIterator