49 #include "private/vpBayerConversion.h"
50 #include "private/vpImageConvert_impl.h"
51 #include <Simd/SimdLib.hpp>
52 #include <visp3/core/vpImageConvert.h>
54 bool vpImageConvert::YCbCrLUTcomputed =
false;
55 int vpImageConvert::vpCrr[256];
56 int vpImageConvert::vpCgb[256];
57 int vpImageConvert::vpCgr[256];
58 int vpImageConvert::vpCbb[256];
105 for (
unsigned int i = 0; i < max_xy; i++) {
106 float val = 255.f * (src.
bitmap[i] - min) / (max - min);
112 dest.
bitmap[i] = (
unsigned char)val;
128 for (
unsigned int i = 0; i < src.
getHeight(); i++) {
129 for (
unsigned int j = 0; j < src.
getWidth(); j++) {
130 for (
unsigned int c = 0; c < 3; c++) {
131 float val = 255.f * (
reinterpret_cast<const float *
>(&(src[i][j]))[c] -
reinterpret_cast<float *
>(&min)[c]) /
132 (
reinterpret_cast<float *
>(&max)[c] -
reinterpret_cast<float *
>(&min)[c]);
134 reinterpret_cast<unsigned char *
>(&(dest[i][j]))[c] = 0;
136 reinterpret_cast<unsigned char *
>(&(dest[i][j]))[c] = 255;
138 reinterpret_cast<unsigned char *
>(&(dest[i][j]))[c] = (
unsigned char)val;
170 for (
unsigned int i = 0; i < max_xy; i++) {
171 double val = 255. * (src.
bitmap[i] - min) / (max - min);
177 dest.
bitmap[i] = (
unsigned char)val;
191 for (
unsigned int i = 0; i < src.
getSize(); i++)
192 dest.
bitmap[i] =
static_cast<unsigned char>(src.
bitmap[i] >> bitshift);
205 for (
unsigned int i = 0; i < src.
getSize(); i++)
206 dest.
bitmap[i] =
static_cast<unsigned char>(src.
bitmap[i] << bitshift);
230 vp_createDepthHistogram(src_depth, dest_rgba);
241 vp_createDepthHistogram(src_depth, dest_depth);
253 vp_createDepthHistogram(src_depth, dest_rgba);
264 vp_createDepthHistogram(src_depth, dest_depth);
267 #ifdef VISP_HAVE_OPENCV
316 int nChannel = src->nChannels;
317 int depth = src->depth;
318 int height = src->height;
319 int width = src->width;
320 int widthStep = src->widthStep;
321 int lineStep = (flip) ? 1 : 0;
323 if (nChannel == 3 && depth == 8) {
324 dest.
resize((
unsigned int)height, (
unsigned int)width);
327 unsigned char *input = (
unsigned char *)src->imageData;
328 unsigned char *beginOutput = (
unsigned char *)dest.
bitmap;
330 for (
int i = 0; i < height; i++) {
331 unsigned char *line = input;
332 unsigned char *output = beginOutput + lineStep * (4 * width * (height - 1 - i)) + (1 - lineStep) * 4 * width * i;
333 for (
int j = 0; j < width; j++) {
334 *(output++) = *(line + 2);
335 *(output++) = *(line + 1);
336 *(output++) = *(line);
344 }
else if (nChannel == 1 && depth == 8) {
345 dest.
resize((
unsigned int)height, (
unsigned int)width);
347 unsigned char *input = (
unsigned char *)src->imageData;
348 unsigned char *beginOutput = (
unsigned char *)dest.
bitmap;
350 for (
int i = 0; i < height; i++) {
351 unsigned char *line = input;
352 unsigned char *output = beginOutput + lineStep * (4 * width * (height - 1 - i)) + (1 - lineStep) * 4 * width * i;
353 for (
int j = 0; j < width; j++) {
411 int nChannel = src->nChannels;
412 int depth = src->depth;
413 int height = src->height;
414 int width = src->width;
415 int widthStep = src->widthStep;
416 int lineStep = (flip) ? 1 : 0;
419 if (widthStep == width) {
420 if (nChannel == 1 && depth == 8) {
421 dest.
resize((
unsigned int)height, (
unsigned int)width);
422 memcpy(dest.
bitmap, src->imageData, (
size_t)(height * width));
424 if (nChannel == 3 && depth == 8) {
425 dest.
resize((
unsigned int)height, (
unsigned int)width);
426 BGRToGrey((
unsigned char *)src->imageData, dest.
bitmap, (
unsigned int)width, (
unsigned int)height,
false);
429 if (nChannel == 1 && depth == 8) {
430 dest.
resize((
unsigned int)height, (
unsigned int)width);
431 for (
int i = 0; i < height; i++) {
432 memcpy(dest.
bitmap + i * width, src->imageData + i * widthStep, (
size_t)width);
435 if (nChannel == 3 && depth == 8) {
436 dest.
resize((
unsigned int)height, (
unsigned int)width);
437 for (
int i = 0; i < height; i++) {
438 BGRToGrey((
unsigned char *)src->imageData + i * widthStep, dest.
bitmap + i * width, (
unsigned int)width, 1,
444 if (nChannel == 1 && depth == 8) {
445 dest.
resize((
unsigned int)height, (
unsigned int)width);
446 unsigned char *beginOutput = (
unsigned char *)dest.
bitmap;
447 for (
int i = 0; i < height; i++) {
448 memcpy(beginOutput + lineStep * (4 * width * (height - 1 - i)), src->imageData + i * widthStep, (
size_t)width);
451 if (nChannel == 3 && depth == 8) {
452 dest.
resize((
unsigned int)height, (
unsigned int)width);
454 BGRToGrey((
unsigned char *)src->imageData , dest.
bitmap , (
unsigned int)width,
455 (
unsigned int)height ,
true);
508 CvSize size = cvSize(width, height);
512 if (dest->nChannels != channels || dest->depth != depth || dest->height != height || dest->width != width) {
513 if (dest->nChannels != 0)
514 cvReleaseImage(&dest);
515 dest = cvCreateImage(size, depth, channels);
518 dest = cvCreateImage(size, depth, channels);
521 unsigned char *input = (
unsigned char *)src.
bitmap;
522 unsigned char *output = (
unsigned char *)dest->imageData;
526 int widthStep = dest->widthStep;
528 for (i = 0; i < height; i++) {
529 output = (
unsigned char *)dest->imageData + i * widthStep;
530 unsigned char *line = input;
531 for (j = 0; j < width; j++) {
532 *output++ = *(line + 2);
533 *output++ = *(line + 1);
589 unsigned int width = src.
getWidth();
590 CvSize size = cvSize((
int)width, (
int)height);
594 if (dest->nChannels != channels || dest->depth != depth || dest->height != (
int)height ||
595 dest->width != (
int)width) {
596 if (dest->nChannels != 0)
597 cvReleaseImage(&dest);
598 dest = cvCreateImage(size, depth, channels);
601 dest = cvCreateImage(size, depth, channels);
603 unsigned int widthStep = (
unsigned int)dest->widthStep;
605 if (width == widthStep) {
606 memcpy(dest->imageData, src.
bitmap, width * height);
609 for (
unsigned int i = 0; i < height; i++) {
610 memcpy(dest->imageData + i * widthStep, src.
bitmap + i * width, width);
615 #if VISP_HAVE_OPENCV_VERSION >= 0x020100
665 dest.
resize((
unsigned int)src.rows, (
unsigned int)src.cols);
667 if (src.type() == CV_8UC4) {
669 for (
unsigned int i = 0; i < dest.
getRows(); ++i)
670 for (
unsigned int j = 0; j < dest.
getCols(); ++j) {
671 cv::Vec4b tmp = src.at<cv::Vec4b>((int)i, (
int)j);
677 dest[dest.
getRows() - i - 1][j] = rgbaVal;
679 dest[i][j] = rgbaVal;
681 }
else if (src.type() == CV_8UC3) {
682 if (src.isContinuous() && !flip) {
683 SimdRgbToBgra(src.data, src.cols, src.rows, src.step[0],
reinterpret_cast<uint8_t *
>(dest.
bitmap),
688 for (
unsigned int i = 0; i < dest.
getRows(); ++i) {
689 for (
unsigned int j = 0; j < dest.
getCols(); ++j) {
690 cv::Vec3b tmp = src.at<cv::Vec3b>((int)i, (
int)j);
695 dest[dest.
getRows() - i - 1][j] = rgbaVal;
697 dest[i][j] = rgbaVal;
702 }
else if (src.type() == CV_8UC1) {
703 if (src.isContinuous() && !flip) {
704 SimdGrayToBgra(src.data, src.cols, src.rows, src.step[0],
reinterpret_cast<uint8_t *
>(dest.
bitmap),
708 for (
unsigned int i = 0; i < dest.
getRows(); ++i) {
709 for (
unsigned int j = 0; j < dest.
getCols(); ++j) {
710 rgbaVal = src.at<
unsigned char>((int)i, (
int)j);
712 dest[dest.
getRows() - i - 1][j] = rgbaVal;
714 dest[i][j] = rgbaVal;
766 if (src.type() == CV_8UC1) {
767 dest.
resize((
unsigned int)src.rows, (
unsigned int)src.cols);
768 if (src.isContinuous() && !flip) {
769 memcpy(dest.
bitmap, src.data, (
size_t)(src.rows * src.cols));
772 for (
unsigned int i = 0; i < dest.
getRows(); ++i) {
773 memcpy(dest.
bitmap + i * dest.
getCols(), src.data + (dest.
getRows() - i - 1) * src.step1(), (
size_t)src.step);
776 for (
unsigned int i = 0; i < dest.
getRows(); ++i) {
777 memcpy(dest.
bitmap + i * dest.
getCols(), src.data + i * src.step1(), (
size_t)src.step);
781 }
else if (src.type() == CV_8UC3) {
782 dest.
resize((
unsigned int)src.rows, (
unsigned int)src.cols);
783 if (src.isContinuous()) {
784 BGRToGrey((
unsigned char *)src.data, (
unsigned char *)dest.
bitmap, (
unsigned int)src.cols, (
unsigned int)src.rows,
788 for (
unsigned int i = 0; i < dest.
getRows(); ++i) {
789 BGRToGrey((
unsigned char *)src.data + i * src.step1(),
791 (
unsigned int)dest.
getCols(), 1,
false);
794 for (
unsigned int i = 0; i < dest.
getRows(); ++i) {
796 (
unsigned int)dest.
getCols(), 1,
false);
800 }
else if (src.type() == CV_8UC4) {
801 dest.
resize((
unsigned int)src.rows, (
unsigned int)src.cols);
802 if (src.isContinuous()) {
803 BGRaToGrey((
unsigned char *)src.data, (
unsigned char *)dest.
bitmap, (
unsigned int)src.cols,
804 (
unsigned int)src.rows, flip, nThreads);
807 for (
unsigned int i = 0; i < dest.
getRows(); ++i) {
808 BGRaToGrey((
unsigned char *)src.data + i * src.step1(),
810 (
unsigned int)dest.
getCols(), 1,
false);
813 for (
unsigned int i = 0; i < dest.
getRows(); ++i) {
815 (
unsigned int)dest.
getCols(), 1,
false);
831 dest.
resize((
unsigned int)src.rows, (
unsigned int)src.cols);
833 if (src.type() == CV_32FC1) {
834 for (
unsigned int i = 0; i < dest.
getRows(); ++i)
835 for (
unsigned int j = 0; j < dest.
getCols(); ++j) {
837 dest[dest.
getRows() - i - 1][j] = src.at<
float>((int)i, (
int)j);
839 dest[i][j] = src.at<
float>((int)i, (
int)j);
855 dest.
resize((
unsigned int)src.rows, (
unsigned int)src.cols);
857 if (src.type() == CV_16UC1) {
858 if (src.isContinuous()) {
859 memcpy(dest.
bitmap, src.data, (
size_t)(src.rows * src.cols)*
sizeof(uint16_t));
862 for (
unsigned int i = 0; i < dest.
getRows(); ++i) {
863 memcpy(dest.
bitmap + i * dest.
getCols(), src.data + (dest.
getRows() - i - 1) * src.step1()*
sizeof(uint16_t), (
size_t)src.step);
866 for (
unsigned int i = 0; i < dest.
getRows(); ++i) {
867 memcpy(dest.
bitmap + i * dest.
getCols(), src.data + i * src.step1()*
sizeof(uint16_t), (
size_t)src.step);
886 dest.
resize((
unsigned int)src.rows, (
unsigned int)src.cols);
888 if (src.type() == CV_32FC3) {
890 for (
unsigned int i = 0; i < dest.
getRows(); ++i)
891 for (
unsigned int j = 0; j < dest.
getCols(); ++j) {
892 cv::Vec3f tmp = src.at<cv::Vec3f>((int)i, (
int)j);
897 dest[dest.
getRows() - i - 1][j] = rgbVal;
945 cv::cvtColor(vpToMat, dest, cv::COLOR_RGBA2BGR);
990 dest = tmpMap.clone();
1000 dest = tmpMap.clone();
1009 cv::cvtColor(vpToMat, dest, cv::COLOR_RGB2BGR);
1015 #ifdef VISP_HAVE_YARP
1100 dest.
resize(src->height(), src->width());
1102 memcpy(dest.
bitmap, src->getRawImage(), src->height() * src->width() *
sizeof(yarp::sig::PixelMono));
1104 dest.
bitmap = src->getRawImage();
1190 dest.
resize(src->height(), src->width());
1192 memcpy(dest.
bitmap, src->getRawImage(), src->height() * src->width() *
sizeof(yarp::sig::PixelRgba));
1194 dest.
bitmap =
static_cast<vpRGBa *
>(src->getRawImage());
1232 for (
unsigned int i = 0; i < src.
getRows(); i++) {
1233 for (
unsigned int j = 0; j < src.
getWidth(); j++) {
1234 dest->pixel(j, i).r = src[i][j].R;
1235 dest->pixel(j, i).g = src[i][j].G;
1236 dest->pixel(j, i).b = src[i][j].B;
1281 dest.
resize(src->height(), src->width());
1282 for (
int i = 0; i < src->height(); i++) {
1283 for (
int j = 0; j < src->width(); j++) {
1284 dest[i][j].R = src->pixel(j, i).r;
1285 dest[i][j].G = src->pixel(j, i).g;
1286 dest[i][j].B = src->pixel(j, i).b;
1318 int r, g, b, cr, cg, cb, y1, y2;
1328 cb = ((*s - 128) * 454) >> 8;
1329 cg = (*s++ - 128) * 88;
1331 cr = ((*s - 128) * 359) >> 8;
1332 cg = (cg + (*s++ - 128) * 183) >> 8;
1337 vpSAT(r) vpSAT(g) vpSAT(b)
1339 *d++ =
static_cast<unsigned char>(r);
1340 *d++ =
static_cast<unsigned char>(g);
1341 *d++ =
static_cast<unsigned char>(b);
1347 vpSAT(r) vpSAT(g) vpSAT(b)
1349 *d++ =
static_cast<unsigned char>(r);
1350 *d++ =
static_cast<unsigned char>(g);
1351 *d++ =
static_cast<unsigned char>(b);
1372 int r, g, b, cr, cg, cb, y1, y2;
1382 cb = ((*s - 128) * 454) >> 8;
1383 cg = (*s++ - 128) * 88;
1385 cr = ((*s - 128) * 359) >> 8;
1386 cg = (cg + (*s++ - 128) * 183) >> 8;
1391 vpSAT(r) vpSAT(g) vpSAT(b)
1393 *d++ =
static_cast<unsigned char>(r);
1394 *d++ =
static_cast<unsigned char>(g);
1395 *d++ =
static_cast<unsigned char>(b);
1400 vpSAT(r) vpSAT(g) vpSAT(b)
1402 *d++ =
static_cast<unsigned char>(r);
1403 *d++ =
static_cast<unsigned char>(g);
1404 *d++ =
static_cast<unsigned char>(b);
1421 unsigned int i = 0, j = 0;
1423 while (j < size * 2) {
1424 grey[i++] = yuyv[j];
1425 grey[i++] = yuyv[j + 2];
1443 for (
unsigned int i = size / 4; i; i--) {
1444 int U = (int)((*yuv++ - 128) * 0.354);
1448 int V = (int)((*yuv++ - 128) * 0.707);
1476 *rgba++ = (
unsigned char)R;
1477 *rgba++ = (
unsigned char)G;
1478 *rgba++ = (
unsigned char)B;
1500 *rgba++ = (
unsigned char)R;
1501 *rgba++ = (
unsigned char)G;
1502 *rgba++ = (
unsigned char)B;
1524 *rgba++ = (
unsigned char)R;
1525 *rgba++ = (
unsigned char)G;
1526 *rgba++ = (
unsigned char)B;
1548 *rgba++ = (
unsigned char)R;
1549 *rgba++ = (
unsigned char)G;
1550 *rgba++ = (
unsigned char)B;
1555 unsigned int i = 0, j = 0;
1556 unsigned char r, g, b;
1557 while (j < numpixels * 3 / 2) {
1559 YUVToRGB(yuv[j + 1], yuv[j], yuv[j + 3], r, g, b);
1566 YUVToRGB(yuv[j + 2], yuv[j], yuv[j + 3], r, g, b);
1573 YUVToRGB(yuv[j + 4], yuv[j], yuv[j + 3], r, g, b);
1580 YUVToRGB(yuv[j + 5], yuv[j], yuv[j + 3], r, g, b);
1609 for (
unsigned int i = size / 2; i; i--) {
1610 int U = (int)((*yuv++ - 128) * 0.354);
1613 int V = (int)((*yuv++ - 128) * 0.707);
1637 *rgba++ = (
unsigned char)R;
1638 *rgba++ = (
unsigned char)G;
1639 *rgba++ = (
unsigned char)B;
1661 *rgba++ = (
unsigned char)R;
1662 *rgba++ = (
unsigned char)G;
1663 *rgba++ = (
unsigned char)B;
1669 unsigned int i = 0, j = 0;
1670 unsigned char r, g, b;
1672 while (j < size * 2) {
1674 YUVToRGB(yuv[j + 1], yuv[j], yuv[j + 2], r, g, b);
1681 YUVToRGB(yuv[j + 3], yuv[j], yuv[j + 2], r, g, b);
1702 unsigned int i = 0, j = 0;
1703 while (j < size * 3 / 2) {
1704 grey[i] = yuv[j + 1];
1705 grey[i + 1] = yuv[j + 2];
1706 grey[i + 2] = yuv[j + 4];
1707 grey[i + 3] = yuv[j + 5];
1729 for (
unsigned int i = size / 2; i; i--) {
1730 int U = (int)((*yuv++ - 128) * 0.354);
1733 int V = (int)((*yuv++ - 128) * 0.707);
1757 *rgb++ = (
unsigned char)R;
1758 *rgb++ = (
unsigned char)G;
1759 *rgb++ = (
unsigned char)B;
1780 *rgb++ = (
unsigned char)R;
1781 *rgb++ = (
unsigned char)G;
1782 *rgb++ = (
unsigned char)B;
1787 unsigned int i = 0, j = 0;
1788 unsigned char r, g, b;
1790 while (j < size * 2) {
1792 YUVToRGB(yuv[j + 1], yuv[j], yuv[j + 2], r, g, b);
1798 YUVToRGB(yuv[j + 3], yuv[j], yuv[j + 2], r, g, b);
1820 unsigned int i = 0, j = 0;
1822 while (j < size * 2) {
1823 grey[i++] = yuv[j + 1];
1824 grey[i++] = yuv[j + 3];
1841 for (
unsigned int i = size / 4; i; i--) {
1842 int U = (int)((*yuv++ - 128) * 0.354);
1846 int V = (int)((*yuv++ - 128) * 0.707);
1874 *rgb++ = (
unsigned char)R;
1875 *rgb++ = (
unsigned char)G;
1876 *rgb++ = (
unsigned char)B;
1897 *rgb++ = (
unsigned char)R;
1898 *rgb++ = (
unsigned char)G;
1899 *rgb++ = (
unsigned char)B;
1920 *rgb++ = (
unsigned char)R;
1921 *rgb++ = (
unsigned char)G;
1922 *rgb++ = (
unsigned char)B;
1943 *rgb++ = (
unsigned char)R;
1944 *rgb++ = (
unsigned char)G;
1945 *rgb++ = (
unsigned char)B;
1950 unsigned int i = 0, j = 0;
1951 unsigned char r, g, b;
1953 while (j < size * 3 / 2) {
1954 YUVToRGB(yuv[j + 1], yuv[j], yuv[j + 3], r, g, b);
1960 YUVToRGB(yuv[j + 2], yuv[j], yuv[j + 3], r, g, b);
1966 YUVToRGB(yuv[j + 4], yuv[j], yuv[j + 3], r, g, b);
1972 YUVToRGB(yuv[j + 5], yuv[j], yuv[j + 3], r, g, b);
1997 int U, V, R, G, B, V2, U5, UV;
1999 unsigned int size = width * height;
2000 unsigned char *iU = yuv + size;
2001 unsigned char *iV = yuv + 5 * size / 4;
2002 for (
unsigned int i = 0; i < height / 2; i++) {
2003 for (
unsigned int j = 0; j < width / 2; j++) {
2004 U = (int)((*iU++ - 128) * 0.354);
2006 V = (int)((*iV++ - 128) * 0.707);
2011 yuv = yuv + width - 1;
2014 yuv = yuv - width + 1;
2038 *rgba++ = (
unsigned char)R;
2039 *rgba++ = (
unsigned char)G;
2040 *rgba++ = (
unsigned char)B;
2062 *rgba++ = (
unsigned char)R;
2063 *rgba++ = (
unsigned char)G;
2064 *rgba++ = (
unsigned char)B;
2066 rgba = rgba + 4 * width - 7;
2087 *rgba++ = (
unsigned char)R;
2088 *rgba++ = (
unsigned char)G;
2089 *rgba++ = (
unsigned char)B;
2111 *rgba++ = (
unsigned char)R;
2112 *rgba++ = (
unsigned char)G;
2113 *rgba++ = (
unsigned char)B;
2115 rgba = rgba - 4 * width + 1;
2133 int U, V, R, G, B, V2, U5, UV;
2135 unsigned int size = width * height;
2136 unsigned char *iU = yuv + size;
2137 unsigned char *iV = yuv + 5 * size / 4;
2138 for (
unsigned int i = 0; i < height / 2; i++) {
2139 for (
unsigned int j = 0; j < width / 2; j++) {
2140 U = (int)((*iU++ - 128) * 0.354);
2142 V = (int)((*iV++ - 128) * 0.707);
2147 yuv = yuv + width - 1;
2150 yuv = yuv - width + 1;
2174 *rgb++ = (
unsigned char)R;
2175 *rgb++ = (
unsigned char)G;
2176 *rgb++ = (
unsigned char)B;
2197 *rgb++ = (
unsigned char)R;
2198 *rgb++ = (
unsigned char)G;
2199 *rgb = (
unsigned char)B;
2200 rgb = rgb + 3 * width - 5;
2221 *rgb++ = (
unsigned char)R;
2222 *rgb++ = (
unsigned char)G;
2223 *rgb++ = (
unsigned char)B;
2244 *rgb++ = (
unsigned char)R;
2245 *rgb++ = (
unsigned char)G;
2246 *rgb = (
unsigned char)B;
2247 rgb = rgb - 3 * width + 1;
2263 for (
unsigned int i = 0; i < size; i++) {
2279 for (
unsigned int i = 0; i < size; i++) {
2280 int U = (int)((*yuv++ - 128) * 0.354);
2283 int V = (int)((*yuv++ - 128) * 0.707);
2309 *rgba++ = (
unsigned char)R;
2310 *rgba++ = (
unsigned char)G;
2311 *rgba++ = (
unsigned char)B;
2325 for (
unsigned int i = 0; i < size; i++) {
2326 int U = (int)((*yuv++ - 128) * 0.354);
2329 int V = (int)((*yuv++ - 128) * 0.707);
2355 *rgb++ = (
unsigned char)R;
2356 *rgb++ = (
unsigned char)G;
2357 *rgb++ = (
unsigned char)B;
2371 for (
unsigned int i = 0; i < size; i++) {
2390 int U, V, R, G, B, V2, U5, UV;
2392 unsigned int size = width * height;
2393 unsigned char *iV = yuv + size;
2394 unsigned char *iU = yuv + 5 * size / 4;
2395 for (
unsigned int i = 0; i < height / 2; i++) {
2396 for (
unsigned int j = 0; j < width / 2; j++) {
2397 U = (int)((*iU++ - 128) * 0.354);
2399 V = (int)((*iV++ - 128) * 0.707);
2404 yuv = yuv + width - 1;
2407 yuv = yuv - width + 1;
2431 *rgba++ = (
unsigned char)R;
2432 *rgba++ = (
unsigned char)G;
2433 *rgba++ = (
unsigned char)B;
2455 *rgba++ = (
unsigned char)R;
2456 *rgba++ = (
unsigned char)G;
2457 *rgba++ = (
unsigned char)B;
2459 rgba = rgba + 4 * width - 7;
2480 *rgba++ = (
unsigned char)R;
2481 *rgba++ = (
unsigned char)G;
2482 *rgba++ = (
unsigned char)B;
2504 *rgba++ = (
unsigned char)R;
2505 *rgba++ = (
unsigned char)G;
2506 *rgba++ = (
unsigned char)B;
2508 rgba = rgba - 4 * width + 1;
2526 int U, V, R, G, B, V2, U5, UV;
2528 unsigned int size = width * height;
2529 unsigned char *iV = yuv + size;
2530 unsigned char *iU = yuv + 5 * size / 4;
2531 for (
unsigned int i = 0; i < height / 2; i++) {
2532 for (
unsigned int j = 0; j < width / 2; j++) {
2533 U = (int)((*iU++ - 128) * 0.354);
2535 V = (int)((*iV++ - 128) * 0.707);
2540 yuv = yuv + width - 1;
2543 yuv = yuv - width + 1;
2567 *rgb++ = (
unsigned char)R;
2568 *rgb++ = (
unsigned char)G;
2569 *rgb++ = (
unsigned char)B;
2590 *rgb++ = (
unsigned char)R;
2591 *rgb++ = (
unsigned char)G;
2592 *rgb = (
unsigned char)B;
2593 rgb = rgb + 3 * width - 5;
2614 *rgb++ = (
unsigned char)R;
2615 *rgb++ = (
unsigned char)G;
2616 *rgb++ = (
unsigned char)B;
2637 *rgb++ = (
unsigned char)R;
2638 *rgb++ = (
unsigned char)G;
2639 *rgb = (
unsigned char)B;
2640 rgb = rgb - 3 * width + 1;
2660 int U, V, R, G, B, V2, U5, UV;
2661 int Y0, Y1, Y2, Y3, Y4, Y5, Y6, Y7, Y8, Y9, Y10, Y11, Y12, Y13, Y14, Y15;
2662 unsigned int size = width * height;
2663 unsigned char *iV = yuv + size;
2664 unsigned char *iU = yuv + 17 * size / 16;
2665 for (
unsigned int i = 0; i < height / 4; i++) {
2666 for (
unsigned int j = 0; j < width / 4; j++) {
2667 U = (int)((*iU++ - 128) * 0.354);
2669 V = (int)((*iV++ - 128) * 0.707);
2676 yuv = yuv + width - 3;
2681 yuv = yuv + width - 3;
2686 yuv = yuv + width - 3;
2691 yuv = yuv - 3 * width + 1;
2715 *rgba++ = (
unsigned char)R;
2716 *rgba++ = (
unsigned char)G;
2717 *rgba++ = (
unsigned char)B;
2739 *rgba++ = (
unsigned char)R;
2740 *rgba++ = (
unsigned char)G;
2741 *rgba++ = (
unsigned char)B;
2763 *rgba++ = (
unsigned char)R;
2764 *rgba++ = (
unsigned char)G;
2765 *rgba++ = (
unsigned char)B;
2787 *rgba++ = (
unsigned char)R;
2788 *rgba++ = (
unsigned char)G;
2789 *rgba++ = (
unsigned char)B;
2791 rgba = rgba + 4 * width - 15;
2811 *rgba++ = (
unsigned char)R;
2812 *rgba++ = (
unsigned char)G;
2813 *rgba++ = (
unsigned char)B;
2835 *rgba++ = (
unsigned char)R;
2836 *rgba++ = (
unsigned char)G;
2837 *rgba++ = (
unsigned char)B;
2859 *rgba++ = (
unsigned char)R;
2860 *rgba++ = (
unsigned char)G;
2861 *rgba++ = (
unsigned char)B;
2883 *rgba++ = (
unsigned char)R;
2884 *rgba++ = (
unsigned char)G;
2885 *rgba++ = (
unsigned char)B;
2887 rgba = rgba + 4 * width - 15;
2907 *rgba++ = (
unsigned char)R;
2908 *rgba++ = (
unsigned char)G;
2909 *rgba++ = (
unsigned char)B;
2931 *rgba++ = (
unsigned char)R;
2932 *rgba++ = (
unsigned char)G;
2933 *rgba++ = (
unsigned char)B;
2955 *rgba++ = (
unsigned char)R;
2956 *rgba++ = (
unsigned char)G;
2957 *rgba++ = (
unsigned char)B;
2979 *rgba++ = (
unsigned char)R;
2980 *rgba++ = (
unsigned char)G;
2981 *rgba++ = (
unsigned char)B;
2983 rgba = rgba + 4 * width - 15;
3003 *rgba++ = (
unsigned char)R;
3004 *rgba++ = (
unsigned char)G;
3005 *rgba++ = (
unsigned char)B;
3027 *rgba++ = (
unsigned char)R;
3028 *rgba++ = (
unsigned char)G;
3029 *rgba++ = (
unsigned char)B;
3051 *rgba++ = (
unsigned char)R;
3052 *rgba++ = (
unsigned char)G;
3053 *rgba++ = (
unsigned char)B;
3075 *rgba++ = (
unsigned char)R;
3076 *rgba++ = (
unsigned char)G;
3077 *rgba++ = (
unsigned char)B;
3079 rgba = rgba - 12 * width + 1;
3096 int U, V, R, G, B, V2, U5, UV;
3097 int Y0, Y1, Y2, Y3, Y4, Y5, Y6, Y7, Y8, Y9, Y10, Y11, Y12, Y13, Y14, Y15;
3098 unsigned int size = width * height;
3099 unsigned char *iV = yuv + size;
3100 unsigned char *iU = yuv + 17 * size / 16;
3101 for (
unsigned int i = 0; i < height / 4; i++) {
3102 for (
unsigned int j = 0; j < width / 4; j++) {
3103 U = (int)((*iU++ - 128) * 0.354);
3105 V = (int)((*iV++ - 128) * 0.707);
3112 yuv = yuv + width - 3;
3117 yuv = yuv + width - 3;
3122 yuv = yuv + width - 3;
3127 yuv = yuv - 3 * width + 1;
3151 *rgb++ = (
unsigned char)R;
3152 *rgb++ = (
unsigned char)G;
3153 *rgb++ = (
unsigned char)B;
3174 *rgb++ = (
unsigned char)R;
3175 *rgb++ = (
unsigned char)G;
3176 *rgb++ = (
unsigned char)B;
3197 *rgb++ = (
unsigned char)R;
3198 *rgb++ = (
unsigned char)G;
3199 *rgb++ = (
unsigned char)B;
3220 *rgb++ = (
unsigned char)R;
3221 *rgb++ = (
unsigned char)G;
3222 *rgb = (
unsigned char)B;
3223 rgb = rgb + 3 * width - 11;
3243 *rgb++ = (
unsigned char)R;
3244 *rgb++ = (
unsigned char)G;
3245 *rgb++ = (
unsigned char)B;
3266 *rgb++ = (
unsigned char)R;
3267 *rgb++ = (
unsigned char)G;
3268 *rgb++ = (
unsigned char)B;
3289 *rgb++ = (
unsigned char)R;
3290 *rgb++ = (
unsigned char)G;
3291 *rgb++ = (
unsigned char)B;
3312 *rgb++ = (
unsigned char)R;
3313 *rgb++ = (
unsigned char)G;
3314 *rgb = (
unsigned char)B;
3315 rgb = rgb + 3 * width - 11;
3335 *rgb++ = (
unsigned char)R;
3336 *rgb++ = (
unsigned char)G;
3337 *rgb++ = (
unsigned char)B;
3358 *rgb++ = (
unsigned char)R;
3359 *rgb++ = (
unsigned char)G;
3360 *rgb++ = (
unsigned char)B;
3381 *rgb++ = (
unsigned char)R;
3382 *rgb++ = (
unsigned char)G;
3383 *rgb++ = (
unsigned char)B;
3404 *rgb++ = (
unsigned char)R;
3405 *rgb++ = (
unsigned char)G;
3406 *rgb = (
unsigned char)B;
3407 rgb = rgb + 3 * width - 11;
3427 *rgb++ = (
unsigned char)R;
3428 *rgb++ = (
unsigned char)G;
3429 *rgb++ = (
unsigned char)B;
3450 *rgb++ = (
unsigned char)R;
3451 *rgb++ = (
unsigned char)G;
3452 *rgb++ = (
unsigned char)B;
3473 *rgb++ = (
unsigned char)R;
3474 *rgb++ = (
unsigned char)G;
3475 *rgb++ = (
unsigned char)B;
3496 *rgb++ = (
unsigned char)R;
3497 *rgb++ = (
unsigned char)G;
3498 *rgb++ = (
unsigned char)B;
3499 rgb = rgb - 9 * width + 1;
3543 int lineStep = (flip) ? -(
int)(width * 3) : (
int)(width * 3);
3546 unsigned char *src = (flip) ? (rgb + (width * height * 3) + lineStep) : rgb;
3551 for (i = 0; i < height; i++) {
3552 unsigned char *line = src;
3553 for (j = 0; j < width; j++) {
3554 *rgba++ = *(line++);
3555 *rgba++ = *(line++);
3556 *rgba++ = *(line++);
3579 SimdBgraToBgr(rgba, size, 1, size * 4, rgb, size * 3);
3616 SimdRgbToGray(rgb, width, height, width * 3, grey, width);
3620 int lineStep = (flip) ? -(
int)(width * 3) : (
int)(width * 3);
3623 unsigned char *src = (flip) ? rgb + (width * height * 3) + lineStep : rgb;
3630 for (i = 0; i < height; i++) {
3631 unsigned char *line = src;
3632 for (j = 0; j < width; j++) {
3636 *grey++ = (
unsigned char)(0.2126 * r + 0.7152 * g + 0.0722 * b);
3669 omp_set_num_threads(
static_cast<int>(nThreads));
3671 #pragma omp parallel for
3673 for (
int i = 0; i < static_cast<int>(height); i++) {
3674 SimdRgbaToGray(rgba + i * width * 4, width, 1, width * 4, grey + i * width, width);
3694 SimdRgbaToGray(rgba, size, 1, size * 4, grey, size);
3742 SimdGrayToBgr(grey, size, 1, size, rgb, size * 3);
3768 int lineStep = (flip) ? -(
int)(width * 3) : (
int)(width * 3);
3771 unsigned char *src = (flip) ? (bgr + (width * height * 3) + lineStep) : bgr;
3773 for (
unsigned int i = 0; i < height; i++) {
3774 unsigned char *line = src;
3775 for (
unsigned int j = 0; j < width; j++) {
3776 *rgba++ = *(line + 2);
3777 *rgba++ = *(line + 1);
3778 *rgba++ = *(line + 0);
3807 SimdBgraToRgba(bgra, width, height, width * 4, rgba, width * 4);
3811 int lineStep = (flip) ? -(
int)(width * 4) : (
int)(width * 4);
3814 unsigned char *src = (flip) ? (bgra + (width * height * 4) + lineStep) : bgra;
3816 for (
unsigned int i = 0; i < height; i++) {
3817 unsigned char *line = src;
3818 for (
unsigned int j = 0; j < width; j++) {
3819 *rgba++ = *(line + 2);
3820 *rgba++ = *(line + 1);
3821 *rgba++ = *(line + 0);
3822 *rgba++ = *(line + 3);
3857 omp_set_num_threads(
static_cast<int>(nThreads));
3859 #pragma omp parallel for
3861 for (
int i = 0; i < static_cast<int>(height); i++) {
3862 SimdBgrToGray(bgr + i * width * 3, width, 1, width * 3, grey + i * width, width);
3867 int lineStep = (flip) ? -(
int)(width * 3) : (
int)(width * 3);
3870 unsigned char *src = (flip) ? bgr + (width * height * 3) + lineStep : bgr;
3872 for (
unsigned int i = 0; i < height; i++) {
3873 unsigned char *line = src;
3874 for (
unsigned int j = 0; j < width; j++) {
3875 *grey++ = (
unsigned char)(0.2126 * *(line + 2) + 0.7152 * *(line + 1) + 0.0722 * *(line + 0));
3910 omp_set_num_threads(
static_cast<int>(nThreads));
3912 #pragma omp parallel for
3914 for (
int i = 0; i < static_cast<int>(height); i++) {
3915 SimdBgraToGray(bgra + i * width * 4, width, 1, width * 4, grey + i * width, width);
3920 int lineStep = (flip) ? -(
int)(width * 4) : (
int)(width * 4);
3923 unsigned char *src = (flip) ? bgra + (width * height * 4) + lineStep : bgra;
3925 for (
unsigned int i = 0; i < height; i++) {
3926 unsigned char *line = src;
3927 for (
unsigned int j = 0; j < width; j++) {
3928 *grey++ = (
unsigned char)(0.2126 * *(line + 2) + 0.7152 * *(line + 1) + 0.0722 * *(line + 0));
3941 void vpImageConvert::computeYCbCrLUT()
3943 if (YCbCrLUTcomputed ==
false) {
3948 int aux = index - 128;
3949 vpImageConvert::vpCrr[index] = (int)(364.6610 * aux) >> 8;
3950 vpImageConvert::vpCgb[index] = (int)(-89.8779 * aux) >> 8;
3951 vpImageConvert::vpCgr[index] = (int)(-185.8154 * aux) >> 8;
3952 vpImageConvert::vpCbb[index] = (int)(460.5724 * aux) >> 8;
3955 YCbCrLUTcomputed =
true;
3984 unsigned char *pt_ycbcr = ycbcr;
3985 unsigned char *pt_rgb = rgb;
3989 vpImageConvert::computeYCbCrLUT();
3994 int val_r, val_g, val_b;
4000 val_r = *pt_ycbcr + vpImageConvert::vpCrr[*crv];
4001 val_g = *pt_ycbcr + vpImageConvert::vpCgb[*cbv] + vpImageConvert::vpCgr[*crv];
4002 val_b = *pt_ycbcr + vpImageConvert::vpCbb[*cbv];
4004 vpDEBUG_TRACE(5,
"[%d] R: %d G: %d B: %d\n", size, val_r, val_g, val_b);
4006 *pt_rgb++ = (val_r < 0) ? 0u : ((val_r > 255) ? 255u : (
unsigned char)val_r);
4007 *pt_rgb++ = (val_g < 0) ? 0u : ((val_g > 255) ? 255u : (
unsigned char)val_g);
4008 *pt_rgb++ = (val_b < 0) ? 0u : ((val_b > 255) ? 255u : (
unsigned char)val_b);
4043 unsigned char *pt_ycbcr = ycbcr;
4044 unsigned char *pt_rgba = rgba;
4048 vpImageConvert::computeYCbCrLUT();
4053 int val_r, val_g, val_b;
4059 val_r = *pt_ycbcr + vpImageConvert::vpCrr[*crv];
4060 val_g = *pt_ycbcr + vpImageConvert::vpCgb[*cbv] + vpImageConvert::vpCgr[*crv];
4061 val_b = *pt_ycbcr + vpImageConvert::vpCbb[*cbv];
4063 vpDEBUG_TRACE(5,
"[%d] R: %d G: %d B: %d\n", size, val_r, val_g, val_b);
4065 *pt_rgba++ = (val_r < 0) ? 0u : ((val_r > 255) ? 255u : (
unsigned char)val_r);
4066 *pt_rgba++ = (val_g < 0) ? 0u : ((val_g > 255) ? 255u : (
unsigned char)val_g);
4067 *pt_rgba++ = (val_b < 0) ? 0u : ((val_b > 255) ? 255u : (
unsigned char)val_b);
4095 unsigned int i = 0, j = 0;
4097 while (j < size * 2) {
4098 grey[i++] = ycbcr[j];
4099 grey[i++] = ycbcr[j + 2];
4129 unsigned char *pt_ycbcr = ycrcb;
4130 unsigned char *pt_rgb = rgb;
4134 vpImageConvert::computeYCbCrLUT();
4139 int val_r, val_g, val_b;
4145 val_r = *pt_ycbcr + vpImageConvert::vpCrr[*crv];
4146 val_g = *pt_ycbcr + vpImageConvert::vpCgb[*cbv] + vpImageConvert::vpCgr[*crv];
4147 val_b = *pt_ycbcr + vpImageConvert::vpCbb[*cbv];
4149 vpDEBUG_TRACE(5,
"[%d] R: %d G: %d B: %d\n", size, val_r, val_g, val_b);
4151 *pt_rgb++ = (val_r < 0) ? 0u : ((val_r > 255) ? 255u : (
unsigned char)val_r);
4152 *pt_rgb++ = (val_g < 0) ? 0u : ((val_g > 255) ? 255u : (
unsigned char)val_g);
4153 *pt_rgb++ = (val_b < 0) ? 0u : ((val_b > 255) ? 255u : (
unsigned char)val_b);
4187 unsigned char *pt_ycbcr = ycrcb;
4188 unsigned char *pt_rgba = rgba;
4192 vpImageConvert::computeYCbCrLUT();
4197 int val_r, val_g, val_b;
4203 val_r = *pt_ycbcr + vpImageConvert::vpCrr[*crv];
4204 val_g = *pt_ycbcr + vpImageConvert::vpCgb[*cbv] + vpImageConvert::vpCgr[*crv];
4205 val_b = *pt_ycbcr + vpImageConvert::vpCbb[*cbv];
4207 vpDEBUG_TRACE(5,
"[%d] R: %d G: %d B: %d\n", size, val_r, val_g, val_b);
4209 *pt_rgba++ = (val_r < 0) ? 0u : ((val_r > 255) ? 255u : (
unsigned char)val_r);
4210 *pt_rgba++ = (val_g < 0) ? 0u : ((val_g > 255) ? 255u : (
unsigned char)val_g);
4211 *pt_rgba++ = (val_b < 0) ? 0u : ((val_b > 255) ? 255u : (
unsigned char)val_b);
4273 unsigned char *ptrR = pR ? pR->
bitmap :
new unsigned char[src.
getSize()];
4274 unsigned char *ptrG = pG ? pG->
bitmap :
new unsigned char[src.
getSize()];
4275 unsigned char *ptrB = pB ? pB->
bitmap :
new unsigned char[src.
getSize()];
4276 unsigned char *ptrA = pa ? pa->
bitmap :
new unsigned char[src.
getSize()];
4311 std::map<unsigned int, unsigned int> mapOfWidths, mapOfHeights;
4332 if (mapOfWidths.size() == 1 && mapOfHeights.size() == 1) {
4333 unsigned int width = mapOfWidths.begin()->first;
4334 unsigned int height = mapOfHeights.begin()->first;
4336 RGBa.
resize(height, width);
4338 if (R != NULL && G != NULL && B != NULL && a != NULL) {
4339 SimdInterleaveBgra(R->
bitmap, width, G->
bitmap, width, B->
bitmap, width, a->
bitmap, width, width, height,
4340 reinterpret_cast<uint8_t *
>(RGBa.
bitmap), width *
sizeof(
vpRGBa));
4342 unsigned int size = width * height;
4343 for (
unsigned int i = 0; i < size; i++) {
4378 int i = (((int)size) << 1) - 1;
4379 int j = (int)size - 1;
4382 int y = grey16[i--];
4383 grey[j--] =
static_cast<unsigned char>((y + (grey16[i--] << 8)) >> 8);
4400 int i = (((int)size) << 1) - 1;
4401 int j = (int)(size * 4 - 1);
4404 int y = grey16[i--];
4405 unsigned char v =
static_cast<unsigned char>((y + (grey16[i--] << 8)) >> 8);
4423 void vpImageConvert::HSV2RGB(
const double *hue_,
const double *saturation_,
const double *value_,
unsigned char *rgb,
4424 unsigned int size,
unsigned int step)
4426 for (
unsigned int i = 0; i < size; i++) {
4427 double hue = hue_[i], saturation = saturation_[i], value = value_[i];
4429 if (
vpMath::equal(saturation, 0.0, std::numeric_limits<double>::epsilon())) {
4433 double h = hue * 6.0;
4434 double s = saturation;
4437 if (
vpMath::equal(h, 6.0, std::numeric_limits<double>::epsilon())) {
4441 double f = h - (int)h;
4442 double p = v * (1.0 - s);
4443 double q = v * (1.0 - s * f);
4444 double t = v * (1.0 - s * (1.0 - f));
4486 rgb[i * step + 1] = (
unsigned char)
vpMath::round(saturation * 255.0);
4487 rgb[i * step + 2] = (
unsigned char)
vpMath::round(value * 255.0);
4503 void vpImageConvert::RGB2HSV(
const unsigned char *rgb,
double *hue,
double *saturation,
double *value,
4504 unsigned int size,
unsigned int step)
4506 for (
unsigned int i = 0; i < size; i++) {
4507 double red, green, blue;
4511 red = rgb[i * step] / 255.0;
4512 green = rgb[i * step + 1] / 255.0;
4513 blue = rgb[i * step + 2] / 255.0;
4516 max = ((std::max))(red, blue);
4517 min = ((std::min))(green, blue);
4519 max = ((std::max))(green, blue);
4520 min = ((std::min))(red, blue);
4525 if (!
vpMath::equal(max, 0.0, std::numeric_limits<double>::epsilon())) {
4526 s = (max - min) / max;
4531 if (
vpMath::equal(s, 0.0, std::numeric_limits<double>::epsilon())) {
4534 double delta = max - min;
4535 if (
vpMath::equal(delta, 0.0, std::numeric_limits<double>::epsilon())) {
4539 if (
vpMath::equal(red, max, std::numeric_limits<double>::epsilon())) {
4540 h = (green - blue) / delta;
4541 }
else if (
vpMath::equal(green, max, std::numeric_limits<double>::epsilon())) {
4542 h = 2 + (blue - red) / delta;
4544 h = 4 + (red - green) / delta;
4550 }
else if (h > 1.0) {
4576 vpImageConvert::HSV2RGB(hue, saturation, value, rgba, size, 4);
4592 unsigned char *rgba,
unsigned int size)
4594 for (
unsigned int i = 0; i < size; i++) {
4595 double h = hue[i] / 255.0, s = saturation[i] / 255.0, v = value[i] / 255.0;
4616 vpImageConvert::RGB2HSV(rgba, hue, saturation, value, size, 4);
4631 unsigned char *value,
unsigned int size)
4633 for (
unsigned int i = 0; i < size; i++) {
4637 hue[i] = (
unsigned char)(255.0 * h);
4638 saturation[i] = (
unsigned char)(255.0 * s);
4639 value[i] = (
unsigned char)(255.0 * v);
4656 vpImageConvert::HSV2RGB(hue, saturation, value, rgb, size, 3);
4670 unsigned char *rgb,
unsigned int size)
4672 for (
unsigned int i = 0; i < size; i++) {
4673 double h = hue[i] / 255.0, s = saturation[i] / 255.0, v = value[i] / 255.0;
4693 vpImageConvert::RGB2HSV(rgb, hue, saturation, value, size, 3);
4707 unsigned char *value,
unsigned int size)
4709 for (
unsigned int i = 0; i < size; i++) {
4714 hue[i] = (
unsigned char)(255.0 * h);
4715 saturation[i] = (
unsigned char)(255.0 * s);
4716 value[i] = (
unsigned char)(255.0 * v);
4735 unsigned int height,
unsigned int nThreads)
4737 demosaicBGGRToRGBaBilinearTpl(bggr, rgba, width, height, nThreads);
4753 unsigned int height,
unsigned int nThreads)
4755 demosaicBGGRToRGBaBilinearTpl(bggr, rgba, width, height, nThreads);
4771 unsigned int height,
unsigned int nThreads)
4773 demosaicGBRGToRGBaBilinearTpl(gbrg, rgba, width, height, nThreads);
4789 unsigned int height,
unsigned int nThreads)
4791 demosaicGBRGToRGBaBilinearTpl(gbrg, rgba, width, height, nThreads);
4807 unsigned int height,
unsigned int nThreads)
4809 demosaicGRBGToRGBaBilinearTpl(grbg, rgba, width, height, nThreads);
4825 unsigned int height,
unsigned int nThreads)
4827 demosaicGRBGToRGBaBilinearTpl(grbg, rgba, width, height, nThreads);
4843 unsigned int height,
unsigned int nThreads)
4845 demosaicRGGBToRGBaBilinearTpl(rggb, rgba, width, height, nThreads);
4861 unsigned int height,
unsigned int nThreads)
4863 demosaicRGGBToRGBaBilinearTpl(rggb, rgba, width, height, nThreads);
4881 unsigned int height,
unsigned int nThreads)
4883 demosaicBGGRToRGBaMalvarTpl(bggr, rgba, width, height, nThreads);
4899 unsigned int height,
unsigned int nThreads)
4901 demosaicBGGRToRGBaMalvarTpl(bggr, rgba, width, height, nThreads);
4917 unsigned int height,
unsigned int nThreads)
4919 demosaicGBRGToRGBaMalvarTpl(gbrg, rgba, width, height, nThreads);
4935 unsigned int height,
unsigned int nThreads)
4937 demosaicGBRGToRGBaMalvarTpl(gbrg, rgba, width, height, nThreads);
4953 unsigned int height,
unsigned int nThreads)
4955 demosaicGRBGToRGBaMalvarTpl(grbg, rgba, width, height, nThreads);
4971 unsigned int height,
unsigned int nThreads)
4973 demosaicGRBGToRGBaMalvarTpl(grbg, rgba, width, height, nThreads);
4989 unsigned int height,
unsigned int nThreads)
4991 demosaicRGGBToRGBaMalvarTpl(rggb, rgba, width, height, nThreads);
5007 unsigned int height,
unsigned int nThreads)
5009 demosaicRGGBToRGBaMalvarTpl(rggb, rgba, width, height, nThreads);
error that can be emited by ViSP classes.
@ badValue
Used to indicate that a value is not in the allowed range.
@ dimensionError
Bad dimension.
static void YUV411ToGrey(unsigned char *yuv, unsigned char *grey, unsigned int size)
static void YVU9ToRGBa(unsigned char *yuv, unsigned char *rgba, unsigned int width, unsigned int height)
static void MONO16ToGrey(unsigned char *grey16, unsigned char *grey, unsigned int size)
static void HSVToRGBa(const double *hue, const double *saturation, const double *value, unsigned char *rgba, unsigned int size)
static void YUYVToRGBa(unsigned char *yuyv, unsigned char *rgba, unsigned int width, unsigned int height)
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 split(const vpImage< vpRGBa > &src, vpImage< unsigned char > *pR, vpImage< unsigned char > *pG, vpImage< unsigned char > *pB, vpImage< unsigned char > *pa=NULL)
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 YUV422ToGrey(unsigned char *yuv, unsigned char *grey, unsigned int size)
static void YUV420ToRGBa(unsigned char *yuv, unsigned char *rgba, unsigned int width, unsigned int height)
static void YUYVToGrey(unsigned char *yuyv, unsigned char *grey, unsigned int size)
static void YUV411ToRGBa(unsigned char *yuv, unsigned char *rgba, unsigned int size)
static void YUV420ToGrey(unsigned char *yuv, unsigned char *grey, unsigned int size)
static void demosaicGBRGToRGBaMalvar(const uint8_t *gbrg, uint8_t *rgba, unsigned int width, unsigned int height, unsigned int nThreads=0)
static void YVU9ToRGB(unsigned char *yuv, unsigned char *rgb, unsigned int width, unsigned int height)
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 YV12ToRGBa(unsigned char *yuv, unsigned char *rgba, unsigned int width, unsigned int height)
static void YUV444ToRGB(unsigned char *yuv, unsigned char *rgb, unsigned int size)
static void demosaicBGGRToRGBaMalvar(const uint8_t *bggr, uint8_t *rgba, unsigned int width, unsigned int height, unsigned int nThreads=0)
static void YUV411ToRGB(unsigned char *yuv, unsigned char *rgb, unsigned int size)
static void YUVToRGB(unsigned char y, unsigned char u, unsigned char v, unsigned char &r, unsigned char &g, unsigned char &b)
static void demosaicGBRGToRGBaBilinear(const uint8_t *gbrg, uint8_t *rgba, unsigned int width, unsigned int height, unsigned int nThreads=0)
static void YCbCrToGrey(unsigned char *ycbcr, unsigned char *grey, unsigned int size)
static void YUV422ToRGB(unsigned char *yuv, unsigned char *rgb, unsigned int size)
static void YCrCbToRGB(unsigned char *ycrcb, unsigned char *rgb, unsigned int size)
static void YCbCrToRGBa(unsigned char *ycbcr, unsigned char *rgb, unsigned int size)
static void createDepthHistogram(const vpImage< uint16_t > &src_depth, vpImage< vpRGBa > &dest_rgba)
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 GreyToRGBa(unsigned char *grey, unsigned char *rgba, unsigned int width, unsigned int height)
static void convert(const vpImage< unsigned char > &src, vpImage< vpRGBa > &dest)
static void MONO16ToRGBa(unsigned char *grey16, unsigned char *rgba, unsigned int size)
static void RGBToGrey(unsigned char *rgb, unsigned char *grey, unsigned int width, unsigned int height, bool flip=false)
static void RGBaToGrey(unsigned char *rgba, unsigned char *grey, unsigned int width, unsigned int height, unsigned int nThreads=0)
static void GreyToRGB(unsigned char *grey, unsigned char *rgb, unsigned int size)
static void YCrCbToRGBa(unsigned char *ycrcb, unsigned char *rgb, unsigned int size)
static void RGBToRGBa(unsigned char *rgb, unsigned char *rgba, unsigned int size)
static void YCbCrToRGB(unsigned char *ycbcr, unsigned char *rgb, 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 YUV422ToRGBa(unsigned char *yuv, unsigned char *rgba, unsigned int size)
static void YV12ToRGB(unsigned char *yuv, unsigned char *rgb, unsigned int width, unsigned int height)
static void BGRToGrey(unsigned char *bgr, unsigned char *grey, unsigned int width, unsigned int height, bool flip=false, unsigned int nThreads=0)
static void BGRToRGBa(unsigned char *bgr, unsigned char *rgba, unsigned int width, unsigned int height, bool flip=false)
static void demosaicRGGBToRGBaBilinear(const uint8_t *rggb, uint8_t *rgba, unsigned int width, unsigned int height, unsigned int nThreads=0)
static void YUV444ToRGBa(unsigned char *yuv, unsigned char *rgba, unsigned int size)
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 YUV444ToGrey(unsigned char *yuv, unsigned char *grey, unsigned int size)
static void YUV420ToRGB(unsigned char *yuv, unsigned char *rgb, unsigned int width, unsigned int height)
static void HSVToRGB(const double *hue, const double *saturation, const double *value, unsigned char *rgb, unsigned int size)
static void YUYVToRGB(unsigned char *yuyv, unsigned char *rgb, unsigned int width, unsigned int height)
unsigned int getWidth() const
void resize(unsigned int h, unsigned int w)
resize the image : Image initialization
unsigned int getSize() const
unsigned int getCols() const
Type * bitmap
points toward the bitmap
unsigned int getHeight() const
unsigned int getRows() const
void getMinMaxValue(Type &min, Type &max, bool onlyFiniteVal=true) const
Look for the minimum and the maximum value within the bitmap.
static bool equal(double x, double y, double threshold=0.001)
static int round(double x)
unsigned char B
Blue component.
unsigned char R
Red component.
unsigned char G
Green component.
unsigned char A
Additionnal component.