44 #include <visp3/core/vpImageMorphology.h> 45 #include <visp3/core/vpImageTools.h> 46 #include <visp3/core/vpIoTools.h> 47 #include <visp3/io/vpImageIo.h> 48 #include <visp3/io/vpParseArgv.h> 51 #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 \"Klimt/Klimt.pgm\"\n\ 76 and \"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\ 84 Print the help.\n\n", ipath.c_str(), nbiter);
87 fprintf(stdout,
"\nERROR: Bad parameter [%s]\n", badparam);
99 bool getOptions(
int argc,
const char **argv, std::string &ipath,
int &nbIterations)
110 nbIterations = atoi(optarg_);
113 usage(argv[0], NULL, ipath, nbIterations);
122 usage(argv[0], optarg_, ipath, nbIterations);
128 if ((c == 1) || (c == -1)) {
130 usage(argv[0], NULL, ipath, nbIterations);
131 std::cerr <<
"ERROR: " << std::endl;
132 std::cerr <<
" Bad argument " << optarg_ << std::endl << std::endl;
141 std::cout <<
"\n" << name <<
":" << std::endl;
142 for (
unsigned int i = 0; i < I.
getHeight(); i++) {
143 for (
unsigned int j = 0; j < I.
getWidth(); j++) {
144 std::cout << static_cast<unsigned>(I[i][j]) <<
" ";
146 std::cout << std::endl;
155 std::cerr <<
"Input image is empty!" << std::endl;
159 const unsigned char null_value = 255;
163 for (
unsigned int i = 0; i < J.getHeight(); i++) {
164 if (i == 0 || i == J.getHeight() - 1) {
165 for (
unsigned int j = 0; j < J.getWidth(); j++) {
166 J[i][j] = null_value;
169 J[i][0] = null_value;
170 memcpy(J[i] + 1, I[i - 1],
sizeof(
unsigned char) * I.
getWidth());
171 J[i][J.getWidth() - 1] = null_value;
176 unsigned int offset[5] = {1, J.
getWidth(), J.getWidth() + 1, J.getWidth() + 2, J.getWidth() * 2 + 1};
178 for (
unsigned int i = 0; i < I.
getHeight(); i++) {
179 unsigned char *ptr_curr_J = J.bitmap + i * J.getWidth();
182 for (
unsigned int j = 0; j < I.
getWidth(); j++) {
183 unsigned char min_value = null_value;
184 for (
int k = 0; k < 5; k++) {
185 min_value = (std::min)(min_value, *(ptr_curr_J + j + offset[k]));
188 *(ptr_curr_I + j) = min_value;
193 unsigned int offset[9] = {0,
200 J.getWidth() * 2 + 1,
201 J.getWidth() * 2 + 2};
203 for (
unsigned int i = 0; i < I.
getHeight(); i++) {
204 unsigned char *ptr_curr_J = J.bitmap + i * J.getWidth();
207 for (
unsigned int j = 0; j < I.
getWidth(); j++) {
208 unsigned char min_value = null_value;
209 for (
int k = 0; k < 9; k++) {
210 min_value = (std::min)(min_value, *(ptr_curr_J + j + offset[k]));
213 *(ptr_curr_I + j) = min_value;
224 std::cerr <<
"Input image is empty!" << std::endl;
228 const unsigned char null_value = 0;
232 for (
unsigned int i = 0; i < J.getHeight(); i++) {
233 if (i == 0 || i == J.getHeight() - 1) {
234 for (
unsigned int j = 0; j < J.getWidth(); j++) {
235 J[i][j] = null_value;
238 J[i][0] = null_value;
239 memcpy(J[i] + 1, I[i - 1],
sizeof(
unsigned char) * I.
getWidth());
240 J[i][J.getWidth() - 1] = null_value;
245 unsigned int offset[5] = {1, J.
getWidth(), J.getWidth() + 1, J.getWidth() + 2, J.getWidth() * 2 + 1};
247 for (
unsigned int i = 0; i < I.
getHeight(); i++) {
248 unsigned char *ptr_curr_J = J.bitmap + i * J.getWidth();
251 for (
unsigned int j = 0; j < I.
getWidth(); j++) {
252 unsigned char max_value = null_value;
253 for (
int k = 0; k < 5; k++) {
254 max_value = (std::max)(max_value, *(ptr_curr_J + j + offset[k]));
257 *(ptr_curr_I + j) = max_value;
262 unsigned int offset[9] = {0,
269 J.getWidth() * 2 + 1,
270 J.getWidth() * 2 + 2};
272 for (
unsigned int i = 0; i < I.
getHeight(); i++) {
273 unsigned char *ptr_curr_J = J.bitmap + i * J.getWidth();
276 for (
unsigned int j = 0; j < I.
getWidth(); j++) {
277 unsigned char max_value = null_value;
278 for (
int k = 0; k < 9; k++) {
279 max_value = (std::max)(max_value, *(ptr_curr_J + j + offset[k]));
282 *(ptr_curr_I + j) = max_value;
291 magic_square.
resize((
unsigned int)N, (
unsigned int)N, 0);
294 int i = 0, j = N / 2;
297 magic_square[i][j] = vpMath::saturate<unsigned char>(n);
302 if (magic_square[newi][newj]) {
311 int main(
int argc,
const char **argv)
314 std::string env_ipath;
315 std::string opt_ipath;
317 std::string filename;
318 int nbIterations = 100;
325 if (!env_ipath.empty())
329 if (getOptions(argc, argv, opt_ipath, nbIterations) ==
false) {
334 if (!opt_ipath.empty())
339 if (opt_ipath.empty()) {
340 if (ipath != env_ipath) {
341 std::cout << std::endl <<
"WARNING: " << std::endl;
342 std::cout <<
" Since -i <visp image path=" << ipath <<
"> " 343 <<
" is different from VISP_IMAGE_PATH=" << env_ipath << std::endl
344 <<
" we skip the environment variable." << std::endl;
349 if (opt_ipath.empty() && env_ipath.empty()) {
350 usage(argv[0], NULL, ipath, nbIterations);
351 std::cerr << std::endl <<
"ERROR:" << std::endl;
352 std::cerr <<
" Use -i <visp image path> option or set VISP_INPUT_IMAGE_PATH " << std::endl
353 <<
" environment variable to specify the location of the " << std::endl
354 <<
" image path where test images are located." << std::endl
360 unsigned char image_data[8 * 16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0,
361 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1,
362 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0,
363 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1,
364 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0};
377 printMatrix(I_dilatation1,
"I_dilatation1");
378 printMatrix(I_dilatation2,
"I_dilatation2");
387 printMatrix(I_erosion1,
"I_erosion1");
388 printMatrix(I_erosion2,
"I_erosion2");
398 printMatrix(I_dilatation1_sse,
"I_dilatation1_sse");
399 printMatrix(I_dilatation2_sse,
"I_dilatation2_sse");
401 std::cout <<
"\n(I_dilatation1 == I_dilatation1_sse)? " << (I_dilatation1 == I_dilatation1_sse) << std::endl;
402 std::cout <<
"(I_dilatation2 == I_dilatation2_sse)? " << (I_dilatation2 == I_dilatation2_sse) << std::endl;
404 if ((I_dilatation1 != I_dilatation1_sse)) {
407 if ((I_dilatation2 != I_dilatation2_sse)) {
418 printMatrix(I_erosion1_sse,
"I_erosion1_sse");
419 printMatrix(I_erosion2_sse,
"I_erosion2_sse");
421 std::cout <<
"\n(I_erosion1 == I_erosion1_sse)? " << (I_erosion1 == I_erosion1_sse) << std::endl;
422 std::cout <<
"(I_erosion2 == I_erosion2_sse)? " << (I_erosion2 == I_erosion2_sse) << std::endl;
424 if ((I_erosion1 != I_erosion1_sse)) {
427 if ((I_erosion2 != I_erosion2_sse)) {
432 unsigned char image_data_dilated1[8 * 16] = {
433 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0,
434 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1,
435 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1,
436 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1};
440 if (I_check_dilated1 != I_dilatation1_sse) {
444 unsigned char image_data_dilated2[8 * 16] = {
445 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1,
446 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
447 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1,
448 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1};
452 if (I_check_dilated2 != I_dilatation2_sse) {
456 unsigned char image_data_eroded1[8 * 16] = {
457 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0,
458 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1,
459 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0,
460 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0};
464 if (I_check_eroded1 != I_erosion1_sse) {
468 unsigned char image_data_eroded2[8 * 16] = {
469 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0,
470 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1,
471 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1,
472 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1};
476 if (I_check_eroded2 != I_erosion2_sse) {
482 magicSquare(I_magic_square, 17);
483 printMatrix(I_magic_square,
"I_magic_square");
492 if ((I_magic_square_dilatation1 != I_magic_square_dilatation1_sse)) {
503 if ((I_magic_square_dilatation2 != I_magic_square_dilatation2_sse)) {
514 if ((I_magic_square_erosion1 != I_magic_square_erosion1_sse)) {
525 if ((I_magic_square_erosion2 != I_magic_square_erosion2_sse)) {
530 unsigned char image_data2_dilated1[17 * 17] = {
531 174, 193, 212, 231, 250, 255, 255, 255, 255, 39, 58, 77, 96, 115, 134, 153, 154, 192, 211, 230, 249,
532 255, 255, 255, 255, 38, 57, 76, 95, 114, 133, 152, 170, 172, 210, 229, 248, 255, 255, 255, 255, 37,
533 56, 75, 94, 113, 132, 151, 170, 172, 190, 228, 247, 255, 255, 255, 255, 36, 55, 74, 93, 112, 131,
534 150, 169, 187, 190, 208, 246, 255, 255, 255, 255, 51, 54, 73, 92, 111, 130, 149, 168, 187, 189, 208,
535 226, 255, 255, 255, 255, 51, 53, 72, 91, 110, 129, 148, 167, 186, 204, 207, 226, 244, 255, 255, 255,
536 50, 68, 71, 90, 109, 128, 147, 166, 185, 204, 206, 225, 244, 255, 255, 255, 49, 68, 70, 89, 108,
537 127, 146, 165, 184, 203, 221, 224, 243, 255, 255, 255, 48, 67, 85, 88, 107, 126, 145, 164, 183, 202,
538 221, 223, 242, 255, 255, 255, 47, 66, 85, 87, 106, 125, 144, 163, 182, 201, 220, 238, 241, 255, 255,
539 255, 255, 65, 84, 102, 105, 124, 143, 162, 181, 200, 219, 238, 240, 255, 255, 255, 255, 45, 83, 102,
540 104, 123, 142, 161, 180, 199, 218, 237, 255, 255, 255, 255, 255, 45, 63, 101, 119, 122, 141, 160, 179,
541 198, 217, 236, 255, 255, 255, 255, 255, 44, 63, 81, 119, 121, 140, 159, 178, 197, 216, 235, 254, 255,
542 255, 255, 255, 43, 62, 81, 99, 136, 139, 158, 177, 196, 215, 234, 253, 255, 255, 255, 255, 42, 61,
543 80, 99, 117, 138, 157, 176, 195, 214, 233, 252, 255, 255, 255, 255, 41, 60, 79, 98, 117, 135, 156,
544 175, 194, 213, 232, 251, 255, 255, 255, 255, 40, 59, 78, 97, 116, 135, 135};
548 if (I2_check_dilated1 != I_magic_square_dilatation1_sse) {
552 unsigned char image_data2_dilated2[17 * 17] = {
553 192, 211, 230, 249, 255, 255, 255, 255, 255, 57, 76, 95, 114, 133, 152, 154, 154, 210, 229, 248, 255,
554 255, 255, 255, 255, 255, 75, 94, 113, 132, 151, 170, 172, 172, 228, 247, 255, 255, 255, 255, 255, 255,
555 74, 93, 112, 131, 150, 169, 171, 190, 190, 246, 255, 255, 255, 255, 255, 255, 73, 92, 111, 130, 149,
556 168, 187, 189, 208, 208, 255, 255, 255, 255, 255, 255, 72, 91, 110, 129, 148, 167, 186, 188, 207, 226,
557 226, 255, 255, 255, 255, 255, 71, 90, 109, 128, 147, 166, 185, 204, 206, 225, 244, 244, 255, 255, 255,
558 255, 70, 89, 108, 127, 146, 165, 184, 203, 205, 224, 243, 255, 255, 255, 255, 255, 69, 88, 107, 126,
559 145, 164, 183, 202, 221, 223, 242, 255, 255, 255, 255, 255, 85, 87, 106, 125, 144, 163, 182, 201, 220,
560 222, 241, 255, 255, 255, 255, 65, 84, 86, 105, 124, 143, 162, 181, 200, 219, 238, 240, 255, 255, 255,
561 255, 255, 83, 102, 104, 123, 142, 161, 180, 199, 218, 237, 239, 255, 255, 255, 255, 255, 255, 101, 103,
562 122, 141, 160, 179, 198, 217, 236, 255, 255, 255, 255, 255, 255, 255, 63, 119, 121, 140, 159, 178, 197,
563 216, 235, 254, 255, 255, 255, 255, 255, 255, 81, 81, 120, 139, 158, 177, 196, 215, 234, 253, 255, 255,
564 255, 255, 255, 255, 80, 99, 99, 138, 157, 176, 195, 214, 233, 252, 255, 255, 255, 255, 255, 255, 79,
565 98, 117, 117, 156, 175, 194, 213, 232, 251, 255, 255, 255, 255, 255, 255, 78, 97, 116, 135, 135, 156,
566 175, 194, 213, 232, 251, 255, 255, 255, 255, 255, 59, 78, 97, 116, 135, 135};
570 if (I2_check_dilated2 != I_magic_square_dilatation2_sse) {
574 unsigned char image_data2_eroded1[17 * 17] = {
575 174, 174, 193, 212, 231, 250, 255, 255, 38, 39, 39, 58, 77, 96, 115, 134, 153, 174, 192, 211, 230,
576 249, 255, 255, 37, 38, 38, 57, 76, 95, 114, 133, 152, 154, 192, 210, 229, 248, 255, 255, 36, 37,
577 37, 56, 75, 94, 113, 132, 151, 170, 172, 210, 228, 247, 255, 255, 36, 36, 36, 55, 74, 93, 112,
578 131, 150, 169, 172, 190, 228, 246, 255, 255, 51, 51, 36, 54, 73, 92, 111, 130, 149, 168, 187, 189,
579 208, 246, 255, 255, 50, 51, 51, 53, 72, 91, 110, 129, 148, 167, 186, 189, 207, 226, 255, 255, 49,
580 50, 50, 53, 71, 90, 109, 128, 147, 166, 185, 204, 206, 225, 244, 255, 48, 49, 49, 68, 70, 89,
581 108, 127, 146, 165, 184, 203, 206, 224, 243, 255, 47, 48, 48, 67, 70, 88, 107, 126, 145, 164, 183,
582 202, 221, 223, 242, 255, 255, 47, 47, 66, 85, 87, 106, 125, 144, 163, 182, 201, 220, 223, 241, 255,
583 255, 45, 47, 65, 84, 87, 105, 124, 143, 162, 181, 200, 219, 238, 240, 255, 255, 45, 45, 65, 83,
584 102, 104, 123, 142, 161, 180, 199, 218, 237, 240, 255, 255, 44, 45, 45, 83, 101, 104, 122, 141, 160,
585 179, 198, 217, 236, 255, 255, 255, 43, 44, 44, 63, 101, 119, 121, 140, 159, 178, 197, 216, 235, 254,
586 255, 255, 42, 43, 43, 62, 81, 119, 121, 139, 158, 177, 196, 215, 234, 253, 255, 255, 41, 42, 42,
587 61, 80, 99, 136, 138, 157, 176, 195, 214, 233, 252, 255, 255, 40, 41, 41, 60, 79, 98, 117, 138,
588 156, 175, 194, 213, 232, 251, 255, 255, 40, 40, 40, 59, 78, 97, 116, 135};
592 if (I2_check_eroded1 != I_magic_square_erosion1_sse) {
593 printMatrix(I_magic_square_erosion1_sse,
"I_magic_square_erosion1_sse");
598 unsigned char image_data2_eroded2[17 * 17] = {
599 192, 192, 211, 230, 249, 255, 255, 255, 57, 57, 57, 76, 95, 114, 133, 152, 154, 192, 192, 211, 230,
600 249, 255, 255, 74, 57, 57, 57, 76, 95, 114, 133, 152, 154, 210, 210, 229, 248, 255, 255, 73, 73,
601 73, 74, 75, 94, 113, 132, 151, 170, 172, 228, 228, 247, 255, 255, 72, 72, 72, 73, 74, 93, 112,
602 131, 150, 169, 171, 190, 246, 246, 255, 255, 71, 71, 71, 72, 73, 92, 111, 130, 149, 168, 187, 189,
603 208, 255, 255, 255, 70, 70, 70, 71, 72, 91, 110, 129, 148, 167, 186, 188, 207, 226, 255, 255, 69,
604 69, 69, 70, 71, 90, 109, 128, 147, 166, 185, 204, 206, 225, 244, 255, 85, 69, 69, 69, 70, 89,
605 108, 127, 146, 165, 184, 203, 205, 224, 243, 255, 65, 65, 69, 69, 69, 88, 107, 126, 145, 164, 183,
606 202, 221, 223, 242, 255, 255, 65, 65, 84, 85, 87, 106, 125, 144, 163, 182, 201, 220, 222, 241, 255,
607 255, 255, 65, 65, 84, 86, 105, 124, 143, 162, 181, 200, 219, 238, 240, 255, 255, 63, 63, 83, 83,
608 102, 104, 123, 142, 161, 180, 199, 218, 237, 239, 255, 255, 81, 63, 63, 101, 101, 103, 122, 141, 160,
609 179, 198, 217, 236, 255, 255, 255, 80, 80, 63, 63, 119, 119, 121, 140, 159, 178, 197, 216, 235, 254,
610 255, 255, 79, 79, 79, 80, 81, 120, 120, 139, 158, 177, 196, 215, 234, 253, 255, 255, 78, 78, 78,
611 79, 80, 99, 138, 138, 157, 176, 195, 214, 233, 252, 255, 255, 59, 59, 59, 78, 79, 98, 117, 156,
612 156, 175, 194, 213, 232, 251, 255, 255, 255, 59, 59, 59, 78, 97, 116, 135};
616 if (I2_check_eroded2 != I_magic_square_erosion2_sse) {
620 std::cout << std::endl;
630 (
unsigned char)1, (
unsigned char)1,
true);
637 for (
int cpt = 0; cpt < nbIterations; cpt++) {
644 for (
int cpt = 0; cpt < nbIterations; cpt++) {
649 std::cout <<
"(I_Klimt_binarized_dilatation1 == " 650 "I_Klimt_binarized_dilatation1_sse)? " 651 << (I_Klimt_binarized_dilatation1 == I_Klimt_binarized_dilatation1_sse) <<
" ; t=" << t
652 <<
" ms ; t_sse=" << t_sse <<
" ms" 653 <<
" ; speed-up=" << (t / t_sse) <<
"X" << std::endl;
660 for (
int cpt = 0; cpt < nbIterations; cpt++) {
667 for (
int cpt = 0; cpt < nbIterations; cpt++) {
672 std::cout <<
"(I_Klimt_binarized_dilatation2 == " 673 "I_Klimt_binarized_dilatation2_sse)? " 674 << (I_Klimt_binarized_dilatation2 == I_Klimt_binarized_dilatation2_sse) <<
" ; t=" << t
675 <<
" ms ; t_sse=" << t_sse <<
" ms" 676 <<
" ; speed-up=" << (t / t_sse) <<
"X" << std::endl;
683 for (
int cpt = 0; cpt < nbIterations; cpt++) {
690 for (
int cpt = 0; cpt < nbIterations; cpt++) {
695 std::cout <<
"(I_Klimt_binarized_erosion1 == I_Klimt_binarized_erosion1_sse)? " 696 << (I_Klimt_binarized_erosion1 == I_Klimt_binarized_erosion1_sse) <<
" ; t=" << t
697 <<
" ms ; t_sse=" << t_sse <<
" ms" 698 <<
" ; speed-up=" << (t / t_sse) <<
"X" << std::endl;
705 for (
int cpt = 0; cpt < nbIterations; cpt++) {
712 for (
int cpt = 0; cpt < nbIterations; cpt++) {
717 std::cout <<
"(I_Klimt_binarized_erosion2 == I_Klimt_binarized_erosion2_sse)? " 718 << (I_Klimt_binarized_erosion2 == I_Klimt_binarized_erosion2_sse) <<
" ; t=" << t
719 <<
" ms ; t_sse=" << t_sse <<
" ms" 720 <<
" ; speed-up=" << (t / t_sse) <<
"X" << std::endl;
730 for (
int cpt = 0; cpt < nbIterations; cpt++) {
736 for (
int cpt = 0; cpt < nbIterations; cpt++) {
741 std::cout <<
"(I_Klimt_dilatation1 == I_Klimt_dilatation1_sse)? " 742 << (I_Klimt_dilatation1 == I_Klimt_dilatation1_sse) <<
" ; t=" << t <<
" ms ; t_sse=" << t_sse <<
" ms" 743 <<
" ; speed-up=" << (t / t_sse) <<
"X" << std::endl;
750 for (
int cpt = 0; cpt < nbIterations; cpt++) {
756 for (
int cpt = 0; cpt < nbIterations; cpt++) {
761 std::cout <<
"(I_Klimt_dilatation2 == I_Klimt_dilatation2_sse)? " 762 << (I_Klimt_dilatation2 == I_Klimt_dilatation2_sse) <<
" ; t=" << t <<
" ms ; t_sse=" << t_sse <<
" ms" 763 <<
" ; speed-up=" << (t / t_sse) <<
"X" << std::endl;
770 for (
int cpt = 0; cpt < nbIterations; cpt++) {
776 for (
int cpt = 0; cpt < nbIterations; cpt++) {
781 std::cout <<
"(I_Klimt_erosion1 == I_Klimt_erosion1_sse)? " << (I_Klimt_erosion1 == I_Klimt_erosion1_sse)
782 <<
" ; t=" << t <<
" ms ; t_sse=" << t_sse <<
" ms" 783 <<
" ; speed-up=" << (t / t_sse) <<
"X" << std::endl;
790 for (
int cpt = 0; cpt < nbIterations; cpt++) {
796 for (
int cpt = 0; cpt < nbIterations; cpt++) {
801 std::cout <<
"(I_Klimt_erosion2 == I_Klimt_erosion2_sse)? " << (I_Klimt_erosion2 == I_Klimt_erosion2_sse)
802 <<
" ; t=" << t <<
" ms ; t_sse=" << t_sse <<
" ms" 803 <<
" ; speed-up=" << (t / t_sse) <<
"X" << std::endl;
806 #if (VISP_HAVE_OPENCV_VERSION >= 0x030000) 807 std::cout << std::endl;
809 cv::Mat cross_SE = cv::getStructuringElement(cv::MORPH_CROSS, cv::Size(3, 3));
810 cv::Mat rect_SE = cv::getStructuringElement(cv::MORPH_RECT, cv::Size(3, 3));
813 cv::Mat matImg_dilatation1;
817 for (
int cpt = 0; cpt < nbIterations; cpt++) {
818 cv::morphologyEx(matImg_dilatation1, matImg_dilatation1, cv::MORPH_DILATE, cross_SE);
824 std::cout <<
"(I_matImg_dilatation1 == I_Klimt_dilatation1_sse)? " 825 << (I_matImg_dilatation1 == I_Klimt_dilatation1_sse) <<
" ; t_opencv=" << t_opencv <<
" ms" << std::endl;
828 cv::Mat matImg_dilatation2;
832 for (
int cpt = 0; cpt < nbIterations; cpt++) {
833 cv::morphologyEx(matImg_dilatation2, matImg_dilatation2, cv::MORPH_DILATE, rect_SE);
839 std::cout <<
"(I_matImg_dilatation2 == I_Klimt_dilatation2_sse)? " 840 << (I_matImg_dilatation2 == I_Klimt_dilatation2_sse) <<
" ; t_opencv=" << t_opencv <<
" ms" << std::endl;
843 cv::Mat matImg_erosion1;
847 for (
int cpt = 0; cpt < nbIterations; cpt++) {
848 cv::morphologyEx(matImg_erosion1, matImg_erosion1, cv::MORPH_ERODE, cross_SE);
854 std::cout <<
"(I_matImg_erosion1 == I_Klimt_erosion1_sse)? " << (I_matImg_erosion1 == I_Klimt_erosion1_sse)
855 <<
" ; t_opencv=" << t_opencv <<
" ms" << std::endl;
858 cv::Mat matImg_erosion2;
862 for (
int cpt = 0; cpt < nbIterations; cpt++) {
863 cv::morphologyEx(matImg_erosion2, matImg_erosion2, cv::MORPH_ERODE, rect_SE);
869 std::cout <<
"(I_matImg_erosion2 == I_Klimt_erosion2_sse)? " << (I_matImg_erosion2 == I_Klimt_erosion2_sse)
870 <<
" ; t_opencv=" << t_opencv <<
" ms" << std::endl;
875 std::cout <<
"\nCatch an exception: " << e << std::endl;
879 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