40 #include <visp3/core/vpImage.h>
42 void printHelp(
const std::string &progName)
44 std::cout <<
"SYNOPSIS: " << std::endl;
45 std::cout <<
" " << progName <<
" [-v, --verbose] [-h, --help]" << std::endl;
46 std::cout <<
"DETAILS:" << std::endl;
47 std::cout <<
" -v, --verbose" << std::endl;
48 std::cout <<
" Activate verbose mode to have some logs in the console." << std::endl;
49 std::cout << std::endl;
50 std::cout <<
" -h, --help" << std::endl;
51 std::cout <<
" Display the help about the program." << std::endl;
52 std::cout << std::endl;
55 int main(
const int argc,
const char *argv[])
57 #ifdef ENABLE_VISP_NAMESPACE
60 bool opt_verbose =
false;
61 for (
int i = 1; i < argc; ++i) {
62 std::string argName(argv[i]);
63 if ((argName ==
"-v") || (argName ==
"--verbose")) {
66 else if ((argName ==
"-h") || (argName ==
"--help")) {
67 printHelp(std::string(argv[0]));
72 const unsigned int nbRows = 4, nbCols = 4;
76 double sum_uchar_ref = 0.;
77 double sum_rgba_ref = 0.;
78 double sum_rgbf_ref = 0.;
79 unsigned int count_ref = 0;
81 for (
unsigned int r = 0; r < nbRows; ++r) {
82 for (
unsigned int c = 0; c < nbCols; ++c) {
83 unsigned int val = r * nbCols + c;
84 I_uchar_ref[r][c] = val;
85 I_rgba_ref[r][c].R = val;
86 I_rgba_ref[r][c].G = 2*val;
87 I_rgba_ref[r][c].B = 3*val;
88 I_rgbf_ref[r][c].R = I_rgba_ref[r][c].R;
89 I_rgbf_ref[r][c].G = I_rgba_ref[r][c].G;
90 I_rgbf_ref[r][c].B = I_rgba_ref[r][c].B;
91 sum_uchar_ref +=
static_cast<double>(val);
92 double val_rgb =
static_cast<double>(I_rgba_ref[r][c].R) +
static_cast<double>(I_rgba_ref[r][c].G) +
static_cast<double>(I_rgba_ref[r][c].B);
93 sum_rgba_ref += val_rgb;
94 sum_rgbf_ref += val_rgb;
100 double mean_uchar_ref = sum_uchar_ref /
static_cast<double>(count_ref);
101 double mean_rgba_ref = sum_rgba_ref /
static_cast<double>(count_ref);
102 double mean_rgbf_ref = sum_rgbf_ref /
static_cast<double>(count_ref);
105 double stdev_uchar_ref = 0.;
106 double stdev_rgba_ref = 0.;
107 double stdev_rgbf_ref = 0.;
108 for (
unsigned int r = 0; r < nbRows; ++r) {
109 for (
unsigned int c = 0; c < nbCols; ++c) {
110 stdev_uchar_ref += std::pow(
static_cast<double>(I_uchar_ref[r][c]) - mean_uchar_ref, 2);
111 stdev_rgba_ref += std::pow(
static_cast<double>(I_rgba_ref[r][c].R) +
static_cast<double>(I_rgba_ref[r][c].G) +
static_cast<double>(I_rgba_ref[r][c].B) - mean_rgba_ref, 2);
112 stdev_rgbf_ref += std::pow(
static_cast<double>(I_rgbf_ref[r][c].R) +
static_cast<double>(I_rgbf_ref[r][c].G) +
static_cast<double>(I_rgbf_ref[r][c].B) - mean_rgbf_ref, 2);
115 stdev_uchar_ref = std::sqrt((1./
static_cast<double>(nbRows * nbCols))* stdev_uchar_ref);
116 stdev_rgba_ref = std::sqrt((1./
static_cast<double>(nbRows * nbCols))* stdev_rgba_ref);
117 stdev_rgbf_ref = std::sqrt((1./
static_cast<double>(nbRows * nbCols))* stdev_rgbf_ref);
119 std::cout <<
"----- Input data-----" << std::endl;
120 std::cout <<
"I_uchar_ref = \n" << I_uchar_ref << std::endl;
121 std::cout <<
"sum_uchar_ref(I_uchar_ref) = " << sum_uchar_ref << std::endl;
122 std::cout <<
"mean_uchar_ref(I_uchar_ref) = " << mean_uchar_ref << std::endl;
123 std::cout <<
"stdev_uchar_ref(I_uchar_ref) = " << stdev_uchar_ref << std::endl;
124 std::cout << std::endl;
125 std::cout <<
"I_rgba_ref = \n" << I_rgba_ref << std::endl;
126 std::cout <<
"sum_rgba_ref(I_uchar_ref) = " << sum_rgba_ref << std::endl;
127 std::cout <<
"mean_rgba_ref(I_rgba_ref) = " << mean_rgba_ref << std::endl;
128 std::cout <<
"stdev_rgba_ref(I_rgba_ref) = " << stdev_rgba_ref << std::endl;
129 std::cout << std::endl;
130 std::cout <<
"I_rgbf_ref = \n" << I_rgbf_ref << std::endl;
131 std::cout <<
"sum_rgbf_ref(I_rgbf_ref) = " << sum_rgbf_ref << std::endl;
132 std::cout <<
"mean_rgbf_ref(I_rgbf_ref) = " << mean_rgbf_ref << std::endl;
133 std::cout <<
"stdev_rgbf_ref(I_rgbf_ref) = " << stdev_rgbf_ref << std::endl;
134 std::cout << std::endl;
138 unsigned int count_true = 0;
139 double sum_uchar_true = 0.;
140 double sum_rgba_true = 0.;
141 double sum_rgbf_true = 0.;
142 for (
unsigned int r = 0; r < nbRows; ++r) {
143 for (
unsigned int c = 0; c < nbCols; ++c) {
144 bool isTrue = ((r + c) % 2) == 0;
145 I_mask[r][c] = isTrue;
148 sum_uchar_true +=
static_cast<double>(I_uchar_ref[r][c]);
149 double val_rgba =
static_cast<double>(I_rgba_ref[r][c].R) +
static_cast<double>(I_rgba_ref[r][c].G) +
static_cast<double>(I_rgba_ref[r][c].B);
150 sum_rgba_true += val_rgba;
151 double val_rgbf =
static_cast<double>(I_rgbf_ref[r][c].R) +
static_cast<double>(I_rgbf_ref[r][c].G) +
static_cast<double>(I_rgbf_ref[r][c].B);
152 sum_rgbf_true += val_rgbf;
157 double mean_uchar_true = sum_uchar_true /
static_cast<double>(count_true);
158 double mean_rgba_true = sum_rgba_true /
static_cast<double>(count_true);
159 double mean_rgbf_true = sum_rgbf_true /
static_cast<double>(count_true);
161 double stdev_uchar_true = 0.;
162 double stdev_rgba_true = 0.;
163 double stdev_rgbf_true = 0.;
164 for (
unsigned int r = 0; r < nbRows; ++r) {
165 for (
unsigned int c = 0; c < nbCols; ++c) {
167 stdev_uchar_true += (
static_cast<double>(I_uchar_ref[r][c]) - mean_uchar_true) * (
static_cast<double>(I_uchar_ref[r][c]) - mean_uchar_true);
168 double val_rgba =
static_cast<double>(I_rgba_ref[r][c].R) +
static_cast<double>(I_rgba_ref[r][c].G) +
static_cast<double>(I_rgba_ref[r][c].B);
169 stdev_rgba_true += (val_rgba - mean_rgba_true) * (val_rgba - mean_rgba_true);
170 double val_rgbf =
static_cast<double>(I_rgbf_ref[r][c].R) +
static_cast<double>(I_rgbf_ref[r][c].G) +
static_cast<double>(I_rgbf_ref[r][c].B);
171 stdev_rgbf_true += (val_rgbf - mean_rgbf_true) * (val_rgbf - mean_rgbf_true);
175 stdev_uchar_true = std::sqrt((1./
static_cast<double>(count_true)) * stdev_uchar_true);
176 stdev_rgba_true = std::sqrt((1./
static_cast<double>(count_true)) * stdev_rgba_true);
177 stdev_rgbf_true = std::sqrt((1./
static_cast<double>(count_true)) * stdev_rgbf_true);
179 std::cout <<
"I_mask = \n";
180 for (
unsigned int r = 0; r < nbRows; ++r) {
181 for (
unsigned int c = 0; c < nbCols; ++c) {
182 std::cout << (I_mask[r][c] ?
"true" :
"false") <<
" ";
186 std::cout << std::endl;
187 std::cout <<
"nb_true(I_uchar_ref, I_mask) = " << count_true << std::endl;
188 std::cout <<
"sum_uchar_true(I_uchar_ref, I_mask) = " << sum_uchar_true << std::endl;
189 std::cout <<
"mean_uchar_true(I_uchar_ref, I_mask) = " << mean_uchar_true << std::endl;
190 std::cout <<
"stdev_uchar_true(I_uchar_ref, I_mask) = " << stdev_uchar_true << std::endl;
191 std::cout <<
"sum_rgba_true(I_rgba_ref, I_mask) = " << sum_rgba_true << std::endl;
192 std::cout <<
"mean_rgba_true(I_rgba_ref, I_mask) = " << mean_rgba_true << std::endl;
193 std::cout <<
"stdev_rgba_true(I_rgba_ref, I_mask) = " << stdev_rgba_true << std::endl;
194 std::cout <<
"sum_rgbf_true(I_rgbf_ref, I_mask) = " << sum_rgbf_true << std::endl;
195 std::cout <<
"mean_rgbf_true(I_rgbf_ref, I_mask) = " << mean_rgbf_true << std::endl;
196 std::cout <<
"stdev_rgbf_true(I_rgbf_ref, I_mask) = " << stdev_rgbf_true << std::endl;
197 std::cout << std::endl;
200 bool areTestOK =
true;
201 unsigned int nbFailedTests = 0;
202 std::vector<std::string> failedTestsNames;
204 std::cout <<
"----- BEGIN tests-----" << std::endl;
210 std::cout <<
"Tests on the sum" << std::endl;
212 std::string nameTest(
"vpImage<uchar>::getSum()");
213 double sum = I_uchar_ref.getSum();
217 failedTestsNames.push_back(nameTest);
221 std::cout <<
"\tTest " << nameTest <<
": " << (success ?
"OK" :
"failure") << std::endl;
223 std::cout <<
"Theoretical sum = " << sum_uchar_ref <<
" | returned value = " << sum << std::endl;
227 unsigned int nbValidPoints = 0;
228 nameTest = (
"vpImage<uchar>::getSum( const vpImage<bool> *, unsigned int * )");
229 sum = I_uchar_ref.getSum(&I_mask, &nbValidPoints);
230 success =
vpMath::equal(sum, sum_uchar_true) && (nbValidPoints == count_true);
233 failedTestsNames.push_back(nameTest);
237 std::cout <<
"\tTest " << nameTest <<
": " << (success ?
"OK" :
"failure") << std::endl;
239 std::cout <<
"Theoretical count = " << count_true <<
" | returned value = " << nbValidPoints << std::endl;
240 std::cout <<
"Theoretical sum = " << sum_uchar_true <<
" | returned value = " << sum << std::endl;
244 nameTest = (
"vpImage<uchar>::getSum( vpImage<bool> * = nullptr, unsigned int * )");
245 sum = I_uchar_ref.getSum(
nullptr, &nbValidPoints);
246 success =
vpMath::equal(sum, sum_uchar_ref) && (nbValidPoints == (nbCols * nbRows));
249 failedTestsNames.push_back(nameTest);
253 std::cout <<
"\tTest " << nameTest <<
": " << (success ?
"OK" :
"failure") << std::endl;
255 std::cout <<
"Theoretical count = " << nbCols * nbRows <<
" | returned value = " << nbValidPoints << std::endl;
256 std::cout <<
"Theoretical sum = " << sum_uchar_ref <<
" | returned value = " << sum << std::endl;
260 nameTest = (
"vpImage<vpRGBa>::getSum()");
261 sum = I_rgba_ref.getSum();
265 failedTestsNames.push_back(nameTest);
269 std::cout <<
"\tTest " << nameTest <<
": " << (success ?
"OK" :
"failure") << std::endl;
271 std::cout <<
"Theoretical sum = " << sum_rgba_ref <<
" | returned value = " << sum << std::endl;
275 nameTest = (
"vpImage<vpRGBa>::getSum( vpImage<bool> *, unsigned int * )");
276 sum = I_rgba_ref.getSum(&I_mask, &nbValidPoints);
277 success =
vpMath::equal(sum, sum_rgba_true) && (nbValidPoints == count_true);
280 failedTestsNames.push_back(nameTest);
284 std::cout <<
"\tTest " << nameTest <<
": " << (success ?
"OK" :
"failure") << std::endl;
286 std::cout <<
"Theoretical count = " << count_true <<
" | returned value = " << nbValidPoints << std::endl;
287 std::cout <<
"Theoretical sum = " << sum_rgba_true <<
" | returned value = " << sum << std::endl;
291 nameTest = (
"vpImage<vpRGBa>::getSum( vpImage<bool> * = nullptr, unsigned int * )");
292 sum = I_rgba_ref.getSum(
nullptr, &nbValidPoints);
293 success =
vpMath::equal(sum, sum_rgba_ref) && (nbValidPoints == (nbCols * nbRows));
296 failedTestsNames.push_back(nameTest);
300 std::cout <<
"\tTest " << nameTest <<
": " << (success ?
"OK" :
"failure") << std::endl;
302 std::cout <<
"Theoretical count = " << nbCols * nbRows <<
" | returned value = " << nbValidPoints << std::endl;
303 std::cout <<
"Theoretical sum = " << sum_rgba_ref <<
" | returned value = " << sum << std::endl;
307 nameTest = (
"vpImage<vpRGBf>::getSum()");
308 sum = I_rgbf_ref.getSum();
312 failedTestsNames.push_back(nameTest);
316 std::cout <<
"\tTest " << nameTest <<
": " << (success ?
"OK" :
"failure") << std::endl;
318 std::cout <<
"Theoretical sum = " << sum_rgbf_ref <<
" | returned value = " << sum << std::endl;
322 nameTest = (
"vpImage<vpRGBf>::getSum( vpImage<bool> *, unsigned int * )");
323 sum = I_rgbf_ref.getSum(&I_mask, &nbValidPoints);
324 success =
vpMath::equal(sum, sum_rgbf_true) && (nbValidPoints == count_true);
327 failedTestsNames.push_back(nameTest);
331 std::cout <<
"\tTest " << nameTest <<
": " << (success ?
"OK" :
"failure") << std::endl;
333 std::cout <<
"Theoretical count = " << count_true <<
" | returned value = " << nbValidPoints << std::endl;
334 std::cout <<
"Theoretical sum = " << sum_rgbf_true <<
" | returned value = " << sum << std::endl;
338 nameTest = (
"vpImage<vpRGBf>::getSum( vpImage<bool> * = nullptr, unsigned int * )");
339 sum = I_rgbf_ref.getSum(
nullptr, &nbValidPoints);
340 success =
vpMath::equal(sum, sum_rgbf_ref) && (nbValidPoints == (nbCols * nbRows));
343 failedTestsNames.push_back(nameTest);
347 std::cout <<
"\tTest " << nameTest <<
": " << (success ?
"OK" :
"failure") << std::endl;
349 std::cout <<
"Theoretical count = " << nbCols * nbRows <<
" | returned value = " << nbValidPoints << std::endl;
350 std::cout <<
"Theoretical sum = " << sum_rgbf_ref <<
" | returned value = " << sum << std::endl;
358 std::cout <<
"Tests on the mean" << std::endl;
360 std::string nameTest(
"vpImage<uchar>::getMeanValue()");
361 double mean = I_uchar_ref.getMeanValue();
365 failedTestsNames.push_back(nameTest);
369 std::cout <<
"\tTest " << nameTest <<
": " << (success ?
"OK" :
"failure") << std::endl;
371 std::cout <<
"Theoretical mean = " << mean_uchar_ref <<
" | returned value = " << mean << std::endl;
375 nameTest =
"vpImage<uchar>::getMeanValue(vpImage<bool> *)";
376 mean = I_uchar_ref.getMeanValue(&I_mask);
380 failedTestsNames.push_back(nameTest);
384 std::cout <<
"\tTest " << nameTest <<
": " << (success ?
"OK" :
"failure") << std::endl;
386 std::cout <<
"Theoretical mean = " << mean_uchar_true <<
" | returned value = " << mean << std::endl;
390 nameTest =
"vpImage<uchar>::getMeanValue(vpImage<bool> * = nullptr)";
391 mean = I_uchar_ref.getMeanValue(
nullptr);
395 failedTestsNames.push_back(nameTest);
399 std::cout <<
"\tTest " << nameTest <<
": " << (success ?
"OK" :
"failure") << std::endl;
401 std::cout <<
"Theoretical mean = " << mean_uchar_ref <<
" | returned value = " << mean << std::endl;
405 unsigned int nbValidPoints = 0;
406 nameTest =
"vpImage<uchar>::getMeanValue(vpImage<bool> *, unsigned int &)";
407 mean = I_uchar_ref.getMeanValue(&I_mask, &nbValidPoints);
408 success =
vpMath::equal(mean, mean_uchar_true) && (nbValidPoints == count_true);
411 failedTestsNames.push_back(nameTest);
415 std::cout <<
"\tTest " << nameTest <<
": " << (success ?
"OK" :
"failure") << std::endl;
417 std::cout <<
"Theoretical count = " << count_true <<
" | returned value = " << nbValidPoints << std::endl;
418 std::cout <<
"Theoretical mean = " << mean_uchar_true <<
" | returned value = " << mean << std::endl;
423 nameTest =
"vpImage<uchar>::getMeanValue(vpImage<bool> * = nullptr, unsigned int &)";
424 mean = I_uchar_ref.getMeanValue(
nullptr, &nbValidPoints);
425 success =
vpMath::equal(mean, mean_uchar_ref) && (nbValidPoints == (nbCols * nbRows));
428 failedTestsNames.push_back(nameTest);
432 std::cout <<
"\tTest " << nameTest <<
": " << (success ?
"OK" :
"failure") << std::endl;
434 std::cout <<
"Theoretical count = " << nbCols * nbRows <<
" | returned value = " << nbValidPoints << std::endl;
435 std::cout <<
"Theoretical mean = " << mean_uchar_ref <<
" | returned value = " << mean << std::endl;
439 nameTest =
"vpImage<vpRGBa>::getMeanValue()";
440 mean = I_rgba_ref.getMeanValue();
444 failedTestsNames.push_back(nameTest);
448 std::cout <<
"\tTest " << nameTest <<
": " << (success ?
"OK" :
"failure") << std::endl;
450 std::cout <<
"Theoretical mean = " << mean_rgba_ref <<
" | returned value = " << mean << std::endl;
454 nameTest =
"vpImage<vpRGBa>::getMeanValue(vpImage<bool> *)";
455 mean = I_rgba_ref.getMeanValue(&I_mask);
459 failedTestsNames.push_back(nameTest);
463 std::cout <<
"\tTest " << nameTest <<
": " << (success ?
"OK" :
"failure") << std::endl;
465 std::cout <<
"Theoretical mean = " << mean_rgba_true <<
" | returned value = " << mean << std::endl;
469 nameTest =
"vpImage<vpRGBa>::getMeanValue(vpImage<bool> * = nullptr)";
470 mean = I_rgba_ref.getMeanValue(
nullptr);
474 failedTestsNames.push_back(nameTest);
478 std::cout <<
"\tTest " << nameTest <<
": " << (success ?
"OK" :
"failure") << std::endl;
480 std::cout <<
"Theoretical mean = " << mean_rgba_ref <<
" | returned value = " << mean << std::endl;
485 nameTest =
"vpImage<vpRGBa>::getMeanValue(vpImage<bool> *, unsigned int &)";
486 mean = I_rgba_ref.getMeanValue(&I_mask, &nbValidPoints);
487 success =
vpMath::equal(mean, mean_rgba_true) && (nbValidPoints == count_true);
490 failedTestsNames.push_back(nameTest);
494 std::cout <<
"\tTest " << nameTest <<
": " << (success ?
"OK" :
"failure") << std::endl;
496 std::cout <<
"Theoretical count = " << count_true <<
" | returned value = " << nbValidPoints << std::endl;
497 std::cout <<
"Theoretical mean = " << mean_rgba_true <<
" | returned value = " << mean << std::endl;
502 nameTest =
"vpImage<vpRGBa>::getMeanValue(vpImage<bool> * = nullptr, unsigned int &)";
503 mean = I_rgba_ref.getMeanValue(
nullptr, &nbValidPoints);
504 success =
vpMath::equal(mean, mean_rgba_ref) && (nbValidPoints == (nbRows * nbCols));
507 failedTestsNames.push_back(nameTest);
511 std::cout <<
"\tTest " << nameTest <<
": " << (success ?
"OK" :
"failure") << std::endl;
513 std::cout <<
"Theoretical count = " << nbRows * nbCols <<
" | returned value = " << nbValidPoints << std::endl;
514 std::cout <<
"Theoretical mean = " << mean_rgba_ref <<
" | returned value = " << mean << std::endl;
518 nameTest =
"vpImage<vpRGBf>::getMeanValue()";
519 mean = I_rgbf_ref.getMeanValue();
523 failedTestsNames.push_back(nameTest);
527 std::cout <<
"\tTest " << nameTest <<
": " << (success ?
"OK" :
"failure") << std::endl;
529 std::cout <<
"Theoretical mean = " << mean_rgbf_ref <<
" | returned value = " << mean << std::endl;
533 nameTest =
"vpImage<vpRGBf>::getMeanValue(vpImage<bool> *)";
534 mean = I_rgbf_ref.getMeanValue(&I_mask);
538 failedTestsNames.push_back(nameTest);
542 std::cout <<
"\tTest " << nameTest <<
": " << (success ?
"OK" :
"failure") << std::endl;
544 std::cout <<
"Theoretical mean = " << mean_rgbf_true <<
" | returned value = " << mean << std::endl;
548 nameTest =
"vpImage<vpRGBf>::getMeanValue(vpImage<bool> * = nullptr)";
549 mean = I_rgbf_ref.getMeanValue(
nullptr);
553 failedTestsNames.push_back(nameTest);
557 std::cout <<
"\tTest " << nameTest <<
": " << (success ?
"OK" :
"failure") << std::endl;
559 std::cout <<
"Theoretical mean = " << mean_rgbf_ref <<
" | returned value = " << mean << std::endl;
564 nameTest =
"vpImage<vpRGBf>::getMeanValue(vpImage<bool> *, unsigned int &)";
565 mean = I_rgbf_ref.getMeanValue(&I_mask, &nbValidPoints);
566 success =
vpMath::equal(mean, mean_rgbf_true) && (nbValidPoints == count_true);
569 failedTestsNames.push_back(nameTest);
573 std::cout <<
"\tTest " << nameTest <<
": " << (success ?
"OK" :
"failure") << std::endl;
575 std::cout <<
"Theoretical count = " << count_true <<
" | returned value = " << nbValidPoints << std::endl;
576 std::cout <<
"Theoretical mean = " << mean_rgbf_true <<
" | returned value = " << mean << std::endl;
581 nameTest =
"vpImage<vpRGBf>::getMeanValue(vpImage<bool> * = nullptr, unsigned int &)";
582 mean = I_rgbf_ref.getMeanValue(
nullptr, &nbValidPoints);
583 success =
vpMath::equal(mean, mean_rgbf_ref) && (nbValidPoints == (nbRows * nbCols));
586 failedTestsNames.push_back(nameTest);
590 std::cout <<
"\tTest " << nameTest <<
": " << (success ?
"OK" :
"failure") << std::endl;
592 std::cout <<
"Theoretical count = " << nbRows * nbCols <<
" | returned value = " << nbValidPoints << std::endl;
593 std::cout <<
"Theoretical mean = " << mean_rgbf_ref <<
" | returned value = " << mean << std::endl;
601 std::cout <<
"Tests on the stdev" << std::endl;
603 std::string nameTest(
"vpImage<uchar>::getStdev()");
604 double stdev = I_uchar_ref.getStdev();
608 failedTestsNames.push_back(nameTest);
612 std::cout <<
"\tTest " << nameTest <<
": " << (success ?
"OK" :
"failure") << std::endl;
614 std::cout <<
"Theoretical stdev = " << stdev_uchar_ref <<
" | returned value = " << stdev << std::endl;
618 nameTest = (
"vpImage<uchar>::getStdev(const vpImage<bool> *)");
619 stdev = I_uchar_ref.getStdev(&I_mask);
623 failedTestsNames.push_back(nameTest);
627 std::cout <<
"\tTest " << nameTest <<
": " << (success ?
"OK" :
"failure") << std::endl;
629 std::cout <<
"Theoretical stdev = " << stdev_uchar_true <<
" | returned value = " << stdev << std::endl;
633 nameTest = (
"vpImage<uchar>::getStdev(const vpImage<bool> * = nullptr)");
634 stdev = I_uchar_ref.getStdev(
nullptr);
638 failedTestsNames.push_back(nameTest);
642 std::cout <<
"\tTest " << nameTest <<
": " << (success ?
"OK" :
"failure") << std::endl;
644 std::cout <<
"Theoretical stdev = " << stdev_uchar_ref <<
" | returned value = " << stdev << std::endl;
648 nameTest = (
"vpImage<uchar>::getStdev(const double &)");
649 double mean = I_uchar_ref.getMeanValue();
650 stdev = I_uchar_ref.getStdev(mean);
654 failedTestsNames.push_back(nameTest);
658 std::cout <<
"\tTest " << nameTest <<
": " << (success ?
"OK" :
"failure") << std::endl;
660 std::cout <<
"Theoretical stdev = " << stdev_uchar_ref <<
" | returned value = " << stdev << std::endl;
664 nameTest = (
"vpImage<uchar>::getStdev(const double &, vpImage<bool> *, unsigned int *)");
665 unsigned int nbValidPoints = 0;
666 mean = I_uchar_ref.getMeanValue(&I_mask, &nbValidPoints);
667 stdev = I_uchar_ref.getStdev(mean, &I_mask, &nbValidPoints);
671 failedTestsNames.push_back(nameTest);
675 std::cout <<
"\tTest " << nameTest <<
": " << (success ?
"OK" :
"failure") << std::endl;
677 std::cout <<
"Theoretical stdev = " << stdev_uchar_true <<
" | returned value = " << stdev << std::endl;
681 nameTest = (
"vpImage<uchar>::getStdev(const double &, vpImage<bool> *, unsigned int * = nullptr)");
683 mean = I_uchar_ref.getMeanValue(
nullptr, &nbValidPoints);
684 stdev = I_uchar_ref.getStdev(mean,
nullptr, &nbValidPoints);
685 success =
vpMath::equal(stdev, stdev_uchar_ref) && (nbValidPoints == (nbRows * nbCols));
688 failedTestsNames.push_back(nameTest);
692 std::cout <<
"\tTest " << nameTest <<
": " << (success ?
"OK" :
"failure") << std::endl;
694 std::cout <<
"Theoretical count = " << nbRows * nbCols <<
" | returned value = " << nbValidPoints << std::endl;
695 std::cout <<
"Theoretical stdev = " << stdev_uchar_ref <<
" | returned value = " << stdev << std::endl;
699 nameTest =
"vpImage<vpRGBa>::getStdev()";
700 stdev = I_rgba_ref.getStdev();
704 failedTestsNames.push_back(nameTest);
708 std::cout <<
"\tTest " << nameTest <<
": " << (success ?
"OK" :
"failure") << std::endl;
710 std::cout <<
"Theoretical stdev = " << stdev_rgba_ref <<
" | returned value = " << stdev << std::endl;
714 nameTest = (
"vpImage<vpRGBa>::getStdev(const vpImage<bool> *)");
715 stdev = I_rgba_ref.getStdev(&I_mask);
719 failedTestsNames.push_back(nameTest);
723 std::cout <<
"\tTest " << nameTest <<
": " << (success ?
"OK" :
"failure") << std::endl;
725 std::cout <<
"Theoretical stdev = " << stdev_rgba_true <<
" | returned value = " << stdev << std::endl;
729 nameTest = (
"vpImage<vpRGBa>::getStdev(const vpImage<bool> * = nullptr)");
730 stdev = I_rgba_ref.getStdev(
nullptr);
734 failedTestsNames.push_back(nameTest);
738 std::cout <<
"\tTest " << nameTest <<
": " << (success ?
"OK" :
"failure") << std::endl;
740 std::cout <<
"Theoretical stdev = " << stdev_rgba_ref <<
" | returned value = " << stdev << std::endl;
744 nameTest = (
"vpImage<vpRGBa>::getStdev(const double &)");
745 mean = I_rgba_ref.getMeanValue();
746 stdev = I_rgba_ref.getStdev(mean);
750 failedTestsNames.push_back(nameTest);
754 std::cout <<
"\tTest " << nameTest <<
": " << (success ?
"OK" :
"failure") << std::endl;
756 std::cout <<
"Theoretical stdev = " << stdev_rgba_ref <<
" | returned value = " << stdev << std::endl;
760 nameTest = (
"vpImage<vpRGBa>::getStdev(const double &, vpImage<bool> *, unsigned int *)");
762 mean = I_rgba_ref.getMeanValue(&I_mask, &nbValidPoints);
763 stdev = I_rgba_ref.getStdev(mean, &I_mask, &nbValidPoints);
767 failedTestsNames.push_back(nameTest);
771 std::cout <<
"\tTest " << nameTest <<
": " << (success ?
"OK" :
"failure") << std::endl;
773 std::cout <<
"Theoretical stdev = " << stdev_rgba_true <<
" | returned value = " << stdev << std::endl;
777 nameTest = (
"vpImage<vpRGBa>::getStdev(const double &, vpImage<bool> *, unsigned int * = nullptr)");
779 mean = I_rgba_ref.getMeanValue(
nullptr, &nbValidPoints);
780 stdev = I_rgba_ref.getStdev(mean,
nullptr, &nbValidPoints);
781 success =
vpMath::equal(stdev, stdev_rgba_ref) && (nbValidPoints == (nbRows * nbCols));
784 failedTestsNames.push_back(nameTest);
788 std::cout <<
"\tTest " << nameTest <<
": " << (success ?
"OK" :
"failure") << std::endl;
790 std::cout <<
"Theoretical count = " << nbRows * nbCols <<
" | returned value = " << nbValidPoints << std::endl;
791 std::cout <<
"Theoretical stdev = " << stdev_rgba_ref <<
" | returned value = " << stdev << std::endl;
795 nameTest =
"vpImage<vpRGBf>::getStdev()";
796 stdev = I_rgbf_ref.getStdev();
800 failedTestsNames.push_back(nameTest);
804 std::cout <<
"\tTest " << nameTest <<
": " << (success ?
"OK" :
"failure") << std::endl;
806 std::cout <<
"Theoretical stdev = " << stdev_rgbf_ref <<
" | returned value = " << stdev << std::endl;
810 nameTest = (
"vpImage<vpRGBf>::getStdev(const vpImage<bool> *)");
811 stdev = I_rgbf_ref.getStdev(&I_mask);
815 failedTestsNames.push_back(nameTest);
819 std::cout <<
"\tTest " << nameTest <<
": " << (success ?
"OK" :
"failure") << std::endl;
821 std::cout <<
"Theoretical stdev = " << stdev_rgbf_true <<
" | returned value = " << stdev << std::endl;
825 nameTest = (
"vpImage<vpRGBf>::getStdev(const vpImage<bool> * = nullptr)");
826 stdev = I_rgbf_ref.getStdev(
nullptr);
830 failedTestsNames.push_back(nameTest);
834 std::cout <<
"\tTest " << nameTest <<
": " << (success ?
"OK" :
"failure") << std::endl;
836 std::cout <<
"Theoretical stdev = " << stdev_rgbf_ref <<
" | returned value = " << stdev << std::endl;
840 nameTest = (
"vpImage<vpRGBf>::getStdev(const double &)");
841 mean = I_rgbf_ref.getMeanValue();
842 stdev = I_rgbf_ref.getStdev(mean);
846 failedTestsNames.push_back(nameTest);
850 std::cout <<
"\tTest " << nameTest <<
": " << (success ?
"OK" :
"failure") << std::endl;
852 std::cout <<
"Theoretical stdev = " << stdev_rgbf_ref <<
" | returned value = " << stdev << std::endl;
856 nameTest = (
"vpImage<vpRGBf>::getStdev(const double &, vpImage<bool> *, unsigned int *)");
858 mean = I_rgbf_ref.getMeanValue(&I_mask, &nbValidPoints);
859 stdev = I_rgbf_ref.getStdev(mean, &I_mask, &nbValidPoints);
863 failedTestsNames.push_back(nameTest);
867 std::cout <<
"\tTest " << nameTest <<
": " << (success ?
"OK" :
"failure") << std::endl;
869 std::cout <<
"Theoretical stdev = " << stdev_rgbf_true <<
" | returned value = " << stdev << std::endl;
873 nameTest = (
"vpImage<vpRGBf>::getStdev(const double &, vpImage<bool> *, unsigned int * = nullptr)");
875 mean = I_rgbf_ref.getMeanValue(
nullptr, &nbValidPoints);
876 stdev = I_rgbf_ref.getStdev(mean,
nullptr, &nbValidPoints);
877 success =
vpMath::equal(stdev, stdev_rgbf_ref) && (nbValidPoints == (nbRows * nbCols));
880 failedTestsNames.push_back(nameTest);
884 std::cout <<
"\tTest " << nameTest <<
": " << (success ?
"OK" :
"failure") << std::endl;
886 std::cout <<
"Theoretical count = " << nbRows * nbCols <<
" | returned value = " << nbValidPoints << std::endl;
887 std::cout <<
"Theoretical stdev = " << stdev_rgbf_ref <<
" | returned value = " << stdev << std::endl;
893 std::cout <<
"All tests succeeded" << std::endl;
897 std::cerr << nbFailedTests <<
" tests failed: " << std::endl;
898 for (
unsigned int i = 0; i < nbFailedTests; ++i) {
899 std::cerr <<
" - " << failedTestsNames[i] << std::endl;
static bool equal(double x, double y, double threshold=0.001)