40 #include <visp3/core/vpConfig.h>
42 #if defined(VISP_HAVE_CATCH2)
43 #define CATCH_CONFIG_RUNNER
46 #include <visp3/core/vpImageConvert.h>
47 #include <visp3/core/vpIoTools.h>
48 #include <visp3/core/vpEndian.h>
49 #include <visp3/io/vpImageIo.h>
51 #ifdef ENABLE_VISP_NAMESPACE
55 static const double maxMeanPixelError = 1.5;
56 static const unsigned int width = 223, height = 151;
58 TEST_CASE(
"Gray to RGBa conversion",
"[image_conversion]")
60 SECTION(
"Image 1x16 (SSE41 aligned=true)")
62 unsigned int h = 1, w = 16;
64 common_tools::fill(gray);
67 common_tools::grayToRGBaRef(gray.bitmap,
reinterpret_cast<unsigned char *
>(rgba_ref.bitmap), gray.getSize());
71 CHECK((rgba == rgba_ref));
73 SECTION(
"Image 1x17 (SSE41 aligned=false)")
75 unsigned int h = 1, w = 17;
77 common_tools::fill(gray);
80 common_tools::grayToRGBaRef(gray.bitmap,
reinterpret_cast<unsigned char *
>(rgba_ref.bitmap), gray.getSize());
84 CHECK((rgba == rgba_ref));
86 SECTION(
"Image 1x32 (AVX2 aligned=true)")
88 unsigned int h = 1, w = 32;
90 common_tools::fill(gray);
93 common_tools::grayToRGBaRef(gray.bitmap,
reinterpret_cast<unsigned char *
>(rgba_ref.bitmap), gray.getSize());
97 CHECK((rgba == rgba_ref));
99 SECTION(
"Image 1x33 (AVX2 aligned=false)")
101 unsigned int h = 1, w = 33;
103 common_tools::fill(gray);
106 common_tools::grayToRGBaRef(gray.bitmap,
reinterpret_cast<unsigned char *
>(rgba_ref.bitmap), gray.getSize());
110 CHECK((rgba == rgba_ref));
112 SECTION(
"Image 4x64 (general aligned = true")
114 unsigned int h = 4, w = 64;
116 common_tools::fill(gray);
119 common_tools::grayToRGBaRef(gray.bitmap,
reinterpret_cast<unsigned char *
>(rgba_ref.bitmap), gray.getSize());
123 CHECK((rgba == rgba_ref));
125 SECTION(
"Image 5x65 (general aligned = false")
127 unsigned int h = 5, w = 65;
129 common_tools::fill(gray);
132 common_tools::grayToRGBaRef(gray.bitmap,
reinterpret_cast<unsigned char *
>(rgba_ref.bitmap), gray.getSize());
136 CHECK((rgba == rgba_ref));
140 TEST_CASE(
"RGBa to Gray conversion",
"[image_conversion]")
142 SECTION(
"Image 1x16 (SSE41 aligned=true)")
144 unsigned int h = 1, w = 16;
146 common_tools::fill(rgba);
149 common_tools::RGBaToGrayRef(
reinterpret_cast<unsigned char *
>(rgba.
bitmap), gray_ref.bitmap, rgba.
getSize());
154 CHECK(common_tools::almostEqual(gray_ref, gray, maxMeanPixelError, error));
155 std::cout <<
"RGBa to Gray conversion, mean error: " << error <<
" max allowed: " << maxMeanPixelError << std::endl;
157 SECTION(
"Image 1x17 (SSE41 aligned=false)")
159 unsigned int h = 1, w = 17;
161 common_tools::fill(rgba);
164 common_tools::RGBaToGrayRef(
reinterpret_cast<unsigned char *
>(rgba.
bitmap), gray_ref.bitmap, rgba.
getSize());
169 CHECK(common_tools::almostEqual(gray_ref, gray, maxMeanPixelError, error));
170 std::cout <<
"RGBa to Gray conversion, mean error: " << error <<
" max allowed: " << maxMeanPixelError << std::endl;
172 SECTION(
"Image 1x32 (AVX2 aligned=true)")
174 unsigned int h = 1, w = 32;
176 common_tools::fill(rgba);
179 common_tools::RGBaToGrayRef(
reinterpret_cast<unsigned char *
>(rgba.
bitmap), gray_ref.bitmap, rgba.
getSize());
184 CHECK(common_tools::almostEqual(gray_ref, gray, maxMeanPixelError, error));
185 std::cout <<
"RGBa to Gray conversion, mean error: " << error <<
" max allowed: " << maxMeanPixelError << std::endl;
187 SECTION(
"Image 1x33 (AVX2 aligned=false)")
189 unsigned int h = 1, w = 33;
191 common_tools::fill(rgba);
194 common_tools::RGBaToGrayRef(
reinterpret_cast<unsigned char *
>(rgba.
bitmap), gray_ref.bitmap, rgba.
getSize());
199 CHECK(common_tools::almostEqual(gray_ref, gray, maxMeanPixelError, error));
200 std::cout <<
"RGBa to Gray conversion, mean error: " << error <<
" max allowed: " << maxMeanPixelError << std::endl;
202 SECTION(
"Image 4x64 (general aligned = true")
204 unsigned int h = 4, w = 64;
206 common_tools::fill(rgba);
209 common_tools::RGBaToGrayRef(
reinterpret_cast<unsigned char *
>(rgba.
bitmap), gray_ref.bitmap, rgba.
getSize());
214 CHECK(common_tools::almostEqual(gray_ref, gray, maxMeanPixelError, error));
215 std::cout <<
"RGBa to Gray conversion, mean error: " << error <<
" max allowed: " << maxMeanPixelError << std::endl;
217 SECTION(
"Image 5x65 (general aligned = false")
219 unsigned int h = 5, w = 65;
221 common_tools::fill(rgba);
224 common_tools::RGBaToGrayRef(
reinterpret_cast<unsigned char *
>(rgba.
bitmap), gray_ref.bitmap, rgba.
getSize());
229 CHECK(common_tools::almostEqual(gray_ref, gray, maxMeanPixelError, error));
230 std::cout <<
"RGBa to Gray conversion, mean error: " << error <<
" max allowed: " << maxMeanPixelError << std::endl;
234 TEST_CASE(
"RGB to Gray conversion",
"[image_conversion]")
236 SECTION(
"Image 1x16 (SSE41 aligned=true)")
238 unsigned int h = 1, w = 16;
239 std::vector<unsigned char> rgb(h * w * 3);
240 common_tools::fill(rgb);
243 common_tools::RGBToGrayRef(rgb.data(), gray_ref.bitmap, gray_ref.getWidth(), gray_ref.getHeight(),
false);
248 CHECK(common_tools::almostEqual(gray_ref, gray, maxMeanPixelError, error));
249 std::cout <<
"RGB to Gray conversion 1, mean error: " << error <<
" max allowed: " << maxMeanPixelError << std::endl;
253 CHECK(common_tools::almostEqual(gray_ref, gray2, maxMeanPixelError, error));
254 std::cout <<
"RGB to Gray conversion 2, mean error: " << error <<
" max allowed: " << maxMeanPixelError << std::endl;
256 SECTION(
"Image 1x17 (SSE41 aligned=false)")
258 unsigned int h = 1, w = 17;
259 std::vector<unsigned char> rgb(h * w * 3);
260 common_tools::fill(rgb);
263 common_tools::RGBToGrayRef(rgb.data(), gray_ref.bitmap, gray_ref.getWidth(), gray_ref.getHeight(),
false);
268 CHECK(common_tools::almostEqual(gray_ref, gray, maxMeanPixelError, error));
269 std::cout <<
"RGB to Gray conversion 1, mean error: " << error <<
" max allowed: " << maxMeanPixelError << std::endl;
273 CHECK(common_tools::almostEqual(gray_ref, gray2, maxMeanPixelError, error));
274 std::cout <<
"RGB to Gray conversion 2, mean error: " << error <<
" max allowed: " << maxMeanPixelError << std::endl;
276 SECTION(
"Image 1x32 (AVX2 aligned=true)")
278 unsigned int h = 1, w = 32;
279 std::vector<unsigned char> rgb(h * w * 3);
280 common_tools::fill(rgb);
283 common_tools::RGBToGrayRef(rgb.data(), gray_ref.bitmap, gray_ref.getWidth(), gray_ref.getHeight(),
false);
288 CHECK(common_tools::almostEqual(gray_ref, gray, maxMeanPixelError, error));
289 std::cout <<
"RGB to Gray conversion 1, mean error: " << error <<
" max allowed: " << maxMeanPixelError << std::endl;
292 CHECK(common_tools::almostEqual(gray_ref, gray2, maxMeanPixelError, error));
293 std::cout <<
"RGB to Gray conversion 2, mean error: " << error <<
" max allowed: " << maxMeanPixelError << std::endl;
295 SECTION(
"Image 1x33 (AVX2 aligned=false)")
297 unsigned int h = 1, w = 33;
298 std::vector<unsigned char> rgb(h * w * 3);
299 common_tools::fill(rgb);
302 common_tools::RGBToGrayRef(rgb.data(), gray_ref.bitmap, gray_ref.getWidth(), gray_ref.getHeight(),
false);
307 CHECK(common_tools::almostEqual(gray_ref, gray, maxMeanPixelError, error));
308 std::cout <<
"RGB to Gray conversion 1, mean error: " << error <<
" max allowed: " << maxMeanPixelError << std::endl;
312 CHECK(common_tools::almostEqual(gray_ref, gray2, maxMeanPixelError, error));
313 std::cout <<
"RGB to Gray conversion 2, mean error: " << error <<
" max allowed: " << maxMeanPixelError << std::endl;
315 SECTION(
"Image 4x64 (general aligned = true")
317 unsigned int h = 4, w = 64;
318 std::vector<unsigned char> rgb(h * w * 3);
319 common_tools::fill(rgb);
322 common_tools::RGBToGrayRef(rgb.data(), gray_ref.bitmap, gray_ref.getWidth(), gray_ref.getHeight(),
false);
327 CHECK(common_tools::almostEqual(gray_ref, gray, maxMeanPixelError, error));
328 std::cout <<
"RGB to Gray conversion 1, mean error: " << error <<
" max allowed: " << maxMeanPixelError << std::endl;
332 CHECK(common_tools::almostEqual(gray_ref, gray2, maxMeanPixelError, error));
333 std::cout <<
"RGB to Gray conversion 2, mean error: " << error <<
" max allowed: " << maxMeanPixelError << std::endl;
335 SECTION(
"Image 5x65 (general aligned = false")
337 unsigned int h = 5, w = 65;
338 std::vector<unsigned char> rgb(h * w * 3);
339 common_tools::fill(rgb);
342 common_tools::RGBToGrayRef(rgb.data(), gray_ref.bitmap, gray_ref.getWidth(), gray_ref.getHeight(),
false);
347 CHECK(common_tools::almostEqual(gray_ref, gray, maxMeanPixelError, error));
348 std::cout <<
"RGB to Gray conversion 1, mean error: " << error <<
" max allowed: " << maxMeanPixelError << std::endl;
352 CHECK(common_tools::almostEqual(gray_ref, gray2, maxMeanPixelError, error));
353 std::cout <<
"RGB to Gray conversion 2, mean error: " << error <<
" max allowed: " << maxMeanPixelError << std::endl;
357 TEST_CASE(
"RGB <==> RGBa conversion",
"[image_conversion]")
359 SECTION(
"Image 1x16 (SSE41 aligned=true)")
361 unsigned int h = 1, w = 16;
363 common_tools::fill(rgba_ref);
365 std::vector<unsigned char> rgb(h * w * 3);
371 CHECK((rgba == rgba_ref));
373 SECTION(
"Image 1x17 (SSE41 aligned=false)")
375 unsigned int h = 1, w = 17;
377 common_tools::fill(rgba_ref);
379 std::vector<unsigned char> rgb(h * w * 3);
385 CHECK((rgba == rgba_ref));
387 SECTION(
"Image 1x32 (AVX2 aligned=true)")
389 unsigned int h = 1, w = 32;
391 common_tools::fill(rgba_ref);
393 std::vector<unsigned char> rgb(h * w * 3);
399 CHECK((rgba == rgba_ref));
401 SECTION(
"Image 1x33 (AVX2 aligned=false)")
403 unsigned int h = 1, w = 33;
405 common_tools::fill(rgba_ref);
407 std::vector<unsigned char> rgb(h * w * 3);
413 CHECK((rgba == rgba_ref));
415 SECTION(
"Image 4x64 (general aligned = true")
417 unsigned int h = 4, w = 64;
419 common_tools::fill(rgba_ref);
421 std::vector<unsigned char> rgb(h * w * 3);
427 CHECK((rgba == rgba_ref));
429 SECTION(
"Image 5x65 (general aligned = false")
431 unsigned int h = 5, w = 65;
433 common_tools::fill(rgba_ref);
435 std::vector<unsigned char> rgb(h * w * 3);
441 CHECK((rgba == rgba_ref));
445 TEST_CASE(
"BGR to Gray conversion",
"[image_conversion]")
447 SECTION(
"Image 1x16 (SSE41 aligned=true)")
449 unsigned int h = 1, w = 16;
451 common_tools::fill(rgba_ref);
456 std::vector<unsigned char> bgr;
457 common_tools::RGBaToBGR(rgba_ref, bgr);
463 CHECK(common_tools::almostEqual(gray_ref, gray, maxMeanPixelError, error));
464 std::cout <<
"BGR to Gray conversion, mean error: " << error <<
" max allowed: " << maxMeanPixelError << std::endl;
466 SECTION(
"Image 1x17 (SSE41 aligned=false)")
468 unsigned int h = 1, w = 17;
470 common_tools::fill(rgba_ref);
475 std::vector<unsigned char> bgr;
476 common_tools::RGBaToBGR(rgba_ref, bgr);
482 CHECK(common_tools::almostEqual(gray_ref, gray, maxMeanPixelError, error));
483 std::cout <<
"BGR to Gray conversion, mean error: " << error <<
" max allowed: " << maxMeanPixelError << std::endl;
485 SECTION(
"Image 1x32 (AVX2 aligned=true)")
487 unsigned int h = 1, w = 32;
489 common_tools::fill(rgba_ref);
494 std::vector<unsigned char> bgr;
495 common_tools::RGBaToBGR(rgba_ref, bgr);
501 CHECK(common_tools::almostEqual(gray_ref, gray, maxMeanPixelError, error));
502 std::cout <<
"BGR to Gray conversion, mean error: " << error <<
" max allowed: " << maxMeanPixelError << std::endl;
504 SECTION(
"Image 1x33 (AVX2 aligned=false)")
506 unsigned int h = 1, w = 33;
508 common_tools::fill(rgba_ref);
513 std::vector<unsigned char> bgr;
514 common_tools::RGBaToBGR(rgba_ref, bgr);
520 CHECK(common_tools::almostEqual(gray_ref, gray, maxMeanPixelError, error));
521 std::cout <<
"BGR to Gray conversion, mean error: " << error <<
" max allowed: " << maxMeanPixelError << std::endl;
523 SECTION(
"Image 4x64 (general aligned = true")
525 unsigned int h = 4, w = 64;
527 common_tools::fill(rgba_ref);
532 std::vector<unsigned char> bgr;
533 common_tools::RGBaToBGR(rgba_ref, bgr);
539 CHECK(common_tools::almostEqual(gray_ref, gray, maxMeanPixelError, error));
540 std::cout <<
"BGR to Gray conversion, mean error: " << error <<
" max allowed: " << maxMeanPixelError << std::endl;
542 SECTION(
"Image 5x65 (general aligned = false")
544 unsigned int h = 5, w = 65;
546 common_tools::fill(rgba_ref);
551 std::vector<unsigned char> bgr;
552 common_tools::RGBaToBGR(rgba_ref, bgr);
558 CHECK(common_tools::almostEqual(gray_ref, gray, maxMeanPixelError, error));
559 std::cout <<
"BGR to Gray conversion, mean error: " << error <<
" max allowed: " << maxMeanPixelError << std::endl;
563 TEST_CASE(
"BGRa to Gray conversion",
"[image_conversion]")
565 SECTION(
"Image 1x16 (SSE41 aligned=true)")
567 unsigned int h = 1, w = 16;
569 common_tools::fill(rgba_ref);
574 std::vector<unsigned char> bgra;
575 common_tools::RGBaToBGRa(rgba_ref, bgra);
581 CHECK(common_tools::almostEqual(gray_ref, gray, maxMeanPixelError, error));
582 std::cout <<
"BGRa to Gray conversion, mean error: " << error <<
" max allowed: " << maxMeanPixelError << std::endl;
584 SECTION(
"Image 1x17 (SSE41 aligned=false)")
586 unsigned int h = 1, w = 17;
588 common_tools::fill(rgba_ref);
593 std::vector<unsigned char> bgra;
594 common_tools::RGBaToBGRa(rgba_ref, bgra);
600 CHECK(common_tools::almostEqual(gray_ref, gray, maxMeanPixelError, error));
601 std::cout <<
"BGRa to Gray conversion, mean error: " << error <<
" max allowed: " << maxMeanPixelError << std::endl;
603 SECTION(
"Image 1x32 (AVX2 aligned=true)")
605 unsigned int h = 1, w = 32;
607 common_tools::fill(rgba_ref);
612 std::vector<unsigned char> bgra;
613 common_tools::RGBaToBGRa(rgba_ref, bgra);
619 CHECK(common_tools::almostEqual(gray_ref, gray, maxMeanPixelError, error));
620 std::cout <<
"BGRa to Gray conversion, mean error: " << error <<
" max allowed: " << maxMeanPixelError << std::endl;
622 SECTION(
"Image 1x33 (AVX2 aligned=false)")
624 unsigned int h = 1, w = 33;
626 common_tools::fill(rgba_ref);
631 std::vector<unsigned char> bgra;
632 common_tools::RGBaToBGRa(rgba_ref, bgra);
638 CHECK(common_tools::almostEqual(gray_ref, gray, maxMeanPixelError, error));
639 std::cout <<
"BGRa to Gray conversion, mean error: " << error <<
" max allowed: " << maxMeanPixelError << std::endl;
641 SECTION(
"Image 4x64 (general aligned = true")
643 unsigned int h = 4, w = 64;
645 common_tools::fill(rgba_ref);
650 std::vector<unsigned char> bgra;
651 common_tools::RGBaToBGRa(rgba_ref, bgra);
657 CHECK(common_tools::almostEqual(gray_ref, gray, maxMeanPixelError, error));
658 std::cout <<
"BGRa to Gray conversion, mean error: " << error <<
" max allowed: " << maxMeanPixelError << std::endl;
660 SECTION(
"Image 5x65 (general aligned = false")
662 unsigned int h = 5, w = 65;
664 common_tools::fill(rgba_ref);
669 std::vector<unsigned char> bgra;
670 common_tools::RGBaToBGRa(rgba_ref, bgra);
676 CHECK(common_tools::almostEqual(gray_ref, gray, maxMeanPixelError, error));
677 std::cout <<
"BGRa to Gray conversion, mean error: " << error <<
" max allowed: " << maxMeanPixelError << std::endl;
681 TEST_CASE(
"BGRa to RGBa conversion",
"[image_conversion]")
683 SECTION(
"Image 1x16 (SSE41 aligned=true)")
685 unsigned int h = 1, w = 16;
687 common_tools::fill(rgba_ref);
689 std::vector<unsigned char> bgra_ref;
690 common_tools::RGBaToBGRa(rgba_ref, bgra_ref);
696 CHECK(common_tools::almostEqual(rgba_ref, rgba, maxMeanPixelError, error));
697 std::cout <<
"BGRa to RGBa conversion, mean error: " << error <<
" max allowed: " << maxMeanPixelError << std::endl;
699 SECTION(
"Image 1x17 (SSE41 aligned=false)")
701 unsigned int h = 1, w = 17;
703 common_tools::fill(rgba_ref);
705 std::vector<unsigned char> bgra_ref;
706 common_tools::RGBaToBGRa(rgba_ref, bgra_ref);
712 CHECK(common_tools::almostEqual(rgba_ref, rgba, maxMeanPixelError, error));
713 std::cout <<
"BGRa to RGBa conversion, mean error: " << error <<
" max allowed: " << maxMeanPixelError << std::endl;
715 SECTION(
"Image 1x32 (AVX2 aligned=true)")
717 unsigned int h = 1, w = 32;
719 common_tools::fill(rgba_ref);
721 std::vector<unsigned char> bgra_ref;
722 common_tools::RGBaToBGRa(rgba_ref, bgra_ref);
728 CHECK(common_tools::almostEqual(rgba_ref, rgba, maxMeanPixelError, error));
729 std::cout <<
"BGRa to RGBa conversion, mean error: " << error <<
" max allowed: " << maxMeanPixelError << std::endl;
731 SECTION(
"Image 1x33 (AVX2 aligned=false)")
733 unsigned int h = 1, w = 33;
735 common_tools::fill(rgba_ref);
737 std::vector<unsigned char> bgra_ref;
738 common_tools::RGBaToBGRa(rgba_ref, bgra_ref);
744 CHECK(common_tools::almostEqual(rgba_ref, rgba, maxMeanPixelError, error));
745 std::cout <<
"BGRa to RGBa conversion, mean error: " << error <<
" max allowed: " << maxMeanPixelError << std::endl;
747 SECTION(
"Image 4x64 (general aligned = true")
749 unsigned int h = 4, w = 64;
751 common_tools::fill(rgba_ref);
753 std::vector<unsigned char> bgra_ref;
754 common_tools::RGBaToBGRa(rgba_ref, bgra_ref);
760 CHECK(common_tools::almostEqual(rgba_ref, rgba, maxMeanPixelError, error));
761 std::cout <<
"BGRa to RGBa conversion, mean error: " << error <<
" max allowed: " << maxMeanPixelError << std::endl;
763 SECTION(
"Image 5x65 (general aligned = false")
765 unsigned int h = 5, w = 65;
767 common_tools::fill(rgba_ref);
769 std::vector<unsigned char> bgra_ref;
770 common_tools::RGBaToBGRa(rgba_ref, bgra_ref);
776 CHECK(common_tools::almostEqual(rgba_ref, rgba, maxMeanPixelError, error));
777 std::cout <<
"BGRa to RGBa conversion, mean error: " << error <<
" max allowed: " << maxMeanPixelError << std::endl;
781 TEST_CASE(
"Split <==> Merge conversion",
"[image_conversion]")
784 common_tools::fill(rgba_ref);
792 CHECK((rgba == rgba_ref));
795 #if defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_IMGPROC)
796 TEST_CASE(
"OpenCV Mat <==> vpImage conversion",
"[image_conversion]")
798 SECTION(
"CV_8UC3 to vpRGBa")
800 cv::Mat img(height, width, CV_8UC3);
801 common_tools::fill(img);
804 common_tools::BGRToRGBaRef(img.data,
reinterpret_cast<unsigned char *
>(rgba_ref.bitmap), img.cols, img.rows,
false);
808 CHECK((rgba_ref == rgba));
811 SECTION(
"CV_8UC1 to vpRGBa")
813 cv::Mat img(height, width, CV_8UC1);
814 common_tools::fill(img);
817 common_tools::grayToRGBaRef(img.data,
reinterpret_cast<unsigned char *
>(rgba_ref.bitmap), height * width);
821 CHECK((rgba_ref == rgba));
824 SECTION(
"CV_8UC3 to unsigned char")
826 cv::Mat img(height, width, CV_8UC3);
827 common_tools::fill(img);
830 common_tools::BGRToGrayRef(img.data, gray_ref.
bitmap, img.cols, img.rows,
false);
835 CHECK(common_tools::almostEqual(gray_ref, gray, maxMeanPixelError, error));
836 std::cout <<
"BGR to Gray conversion, mean error: " << error <<
" max allowed: " << maxMeanPixelError << std::endl;
839 SECTION(
"CV_8UC1 to unsigned char")
841 cv::Mat img(height, width, CV_8UC1);
842 common_tools::fill(img);
850 for (
int i = 0; i < img.rows; i++) {
851 for (
int j = 0; j < img.cols; j++) {
852 REQUIRE(img.at<uchar>(i, j) == gray[i][j]);
857 SECTION(
"CV_16UC1 to uint16_t")
860 unsigned int w = 3, h = 3;
861 cv::Mat img = (cv::Mat_<uint16_t>(h, w) << 65, 650, 6500, 65000, 60000, 6000, 600, 60, 6);
868 for (
int i = 0; i < img.rows; i++) {
869 for (
int j = 0; j < img.cols; j++) {
870 REQUIRE(img.at<uint16_t>(i, j) == gray16[i][j]);
875 cv::Mat img_col1 = img.col(1);
880 REQUIRE(gray16_col1.
getWidth() == 1);
882 for (
int i = 0; i < img_col1.rows; i++) {
883 for (
int j = 0; j < img_col1.cols; j++) {
884 REQUIRE(img_col1.at<uint16_t>(i, j) == gray16_col1[i][j]);
891 #if (VISP_HAVE_DATASET_VERSION >= 0x030500)
892 void col2im(
const std::vector<uint8_t> &buffer,
vpImage<uint8_t> &I_Bayer_8U)
894 for (
unsigned int i = 0; i < I_Bayer_8U.
getHeight(); i++) {
895 for (
unsigned int j = 0; j < I_Bayer_8U.
getWidth(); j++) {
896 I_Bayer_8U[i][j] = buffer[j * I_Bayer_8U.
getHeight() + i];
901 static void col2im(
const std::vector<uint16_t> &buffer,
vpImage<uint16_t> &I_Bayer_16U)
903 for (
unsigned int i = 0; i < I_Bayer_16U.
getHeight(); i++) {
904 for (
unsigned int j = 0; j < I_Bayer_16U.
getWidth(); j++) {
905 I_Bayer_16U[i][j] = buffer[j * I_Bayer_16U.
getHeight() + i];
912 for (
unsigned int i = 0; i < I_RGBA_8U.
getHeight(); i++) {
913 for (
unsigned int j = 0; j < I_RGBA_8U.
getWidth(); j++) {
915 vpMath::saturate<unsigned char>(I_RGBA_16U[0][(i * I_RGBA_8U.
getWidth() + j) * 4 + 0] / (
float)divisor),
916 vpMath::saturate<unsigned char>(I_RGBA_16U[0][(i * I_RGBA_8U.
getWidth() + j) * 4 + 1] / (
float)divisor),
917 vpMath::saturate<unsigned char>(I_RGBA_16U[0][(i * I_RGBA_8U.
getWidth() + j) * 4 + 2] / (
float)divisor));
925 for (
unsigned int i = 0; i < I_RGBA_8U.
getHeight(); i++) {
926 for (
unsigned int j = 0; j < I_RGBA_8U.
getWidth(); j++) {
927 vpColVector err = I_RGBA_8U[i][j] - I_RGBA_8U_ref[i][j];
933 return 10 * std::log10(255 * 255 / mse);
936 static bool readBinaryFile(
const std::string &filename, std::vector<uint16_t> &buffer)
938 std::FILE *f = std::fopen(filename.c_str(),
"rb");
944 size_t sread = std::fread(&buffer[0],
sizeof buffer[0], buffer.size(), f);
945 REQUIRE(sread == buffer.size());
947 #ifdef VISP_BIG_ENDIAN
948 std::vector<uint16_t> tmp = buffer;
949 for (
size_t i = 0; i < tmp.size(); i++) {
957 static bool readBinaryFile(
const std::string &filename, std::vector<uint8_t> &buffer)
959 std::FILE *f = std::fopen(filename.c_str(),
"rb");
965 size_t sread = std::fread(&buffer[0],
sizeof buffer[0], buffer.size(), f);
966 REQUIRE(sread == buffer.size());
972 TEST_CASE(
"Bayer conversion",
"[image_conversion]")
980 const double min_PSNR_bilinear = 21, min_PSNR_Malvar = 24;
984 std::vector<uint16_t> buffer(height * width);
990 const std::string filename =
992 if (readBinaryFile(filename, buffer)) {
993 col2im(buffer, I_Bayer_16U);
1000 convertTo(I_RGBA_16U, I_RGBA_8U);
1001 double PSNR = computePSNR(I_RGBA_8U, I_RGBA_8U_ref);
1002 std::cout <<
"16-bit - BGGR - Bilinear - PSNR: " << PSNR <<
" min required: " << min_PSNR_bilinear << std::endl;
1003 CHECK(PSNR >= min_PSNR_bilinear);
1011 convertTo(I_RGBA_16U, I_RGBA_8U);
1012 double PSNR = computePSNR(I_RGBA_8U, I_RGBA_8U_ref);
1013 std::cout <<
"16-bit - BGGR - Malvar - PSNR: " << PSNR <<
" min required: " << min_PSNR_Malvar << std::endl;
1014 CHECK(PSNR >= min_PSNR_Malvar);
1021 const std::string filename =
1023 if (readBinaryFile(filename, buffer)) {
1024 col2im(buffer, I_Bayer_16U);
1031 convertTo(I_RGBA_16U, I_RGBA_8U);
1032 double PSNR = computePSNR(I_RGBA_8U, I_RGBA_8U_ref);
1033 std::cout <<
"16-bit - GBRG - Bilinear - PSNR: " << PSNR <<
" min required: " << min_PSNR_bilinear << std::endl;
1034 CHECK(PSNR >= min_PSNR_bilinear);
1042 convertTo(I_RGBA_16U, I_RGBA_8U);
1043 double PSNR = computePSNR(I_RGBA_8U, I_RGBA_8U_ref);
1044 std::cout <<
"16-bit - GBRG - Malvar - PSNR: " << PSNR <<
" min required: " << min_PSNR_Malvar << std::endl;
1045 CHECK(PSNR >= min_PSNR_Malvar);
1052 const std::string filename =
1054 if (readBinaryFile(filename, buffer)) {
1055 col2im(buffer, I_Bayer_16U);
1062 convertTo(I_RGBA_16U, I_RGBA_8U);
1063 double PSNR = computePSNR(I_RGBA_8U, I_RGBA_8U_ref);
1064 std::cout <<
"16-bit - GRBG - Bilinear - PSNR: " << PSNR <<
" min required: " << min_PSNR_bilinear << std::endl;
1065 CHECK(PSNR >= min_PSNR_bilinear);
1073 convertTo(I_RGBA_16U, I_RGBA_8U);
1074 double PSNR = computePSNR(I_RGBA_8U, I_RGBA_8U_ref);
1075 std::cout <<
"16-bit - GRBG - Malvar - PSNR: " << PSNR <<
" min required: " << min_PSNR_Malvar << std::endl;
1076 CHECK(PSNR >= min_PSNR_Malvar);
1083 const std::string filename =
1085 if (readBinaryFile(filename, buffer)) {
1086 col2im(buffer, I_Bayer_16U);
1093 convertTo(I_RGBA_16U, I_RGBA_8U);
1094 double PSNR = computePSNR(I_RGBA_8U, I_RGBA_8U_ref);
1095 std::cout <<
"16-bit - RGGB - Bilinear - PSNR: " << PSNR <<
" min required: " << min_PSNR_bilinear << std::endl;
1096 CHECK(PSNR >= min_PSNR_bilinear);
1104 convertTo(I_RGBA_16U, I_RGBA_8U);
1105 double PSNR = computePSNR(I_RGBA_8U, I_RGBA_8U_ref);
1106 std::cout <<
"16-bit - RGGB - Malvar - PSNR: " << PSNR <<
" min required: " << min_PSNR_Malvar << std::endl;
1107 CHECK(PSNR >= min_PSNR_Malvar);
1115 std::vector<uint8_t> buffer(height * width);
1121 const std::string filename =
1124 if (readBinaryFile(filename, buffer)) {
1125 col2im(buffer, I_Bayer_8U);
1132 double PSNR = computePSNR(I_RGBA_8U, I_RGBA_8U_ref);
1133 std::cout <<
"8-bit - BGGR - Bilinear - PSNR: " << PSNR <<
" min required: " << min_PSNR_bilinear << std::endl;
1134 CHECK(PSNR >= min_PSNR_bilinear);
1142 double PSNR = computePSNR(I_RGBA_8U, I_RGBA_8U_ref);
1143 std::cout <<
"8-bit - BGGR - Malvar - PSNR: " << PSNR <<
" min required: " << min_PSNR_Malvar << std::endl;
1144 CHECK(PSNR >= min_PSNR_Malvar);
1151 const std::string filename =
1154 if (readBinaryFile(filename, buffer)) {
1155 col2im(buffer, I_Bayer_8U);
1162 double PSNR = computePSNR(I_RGBA_8U, I_RGBA_8U_ref);
1163 std::cout <<
"8-bit - GBRG - Bilinear - PSNR: " << PSNR <<
" min required: " << min_PSNR_bilinear << std::endl;
1164 CHECK(PSNR >= min_PSNR_bilinear);
1172 double PSNR = computePSNR(I_RGBA_8U, I_RGBA_8U_ref);
1173 std::cout <<
"8-bit - GBRG - Malvar - PSNR: " << PSNR <<
" min required: " << min_PSNR_Malvar << std::endl;
1174 CHECK(PSNR >= min_PSNR_Malvar);
1181 const std::string filename =
1184 if (readBinaryFile(filename, buffer)) {
1185 col2im(buffer, I_Bayer_8U);
1192 double PSNR = computePSNR(I_RGBA_8U, I_RGBA_8U_ref);
1193 std::cout <<
"8-bit - GRBG - Bilinear - PSNR: " << PSNR <<
" min required: " << min_PSNR_bilinear << std::endl;
1194 CHECK(PSNR >= min_PSNR_bilinear);
1202 double PSNR = computePSNR(I_RGBA_8U, I_RGBA_8U_ref);
1203 std::cout <<
"8-bit - GRBG - Malvar - PSNR: " << PSNR <<
" min required: " << min_PSNR_Malvar << std::endl;
1204 CHECK(PSNR >= min_PSNR_Malvar);
1211 const std::string filename =
1214 if (readBinaryFile(filename, buffer)) {
1215 col2im(buffer, I_Bayer_8U);
1222 double PSNR = computePSNR(I_RGBA_8U, I_RGBA_8U_ref);
1223 std::cout <<
"8-bit - RGGB - Bilinear - PSNR: " << PSNR <<
" min required: " << min_PSNR_bilinear << std::endl;
1224 CHECK(PSNR >= min_PSNR_bilinear);
1232 double PSNR = computePSNR(I_RGBA_8U, I_RGBA_8U_ref);
1233 std::cout <<
"8-bit - RGGB - Malvar - PSNR: " << PSNR <<
" min required: " << min_PSNR_Malvar << std::endl;
1234 CHECK(PSNR >= min_PSNR_Malvar);
1242 template<
typename Type>
1243 bool test_hsv(
const std::vector<Type> &hue,
const std::vector<Type> &saturation,
1244 const std::vector<Type> &value,
const std::vector< std::vector<unsigned char> > &rgb_truth,
1245 const std::vector< std::vector<double> > &hsv_truth,
size_t step,
size_t size,
double max_range)
1248 for (
size_t i = 0; i < size; ++i) {
1249 if (((hue[i]*max_range) !=
static_cast<Type
>(hsv_truth[i][0])) ||
1250 ((saturation[i]*max_range) !=
static_cast<Type
>(hsv_truth[i][1])) ||
1251 ((value[i]*max_range) !=
static_cast<Type
>(hsv_truth[i][2]))) {
1253 std::cout <<
"Error in rgb to hsv conversion for rgb (";
1256 std::cout <<
"Error in rgba to hsv conversion for rgba (";
1258 std::cout << static_cast<int>(rgb_truth[i][0]) <<
","
1259 <<
static_cast<int>(rgb_truth[i][1]) <<
","
1260 <<
static_cast<int>(rgb_truth[i][2]) <<
"): Expected hsv value: ("
1261 <<
static_cast<int>(hsv_truth[i][0]) <<
","
1262 <<
static_cast<int>(hsv_truth[i][1]) <<
","
1263 <<
static_cast<int>(hsv_truth[i][2]) <<
") converted value: ("
1264 <<
static_cast<int>(hue[i]) <<
","
1265 <<
static_cast<int>(saturation[i]) <<
","
1266 <<
static_cast<int>(value[i]) <<
")" << std::endl;
1273 bool test_rgb(
const std::vector<unsigned char> &rgb,
const std::vector< std::vector<unsigned char> > rgb_truth,
1274 const std::vector< std::vector<double> > &hsv_truth,
size_t step,
size_t size,
double epsilon = 0.)
1278 for (
size_t i = 0; i < size; ++i) {
1279 if ((!
vpMath::equal(rgb[i*step], rgb_truth[i][0], epsilon)) ||
1280 (!
vpMath::equal(rgb[i*step+1], rgb_truth[i][1], epsilon)) ||
1281 (!
vpMath::equal(rgb[i*step+2], rgb_truth[i][2], epsilon))) {
1282 std::cout <<
"Error in hsv to rgb conversion for hsv ("
1283 <<
static_cast<int>(hsv_truth[i][0]) <<
","
1284 <<
static_cast<int>(hsv_truth[i][1]) <<
","
1285 <<
static_cast<int>(hsv_truth[i][2]) <<
"): Expected rgb value: ("
1286 <<
static_cast<int>(rgb_truth[i][0]) <<
","
1287 <<
static_cast<int>(rgb_truth[i][1]) <<
","
1288 <<
static_cast<int>(rgb_truth[i][2]) <<
") converted value: ("
1289 <<
static_cast<int>(rgb[i*step]) <<
","
1290 <<
static_cast<int>(rgb[(i*step)+1]) <<
","
1291 <<
static_cast<int>(rgb[(i*step)+2]) <<
") epsilon: " << epsilon << std::endl;
1297 for (
size_t i = 0; i < size; ++i) {
1298 if ((rgb[i*step] != rgb_truth[i][0]) || (rgb[i*step+1] != rgb_truth[i][1]) || (rgb[i*step+2] != rgb_truth[i][2])) {
1299 std::cout <<
"Error in hsv to rgb conversion for hsv ("
1300 <<
static_cast<int>(hsv_truth[i][0]) <<
","
1301 <<
static_cast<int>(hsv_truth[i][1]) <<
","
1302 <<
static_cast<int>(hsv_truth[i][2]) <<
"): Expected rgb value: ("
1303 <<
static_cast<int>(rgb_truth[i][0]) <<
","
1304 <<
static_cast<int>(rgb_truth[i][1]) <<
","
1305 <<
static_cast<int>(rgb_truth[i][2]) <<
") converted value: ("
1306 <<
static_cast<int>(rgb[i*step]) <<
","
1307 <<
static_cast<int>(rgb[(i*step)+1]) <<
","
1308 <<
static_cast<int>(rgb[(i*step)+2]) <<
")" << std::endl;
1317 TEST_CASE(
"RGB to HSV conversion",
"[image_conversion]")
1319 std::vector< std::vector<unsigned char> > rgb_truth;
1320 rgb_truth.push_back({ 0, 0, 0 });
1321 rgb_truth.push_back({ 255, 255, 255 });
1322 rgb_truth.push_back({ 255, 0, 0 });
1323 rgb_truth.push_back({ 0, 255, 0 });
1324 rgb_truth.push_back({ 0, 0, 255 });
1325 rgb_truth.push_back({ 255, 255, 0 });
1326 rgb_truth.push_back({ 0, 255, 255 });
1327 rgb_truth.push_back({ 255, 0, 255 });
1328 rgb_truth.push_back({ 128, 128, 128 });
1329 rgb_truth.push_back({ 128, 128, 0 });
1330 rgb_truth.push_back({ 128, 0, 0 });
1331 rgb_truth.push_back({ 0, 128, 0 });
1332 rgb_truth.push_back({ 0, 128, 128 });
1333 rgb_truth.push_back({ 0, 0, 128 });
1334 rgb_truth.push_back({ 128, 0, 128 });
1339 for (
size_t test = 0; test < 2; ++test) {
1348 std::vector< std::vector<double> > hsv_truth;
1350 hsv_truth.push_back({ 0, 0, 0 });
1351 hsv_truth.push_back({ 0, 0, 255 });
1352 hsv_truth.push_back({ 0, 255, 255 });
1353 hsv_truth.push_back({ h_max * 120 / 360, 255, 255 });
1354 hsv_truth.push_back({ h_max * 240 / 360, 255, 255 });
1355 hsv_truth.push_back({ h_max * 60 / 360, 255, 255 });
1356 hsv_truth.push_back({ h_max * 180 / 360, 255, 255 });
1357 hsv_truth.push_back({ h_max * 300 / 360, 255, 255 });
1358 hsv_truth.push_back({ 0, 0, 128 });
1359 hsv_truth.push_back({ h_max * 60 / 360, 255, 128 });
1360 hsv_truth.push_back({ 0, 255, 128 });
1361 hsv_truth.push_back({ h_max * 120 / 360, 255, 128 });
1362 hsv_truth.push_back({ h_max * 180 / 360, 255, 128 });
1363 hsv_truth.push_back({ h_max * 240 / 360, 255, 128 });
1364 hsv_truth.push_back({ h_max * 300 / 360, 255, 128 });
1366 size_t size = rgb_truth.size();
1368 std::vector<unsigned char> rgb_truth_continuous;
1369 for (
size_t i = 0; i < size; ++i) {
1370 for (
size_t j = 0; j < rgb_truth[i].size(); ++j) {
1371 rgb_truth_continuous.push_back(rgb_truth[i][j]);
1374 std::vector<unsigned char> rgba_truth_continuous;
1375 for (
size_t i = 0; i < size; ++i) {
1376 for (
size_t j = 0; j < rgb_truth[i].size(); ++j) {
1377 rgba_truth_continuous.push_back(rgb_truth[i][j]);
1381 SECTION(
"RGB -> HSV (unsigned char) -> RGB")
1383 std::vector<unsigned char> hue(size);
1384 std::vector<unsigned char> saturation(size);
1385 std::vector<unsigned char> value(size);
1386 std::cout <<
"Test rgb -> hsv (unsigned char) conversion with h full scale: " << (h_full ?
"yes" :
"no") << std::endl;
1388 reinterpret_cast<unsigned char *
>(&hue.front()),
1389 reinterpret_cast<unsigned char *
>(&saturation.front()),
1390 reinterpret_cast<unsigned char *
>(&value.front()),
static_cast<unsigned int>(size), h_full);
1391 CHECK(test_hsv(hue, saturation, value, rgb_truth, hsv_truth, 3, size, 1.));
1393 std::cout <<
"Test hsv (unsigned char) -> rgb conversion with h full scale: " << (h_full ?
"yes" :
"no") << std::endl;
1394 std::vector< unsigned char> rgb_continuous(rgb_truth_continuous.size() * 3);
1395 vpImageConvert::HSVToRGB(&hue.front(), &saturation.front(), &value.front(), &rgb_continuous.front(),
static_cast<unsigned int>(size), h_full);
1396 CHECK(test_rgb(rgb_continuous, rgb_truth, hsv_truth, 3, size, 5.));
1398 SECTION(
"RGBa -> HSV (unsigned char) -> RGBa")
1400 std::vector<unsigned char> hue(size);
1401 std::vector<unsigned char> saturation(size);
1402 std::vector<unsigned char> value(size);
1403 std::cout <<
"Test rgba -> hsv (unsigned char) conversion with h full scale: " << (h_full ?
"yes" :
"no") << std::endl;
1405 reinterpret_cast<unsigned char *
>(&hue.front()),
1406 reinterpret_cast<unsigned char *
>(&saturation.front()),
1407 reinterpret_cast<unsigned char *
>(&value.front()),
static_cast<unsigned int>(size), h_full);
1408 CHECK(test_hsv(hue, saturation, value, rgb_truth, hsv_truth, 4, size, 1.));
1410 std::cout <<
"Test hsv (unsigned char) -> rgba conversion with h full scale: " << (h_full ?
"yes" :
"no") << std::endl;
1411 std::vector< unsigned char> rgba_continuous(rgb_truth_continuous.size() * 4);
1412 vpImageConvert::HSVToRGBa(&hue.front(), &saturation.front(), &value.front(), &rgba_continuous.front(),
static_cast<unsigned int>(size), h_full);
1413 CHECK(test_rgb(rgba_continuous, rgb_truth, hsv_truth, 4, size, 5.));
1416 SECTION(
"RGB -> HSV (double) -> RGB")
1418 std::vector<double> hue(size);
1419 std::vector<double> saturation(size);
1420 std::vector<double> value(size);
1421 std::cout <<
"Test rgb -> hsv (double) conversion" << std::endl;
1423 reinterpret_cast<double *
>(&hue.front()),
1424 reinterpret_cast<double *
>(&saturation.front()),
1425 reinterpret_cast<double *
>(&value.front()),
static_cast<unsigned int>(size));
1426 CHECK(test_hsv(hue, saturation, value, rgb_truth, hsv_truth, 3, size, 255.));
1428 std::cout <<
"Test hsv (double) -> rgb conversion" << std::endl;
1429 std::vector< unsigned char> rgb_continuous(rgb_truth_continuous.size());
1430 vpImageConvert::HSVToRGB(&hue.front(), &saturation.front(), &value.front(), &rgb_continuous.front(),
static_cast<unsigned int>(size));
1431 CHECK(test_rgb(rgb_continuous, rgb_truth, hsv_truth, 3, size));
1436 SECTION(
"RGBa -> HSV (double) -> RGBa")
1438 std::vector<double> hue(size);
1439 std::vector<double> saturation(size);
1440 std::vector<double> value(size);
1441 std::cout <<
"Test rgba -> hsv (double) conversion" << std::endl;
1443 reinterpret_cast<double *
>(&hue.front()),
1444 reinterpret_cast<double *
>(&saturation.front()),
1445 reinterpret_cast<double *
>(&value.front()),
static_cast<unsigned int>(size));
1446 CHECK(test_hsv(hue, saturation, value, rgb_truth, hsv_truth, 4, size, 255.));
1448 std::cout <<
"Test hsv (double) -> rgba conversion" << std::endl;
1449 std::vector< unsigned char> rgba_continuous(rgb_truth_continuous.size()*4);
1450 vpImageConvert::HSVToRGBa(&hue.front(), &saturation.front(), &value.front(), &rgba_continuous.front(),
static_cast<unsigned int>(size));
1451 CHECK(test_rgb(rgba_continuous, rgb_truth, hsv_truth, 4, size));
1457 int main(
int argc,
char *argv[])
1459 Catch::Session session;
1462 session.applyCommandLine(argc, argv);
1464 int numFailed = session.run();
1469 std::cout << (numFailed ?
"Test failed" :
"Test succeed") << std::endl;
1473 int main() {
return EXIT_SUCCESS; }
Implementation of column vector and the associated operations.
static void HSVToRGBa(const double *hue, const double *saturation, const double *value, unsigned char *rgba, unsigned int size)
static void demosaicBGGRToRGBaBilinear(const uint8_t *bggr, uint8_t *rgba, unsigned int width, unsigned int height, unsigned int nThreads=0)
static void demosaicGRBGToRGBaBilinear(const uint8_t *grbg, uint8_t *rgba, unsigned int width, unsigned int height, unsigned int nThreads=0)
static void RGBToHSV(const unsigned char *rgb, double *hue, double *saturation, double *value, unsigned int size)
static void demosaicGRBGToRGBaMalvar(const uint8_t *grbg, uint8_t *rgba, unsigned int width, unsigned int height, unsigned int nThreads=0)
static void demosaicGBRGToRGBaMalvar(const uint8_t *gbrg, uint8_t *rgba, unsigned int width, unsigned int height, unsigned int nThreads=0)
static void merge(const vpImage< unsigned char > *R, const vpImage< unsigned char > *G, const vpImage< unsigned char > *B, const vpImage< unsigned char > *a, vpImage< vpRGBa > &RGBa)
static void demosaicBGGRToRGBaMalvar(const uint8_t *bggr, uint8_t *rgba, unsigned int width, unsigned int height, unsigned int nThreads=0)
static void demosaicGBRGToRGBaBilinear(const uint8_t *gbrg, uint8_t *rgba, unsigned int width, unsigned int height, unsigned int nThreads=0)
static void split(const vpImage< vpRGBa > &src, vpImage< unsigned char > *pR, vpImage< unsigned char > *pG, vpImage< unsigned char > *pB, vpImage< unsigned char > *pa=nullptr)
static void RGBaToHSV(const unsigned char *rgba, double *hue, double *saturation, double *value, unsigned int size)
static void demosaicRGGBToRGBaMalvar(const uint8_t *rggb, uint8_t *rgba, unsigned int width, unsigned int height, unsigned int nThreads=0)
static void convert(const vpImage< unsigned char > &src, vpImage< vpRGBa > &dest)
static void RGBToGrey(unsigned char *rgb, unsigned char *grey, unsigned int width, unsigned int height, bool flip=false)
static void RGBToRGBa(unsigned char *rgb, unsigned char *rgba, unsigned int size)
static void BGRaToGrey(unsigned char *bgra, unsigned char *grey, unsigned int width, unsigned int height, bool flip=false, unsigned int nThreads=0)
static void BGRToGrey(unsigned char *bgr, unsigned char *grey, unsigned int width, unsigned int height, bool flip=false, unsigned int nThreads=0)
static void demosaicRGGBToRGBaBilinear(const uint8_t *rggb, uint8_t *rgba, unsigned int width, unsigned int height, unsigned int nThreads=0)
static void BGRaToRGBa(unsigned char *bgra, unsigned char *rgba, unsigned int width, unsigned int height, bool flip=false)
static void RGBaToRGB(unsigned char *rgba, unsigned char *rgb, unsigned int size)
static void HSVToRGB(const double *hue, const double *saturation, const double *value, unsigned char *rgb, unsigned int size)
static void read(vpImage< unsigned char > &I, const std::string &filename, int backend=IO_DEFAULT_BACKEND)
unsigned int getWidth() const
unsigned int getSize() const
Type * bitmap
points toward the bitmap
unsigned int getHeight() const
static double sqr(double x)
static bool equal(double x, double y, double threshold=0.001)
VISP_EXPORT uint16_t swap16bits(uint16_t val)