43 #include <visp3/core/vpImageMorphology.h>
44 #include <visp3/core/vpImageTools.h>
45 #include <visp3/io/vpImageIo.h>
46 #include <visp3/io/vpParseArgv.h>
47 #include <visp3/core/vpIoTools.h>
50 #define GETOPTARGS "cdi:n:h"
61 void usage(
const char *name,
const char *badparam, std::string ipath,
int nbiter)
64 Test vpImageMorphology functions.\n\
67 %s [-i <input image path>] [-n <nb benchmark iterations>]\n\
73 -i <input image path> %s\n\
74 Set image input path.\n\
75 From this path read \"ViSP-images/Klimt/Klimt.pgm\"\n\
76 and \"ViSP-images/Klimt/Klimt.ppm\" images.\n\
77 Setting the VISP_INPUT_IMAGE_PATH environment\n\
78 variable produces the same behaviour than using\n\
80 -n <nb benchmark iterations> %d\n\
81 Set the number of benchmark iterations.\n\
85 ipath.c_str(), nbiter);
88 fprintf(stdout,
"\nERROR: Bad parameter [%s]\n", badparam);
100 bool getOptions(
int argc,
const char **argv, std::string &ipath,
int &nbIterations)
107 case 'i': ipath = optarg_;
break;
108 case 'n': nbIterations = atoi(optarg_);
break;
109 case 'h': usage(argv[0], NULL, ipath, nbIterations);
return false;
break;
116 usage(argv[0], optarg_, ipath, nbIterations);
return false;
break;
120 if ((c == 1) || (c == -1)) {
122 usage(argv[0], NULL, ipath, nbIterations);
123 std::cerr <<
"ERROR: " << std::endl;
124 std::cerr <<
" Bad argument " << optarg_ << std::endl << std::endl;
132 std::cout <<
"\n" << name <<
":" << std::endl;
133 for(
unsigned int i = 0; i < I.
getHeight(); i++) {
134 for(
unsigned int j = 0; j < I.
getWidth(); j++) {
135 std::cout << static_cast<unsigned>(I[i][j]) <<
" ";
137 std::cout << std::endl;
144 std::cerr <<
"Input image is empty!" << std::endl;
148 const unsigned char null_value = 255;
152 for (
unsigned int i = 0; i < J.getHeight(); i++) {
153 if (i == 0 || i == J.getHeight() - 1) {
154 for (
unsigned int j = 0; j < J.getWidth(); j++) {
155 J[i][j] = null_value;
158 J[i][0] = null_value;
159 memcpy(J[i]+1, I[i-1],
sizeof(
unsigned char)*I.
getWidth());
160 J[i][J.getWidth() - 1] = null_value;
165 unsigned int offset[5] = {1, J.
getWidth(), J.getWidth()+1, J.getWidth()+2, J.getWidth()*2 + 1};
167 for (
unsigned int i = 0; i < I.
getHeight(); i++) {
168 unsigned char *ptr_curr_J = J.bitmap + i*J.getWidth();
171 for (
unsigned int j = 0; j < I.
getWidth(); j++) {
172 unsigned char min_value = null_value;
173 for (
int k = 0; k < 5; k++) {
174 min_value = std::min(min_value, *(ptr_curr_J + j + offset[k]));
177 *(ptr_curr_I + j) = min_value;
182 unsigned int offset[9] = {0, 1, 2, J.getWidth(), J.getWidth()+1, J.getWidth()+2,
183 J.getWidth()*2, J.getWidth()*2 + 1, J.getWidth()*2 + 2};
185 for (
unsigned int i = 0; i < I.
getHeight(); i++) {
186 unsigned char *ptr_curr_J = J.bitmap + i*J.getWidth();
189 for (
unsigned int j = 0; j < I.
getWidth(); j++) {
190 unsigned char min_value = null_value;
191 for (
int k = 0; k < 9; k++) {
192 min_value = std::min(min_value, *(ptr_curr_J + j + offset[k]));
195 *(ptr_curr_I + j) = min_value;
204 std::cerr <<
"Input image is empty!" << std::endl;
208 const unsigned char null_value = 0;
212 for (
unsigned int i = 0; i < J.getHeight(); i++) {
213 if (i == 0 || i == J.getHeight() - 1) {
214 for (
unsigned int j = 0; j < J.getWidth(); j++) {
215 J[i][j] = null_value;
218 J[i][0] = null_value;
219 memcpy(J[i]+1, I[i-1],
sizeof(
unsigned char)*I.
getWidth());
220 J[i][J.getWidth() - 1] = null_value;
225 unsigned int offset[5] = {1, J.
getWidth(), J.getWidth()+1, J.getWidth()+2, J.getWidth()*2 + 1};
227 for (
unsigned int i = 0; i < I.
getHeight(); i++) {
228 unsigned char *ptr_curr_J = J.bitmap + i*J.getWidth();
231 for (
unsigned int j = 0; j < I.
getWidth(); j++) {
232 unsigned char max_value = null_value;
233 for (
int k = 0; k < 5; k++) {
234 max_value = std::max(max_value, *(ptr_curr_J + j + offset[k]));
237 *(ptr_curr_I + j) = max_value;
242 unsigned int offset[9] = {0, 1, 2, J.getWidth(), J.getWidth()+1, J.getWidth()+2,
243 J.getWidth()*2, J.getWidth()*2 + 1, J.getWidth()*2 + 2};
245 for (
unsigned int i = 0; i < I.
getHeight(); i++) {
246 unsigned char *ptr_curr_J = J.bitmap + i*J.getWidth();
249 for (
unsigned int j = 0; j < I.
getWidth(); j++) {
250 unsigned char max_value = null_value;
251 for (
int k = 0; k < 9; k++) {
252 max_value = std::max(max_value, *(ptr_curr_J + j + offset[k]));
255 *(ptr_curr_I + j) = max_value;
263 magic_square.
resize((
unsigned int) N, (
unsigned int) N, 0);
269 magic_square[i][j] = vpMath::saturate<unsigned char>(n);
274 if (magic_square[newi][newj]) {
283 int main(
int argc,
const char ** argv) {
285 std::string env_ipath;
286 std::string opt_ipath;
288 std::string filename;
289 int nbIterations = 100;
295 if (! env_ipath.empty())
299 if (getOptions(argc, argv, opt_ipath, nbIterations) ==
false) {
304 if (!opt_ipath.empty())
309 if (opt_ipath.empty()) {
310 if (ipath != env_ipath) {
311 std::cout << std::endl
312 <<
"WARNING: " << std::endl;
313 std::cout <<
" Since -i <visp image path=" << ipath <<
"> "
314 <<
" is different from VISP_IMAGE_PATH=" << env_ipath << std::endl
315 <<
" we skip the environment variable." << std::endl;
320 if (opt_ipath.empty() && env_ipath.empty()){
321 usage(argv[0], NULL, ipath, nbIterations);
322 std::cerr << std::endl
323 <<
"ERROR:" << std::endl;
324 std::cerr <<
" Use -i <visp image path> option or set VISP_INPUT_IMAGE_PATH "
326 <<
" environment variable to specify the location of the " << std::endl
327 <<
" image path where test images are located." << std::endl << std::endl;
333 unsigned char image_data[8*16] = {
334 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
335 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0,
336 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0,
337 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1,
338 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1,
339 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0,
340 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1,
341 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0
356 printMatrix(I_dilatation1,
"I_dilatation1");
357 printMatrix(I_dilatation2,
"I_dilatation2");
367 printMatrix(I_erosion1,
"I_erosion1");
368 printMatrix(I_erosion2,
"I_erosion2");
379 printMatrix(I_dilatation1_sse,
"I_dilatation1_sse");
380 printMatrix(I_dilatation2_sse,
"I_dilatation2_sse");
382 std::cout <<
"\n(I_dilatation1 == I_dilatation1_sse)? " << (I_dilatation1 == I_dilatation1_sse) << std::endl;
383 std::cout <<
"(I_dilatation2 == I_dilatation2_sse)? " << (I_dilatation2 == I_dilatation2_sse) << std::endl;
385 if ((I_dilatation1 != I_dilatation1_sse)) {
388 if ((I_dilatation2 != I_dilatation2_sse)) {
400 printMatrix(I_erosion1_sse,
"I_erosion1_sse");
401 printMatrix(I_erosion2_sse,
"I_erosion2_sse");
403 std::cout <<
"\n(I_erosion1 == I_erosion1_sse)? " << (I_erosion1 == I_erosion1_sse) << std::endl;
404 std::cout <<
"(I_erosion2 == I_erosion2_sse)? " << (I_erosion2 == I_erosion2_sse) << std::endl;
406 if ((I_erosion1 != I_erosion1_sse)) {
409 if ((I_erosion2 != I_erosion2_sse)) {
415 unsigned char image_data_dilated1[8*16] = {
416 0,0,0,0,0,1,1,0,1,0,0,0,0,1,0,0,
417 0,0,0,0,1,1,1,1,1,1,0,0,1,1,1,0,
418 0,0,1,1,1,1,1,1,1,1,1,0,1,1,1,1,
419 0,1,1,1,1,1,1,1,0,1,1,1,0,1,1,1,
420 1,0,1,1,1,1,1,1,1,0,1,0,0,0,1,1,
421 1,1,0,0,1,1,1,1,1,0,0,0,0,0,0,1,
422 1,1,0,0,1,1,1,1,1,1,0,0,0,0,1,1,
423 1,1,0,0,1,1,1,1,1,1,1,0,0,0,0,1
428 if (I_check_dilated1 != I_dilatation1_sse) {
433 unsigned char image_data_dilated2[8*16] = {
434 0,0,0,0,1,1,1,1,1,1,0,0,1,1,1,0,
435 0,0,0,0,1,1,1,1,1,1,1,0,1,1,1,1,
436 0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
437 0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
438 1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,
439 1,1,0,0,1,1,1,1,1,0,0,0,0,0,1,1,
440 1,1,0,0,1,1,1,1,1,1,1,0,0,0,1,1,
441 1,1,0,0,1,1,1,1,1,1,1,0,0,0,1,1
446 if (I_check_dilated2 != I_dilatation2_sse) {
451 unsigned char image_data_eroded1[8*16] = {
452 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
453 0,0,0,0,0,1,1,0,1,0,0,0,0,1,0,0,
454 0,0,0,0,1,1,1,1,0,1,0,0,0,1,1,0,
455 0,0,1,1,1,1,1,0,0,0,1,0,0,0,1,1,
456 0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,1,
457 1,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,
458 1,0,0,0,0,1,1,1,1,0,0,0,0,0,0,1,
459 1,0,0,0,0,1,1,1,1,1,0,0,0,0,0,0
464 if (I_check_eroded1 != I_erosion1_sse) {
469 unsigned char image_data_eroded2[8*16] = {
470 0,0,0,0,0,1,1,1,1,0,0,0,0,1,0,0,
471 0,0,0,0,0,1,1,1,1,0,0,0,0,1,0,0,
472 0,0,0,0,0,1,1,1,1,1,0,0,0,1,1,1,
473 0,0,1,1,1,1,1,1,1,1,1,0,0,0,1,1,
474 0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,1,
475 1,0,0,0,0,1,1,1,0,0,0,0,0,0,0,1,
476 1,0,0,0,0,1,1,1,0,0,0,0,0,0,0,1,
477 1,0,0,0,0,1,1,1,1,1,0,0,0,0,0,1
482 if (I_check_eroded2 != I_erosion2_sse) {
490 magicSquare(I_magic_square, 17);
491 printMatrix(I_magic_square,
"I_magic_square");
500 if ((I_magic_square_dilatation1 != I_magic_square_dilatation1_sse)) {
511 if ((I_magic_square_dilatation2 != I_magic_square_dilatation2_sse)) {
522 if ((I_magic_square_erosion1 != I_magic_square_erosion1_sse)) {
533 if ((I_magic_square_erosion2 != I_magic_square_erosion2_sse)) {
539 unsigned char image_data2_dilated1[17*17] = {
540 174,193,212,231,250,255,255,255,255,39,58,77,96,115,134,153,154,
541 192,211,230,249,255,255,255,255,38,57,76,95,114,133,152,170,172,
542 210,229,248,255,255,255,255,37,56,75,94,113,132,151,170,172,190,
543 228,247,255,255,255,255,36,55,74,93,112,131,150,169,187,190,208,
544 246,255,255,255,255,51,54,73,92,111,130,149,168,187,189,208,226,
545 255,255,255,255,51,53,72,91,110,129,148,167,186,204,207,226,244,
546 255,255,255,50,68,71,90,109,128,147,166,185,204,206,225,244,255,
547 255,255,49,68,70,89,108,127,146,165,184,203,221,224,243,255,255,
548 255,48,67,85,88,107,126,145,164,183,202,221,223,242,255,255,255,
549 47,66,85,87,106,125,144,163,182,201,220,238,241,255,255,255,255,
550 65,84,102,105,124,143,162,181,200,219,238,240,255,255,255,255,45,
551 83,102,104,123,142,161,180,199,218,237,255,255,255,255,255,45,63,
552 101,119,122,141,160,179,198,217,236,255,255,255,255,255,44,63,81,
553 119,121,140,159,178,197,216,235,254,255,255,255,255,43,62,81,99,
554 136,139,158,177,196,215,234,253,255,255,255,255,42,61,80,99,117,
555 138,157,176,195,214,233,252,255,255,255,255,41,60,79,98,117,135,
556 156,175,194,213,232,251,255,255,255,255,40,59,78,97,116,135,135
561 if (I2_check_dilated1 != I_magic_square_dilatation1_sse) {
566 unsigned char image_data2_dilated2[17*17] = {
567 192,211,230,249,255,255,255,255,255,57,76,95,114,133,152,154,154,
568 210,229,248,255,255,255,255,255,255,75,94,113,132,151,170,172,172,
569 228,247,255,255,255,255,255,255,74,93,112,131,150,169,171,190,190,
570 246,255,255,255,255,255,255,73,92,111,130,149,168,187,189,208,208,
571 255,255,255,255,255,255,72,91,110,129,148,167,186,188,207,226,226,
572 255,255,255,255,255,71,90,109,128,147,166,185,204,206,225,244,244,
573 255,255,255,255,70,89,108,127,146,165,184,203,205,224,243,255,255,
574 255,255,255,69,88,107,126,145,164,183,202,221,223,242,255,255,255,
575 255,255,85,87,106,125,144,163,182,201,220,222,241,255,255,255,255,
576 65,84,86,105,124,143,162,181,200,219,238,240,255,255,255,255,255,
577 83,102,104,123,142,161,180,199,218,237,239,255,255,255,255,255,255,
578 101,103,122,141,160,179,198,217,236,255,255,255,255,255,255,255,63,
579 119,121,140,159,178,197,216,235,254,255,255,255,255,255,255,81,81,
580 120,139,158,177,196,215,234,253,255,255,255,255,255,255,80,99,99,
581 138,157,176,195,214,233,252,255,255,255,255,255,255,79,98,117,117,
582 156,175,194,213,232,251,255,255,255,255,255,255,78,97,116,135,135,
583 156,175,194,213,232,251,255,255,255,255,255,59,78,97,116,135,135
588 if (I2_check_dilated2 != I_magic_square_dilatation2_sse) {
593 unsigned char image_data2_eroded1[17*17] = {
594 174,174,193,212,231,250,255,255,38,39,39,58,77,96,115,134,153,
595 174,192,211,230,249,255,255,37,38,38,57,76,95,114,133,152,154,
596 192,210,229,248,255,255,36,37,37,56,75,94,113,132,151,170,172,
597 210,228,247,255,255,36,36,36,55,74,93,112,131,150,169,172,190,
598 228,246,255,255,51,51,36,54,73,92,111,130,149,168,187,189,208,
599 246,255,255,50,51,51,53,72,91,110,129,148,167,186,189,207,226,
600 255,255,49,50,50,53,71,90,109,128,147,166,185,204,206,225,244,
601 255,48,49,49,68,70,89,108,127,146,165,184,203,206,224,243,255,
602 47,48,48,67,70,88,107,126,145,164,183,202,221,223,242,255,255,
603 47,47,66,85,87,106,125,144,163,182,201,220,223,241,255,255,45,
604 47,65,84,87,105,124,143,162,181,200,219,238,240,255,255,45,45,
605 65,83,102,104,123,142,161,180,199,218,237,240,255,255,44,45,45,
606 83,101,104,122,141,160,179,198,217,236,255,255,255,43,44,44,63,
607 101,119,121,140,159,178,197,216,235,254,255,255,42,43,43,62,81,
608 119,121,139,158,177,196,215,234,253,255,255,41,42,42,61,80,99,
609 136,138,157,176,195,214,233,252,255,255,40,41,41,60,79,98,117,
610 138,156,175,194,213,232,251,255,255,40,40,40,59,78,97,116,135
615 if (I2_check_eroded1 != I_magic_square_erosion1_sse) {
616 printMatrix(I_magic_square_erosion1_sse,
"I_magic_square_erosion1_sse");
622 unsigned char image_data2_eroded2[17*17] = {
623 192,192,211,230,249,255,255,255,57,57,57,76,95,114,133,152,154,
624 192,192,211,230,249,255,255,74,57,57,57,76,95,114,133,152,154,
625 210,210,229,248,255,255,73,73,73,74,75,94,113,132,151,170,172,
626 228,228,247,255,255,72,72,72,73,74,93,112,131,150,169,171,190,
627 246,246,255,255,71,71,71,72,73,92,111,130,149,168,187,189,208,
628 255,255,255,70,70,70,71,72,91,110,129,148,167,186,188,207,226,
629 255,255,69,69,69,70,71,90,109,128,147,166,185,204,206,225,244,
630 255,85,69,69,69,70,89,108,127,146,165,184,203,205,224,243,255,
631 65,65,69,69,69,88,107,126,145,164,183,202,221,223,242,255,255,
632 65,65,84,85,87,106,125,144,163,182,201,220,222,241,255,255,255,
633 65,65,84,86,105,124,143,162,181,200,219,238,240,255,255,63,63,
634 83,83,102,104,123,142,161,180,199,218,237,239,255,255,81,63,63,
635 101,101,103,122,141,160,179,198,217,236,255,255,255,80,80,63,63,
636 119,119,121,140,159,178,197,216,235,254,255,255,79,79,79,80,81,
637 120,120,139,158,177,196,215,234,253,255,255,78,78,78,79,80,99,
638 138,138,157,176,195,214,233,252,255,255,59,59,59,78,79,98,117,
639 156,156,175,194,213,232,251,255,255,255,59,59,59,78,97,116,135
644 if (I2_check_eroded2 != I_magic_square_erosion2_sse) {
651 std::cout << std::endl;
661 vpImageTools::binarise(I_Klimt_binarized, (
unsigned char) 127, (
unsigned char) 127, (
unsigned char) 0, (
unsigned char) 1, (
unsigned char) 1,
true);
669 for (
int cpt = 0; cpt < nbIterations; cpt++) {
675 for (
int cpt = 0; cpt < nbIterations; cpt++) {
680 std::cout <<
"(I_Klimt_binarized_dilatation1 == I_Klimt_binarized_dilatation1_sse)? "
681 << (I_Klimt_binarized_dilatation1 == I_Klimt_binarized_dilatation1_sse)
682 <<
" ; t=" << t <<
" ms ; t_sse=" << t_sse <<
" ms"
683 <<
" ; speed-up=" << (t/t_sse) <<
"X" << std::endl;
691 for (
int cpt = 0; cpt < nbIterations; cpt++) {
697 for (
int cpt = 0; cpt < nbIterations; cpt++) {
702 std::cout <<
"(I_Klimt_binarized_dilatation2 == I_Klimt_binarized_dilatation2_sse)? "
703 << (I_Klimt_binarized_dilatation2 == I_Klimt_binarized_dilatation2_sse)
704 <<
" ; t=" << t <<
" ms ; t_sse=" << t_sse <<
" ms"
705 <<
" ; speed-up=" << (t/t_sse) <<
"X" << std::endl;
713 for (
int cpt = 0; cpt < nbIterations; cpt++) {
719 for (
int cpt = 0; cpt < nbIterations; cpt++) {
724 std::cout <<
"(I_Klimt_binarized_erosion1 == I_Klimt_binarized_erosion1_sse)? "
725 << (I_Klimt_binarized_erosion1 == I_Klimt_binarized_erosion1_sse)
726 <<
" ; t=" << t <<
" ms ; t_sse=" << t_sse <<
" ms"
727 <<
" ; speed-up=" << (t/t_sse) <<
"X" << std::endl;
735 for (
int cpt = 0; cpt < nbIterations; cpt++) {
741 for (
int cpt = 0; cpt < nbIterations; cpt++) {
746 std::cout <<
"(I_Klimt_binarized_erosion2 == I_Klimt_binarized_erosion2_sse)? "
747 << (I_Klimt_binarized_erosion2 == I_Klimt_binarized_erosion2_sse)
748 <<
" ; t=" << t <<
" ms ; t_sse=" << t_sse <<
" ms"
749 <<
" ; speed-up=" << (t/t_sse) <<
"X" << std::endl;
761 for (
int cpt = 0; cpt < nbIterations; cpt++) {
767 for (
int cpt = 0; cpt < nbIterations; cpt++) {
772 std::cout <<
"(I_Klimt_dilatation1 == I_Klimt_dilatation1_sse)? "
773 << (I_Klimt_dilatation1 == I_Klimt_dilatation1_sse)
774 <<
" ; t=" << t <<
" ms ; t_sse=" << t_sse <<
" ms"
775 <<
" ; speed-up=" << (t/t_sse) <<
"X" << std::endl;
783 for (
int cpt = 0; cpt < nbIterations; cpt++) {
789 for (
int cpt = 0; cpt < nbIterations; cpt++) {
794 std::cout <<
"(I_Klimt_dilatation2 == I_Klimt_dilatation2_sse)? "
795 << (I_Klimt_dilatation2 == I_Klimt_dilatation2_sse)
796 <<
" ; t=" << t <<
" ms ; t_sse=" << t_sse <<
" ms"
797 <<
" ; speed-up=" << (t/t_sse) <<
"X" << std::endl;
805 for (
int cpt = 0; cpt < nbIterations; cpt++) {
811 for (
int cpt = 0; cpt < nbIterations; cpt++) {
816 std::cout <<
"(I_Klimt_erosion1 == I_Klimt_erosion1_sse)? "
817 << (I_Klimt_erosion1 == I_Klimt_erosion1_sse)
818 <<
" ; t=" << t <<
" ms ; t_sse=" << t_sse <<
" ms"
819 <<
" ; speed-up=" << (t/t_sse) <<
"X" << std::endl;
827 for (
int cpt = 0; cpt < nbIterations; cpt++) {
833 for (
int cpt = 0; cpt < nbIterations; cpt++) {
838 std::cout <<
"(I_Klimt_erosion2 == I_Klimt_erosion2_sse)? "
839 << (I_Klimt_erosion2 == I_Klimt_erosion2_sse)
840 <<
" ; t=" << t <<
" ms ; t_sse=" << t_sse <<
" ms"
841 <<
" ; speed-up=" << (t/t_sse) <<
"X" << std::endl;
845 #if (VISP_HAVE_OPENCV_VERSION >= 0x030000)
846 std::cout << std::endl;
848 cv::Mat cross_SE = cv::getStructuringElement(cv::MORPH_CROSS, cv::Size(3,3));
849 cv::Mat rect_SE = cv::getStructuringElement(cv::MORPH_RECT, cv::Size(3,3));
852 cv::Mat matImg_dilatation1;
856 for (
int cpt = 0; cpt < nbIterations; cpt++) {
857 cv::morphologyEx(matImg_dilatation1, matImg_dilatation1, cv::MORPH_DILATE, cross_SE);
863 std::cout <<
"(I_matImg_dilatation1 == I_Klimt_dilatation1_sse)? "
864 << (I_matImg_dilatation1 == I_Klimt_dilatation1_sse)
865 <<
" ; t_opencv=" << t_opencv <<
" ms"
870 cv::Mat matImg_dilatation2;
874 for (
int cpt = 0; cpt < nbIterations; cpt++) {
875 cv::morphologyEx(matImg_dilatation2, matImg_dilatation2, cv::MORPH_DILATE, rect_SE);
881 std::cout <<
"(I_matImg_dilatation2 == I_Klimt_dilatation2_sse)? "
882 << (I_matImg_dilatation2 == I_Klimt_dilatation2_sse)
883 <<
" ; t_opencv=" << t_opencv <<
" ms"
887 cv::Mat matImg_erosion1;
891 for (
int cpt = 0; cpt < nbIterations; cpt++) {
892 cv::morphologyEx(matImg_erosion1, matImg_erosion1, cv::MORPH_ERODE, cross_SE);
898 std::cout <<
"(I_matImg_erosion1 == I_Klimt_erosion1_sse)? "
899 << (I_matImg_erosion1 == I_Klimt_erosion1_sse)
900 <<
" ; t_opencv=" << t_opencv <<
" ms"
905 cv::Mat matImg_erosion2;
909 for (
int cpt = 0; cpt < nbIterations; cpt++) {
910 cv::morphologyEx(matImg_erosion2, matImg_erosion2, cv::MORPH_ERODE, rect_SE);
916 std::cout <<
"(I_matImg_erosion2 == I_Klimt_erosion2_sse)? "
917 << (I_matImg_erosion2 == I_Klimt_erosion2_sse)
918 <<
" ; t_opencv=" << t_opencv <<
" ms"
924 std::cout <<
"\nCatch an exception: " << e << std::endl;
928 std::cout <<
"\nTest of morphology erosion / dilatation functions are OK!" << std::endl;
static int modulo(const int a, const int n)
static void dilatation(vpImage< Type > &I, Type value, Type value_out, vpConnexityType connexity=CONNEXITY_4)
unsigned int getWidth() const
static void convert(const vpImage< unsigned char > &src, vpImage< vpRGBa > &dest)
Type * bitmap
points toward the bitmap
error that can be emited by ViSP classes.
VISP_EXPORT double measureTimeMs()
static bool parse(int *argcPtr, const char **argv, vpArgvInfo *argTable, int flags)
static void erosion(vpImage< Type > &I, Type value, Type value_out, vpConnexityType connexity=CONNEXITY_4)
unsigned int getSize() const
void resize(const unsigned int h, const unsigned int w)
resize the image : Image initialization
static void read(vpImage< unsigned char > &I, const std::string &filename)
unsigned int getHeight() const