50 #include <visp3/core/vpCPUFeatures.h> 51 #include <visp3/core/vpImageConvert.h> 53 #if defined __SSE2__ || defined _M_X64 || (defined _M_IX86_FP && _M_IX86_FP >= 2) 54 #include <emmintrin.h> 55 #define VISP_HAVE_SSE2 1 57 #if defined __SSE3__ || (defined _MSC_VER && _MSC_VER >= 1500) 58 #include <pmmintrin.h> 59 #define VISP_HAVE_SSE3 1 61 #if defined __SSSE3__ || (defined _MSC_VER && _MSC_VER >= 1500) 62 #include <tmmintrin.h> 63 #define VISP_HAVE_SSSE3 1 67 bool vpImageConvert::YCbCrLUTcomputed =
false;
68 int vpImageConvert::vpCrr[256];
69 int vpImageConvert::vpCgb[256];
70 int vpImageConvert::vpCgr[256];
71 int vpImageConvert::vpCbb[256];
110 for (
unsigned int i = 0; i < max_xy; i++) {
111 float val = 255.f * (src.
bitmap[i] - min) / (max - min);
117 dest.
bitmap[i] = (
unsigned char)val;
145 for (
unsigned int i = 0; i < max_xy; i++) {
146 double val = 255. * (src.
bitmap[i] - min) / (max - min);
152 dest.
bitmap[i] = (
unsigned char)val;
165 for (
unsigned int i = 0; i < src.
getSize(); i++)
178 for (
unsigned int i = 0; i < src.
getSize(); i++)
204 static uint32_t histogram[0x10000];
205 memset(histogram, 0,
sizeof(histogram));
207 for (
unsigned int i = 0; i < src_depth.
getSize(); ++i)
208 ++histogram[src_depth.
bitmap[i]];
209 for (
int i = 2; i < 0x10000; ++i)
210 histogram[i] += histogram[i - 1];
213 for (
unsigned int i = 0; i < src_depth.
getSize(); ++i) {
214 uint16_t d = src_depth.
bitmap[i];
216 int f = (int)(histogram[d] * 255 / histogram[0xFFFF]);
217 dest_rgba.
bitmap[i].
R = 255 - f;
239 static uint32_t histogram2[0x10000];
240 memset(histogram2, 0,
sizeof(histogram2));
242 for (
unsigned int i = 0; i < src_depth.
getSize(); ++i)
243 ++histogram2[src_depth.
bitmap[i]];
244 for (
int i = 2; i < 0x10000; ++i)
245 histogram2[i] += histogram2[i - 1];
248 for (
unsigned int i = 0; i < src_depth.
getSize(); ++i) {
249 uint16_t d = src_depth.
bitmap[i];
251 unsigned char f =
static_cast<unsigned char>(histogram2[d] * 255 / histogram2[0xFFFF]);
259 #ifdef VISP_HAVE_OPENCV 308 int nChannel = src->nChannels;
309 int depth = src->depth;
310 int height = src->height;
311 int width = src->width;
312 int widthStep = src->widthStep;
313 int lineStep = (flip) ? 1 : 0;
315 if (nChannel == 3 && depth == 8) {
316 dest.
resize((
unsigned int)height, (
unsigned int)width);
319 unsigned char *input = (
unsigned char *)src->imageData;
320 unsigned char *beginOutput = (
unsigned char *)dest.
bitmap;
322 for (
int i = 0; i < height; i++) {
323 unsigned char *line = input;
324 unsigned char *output = beginOutput + lineStep * (4 * width * (height - 1 - i)) + (1 - lineStep) * 4 * width * i;
325 for (
int j = 0; j < width; j++) {
326 *(output++) = *(line + 2);
327 *(output++) = *(line + 1);
328 *(output++) = *(line);
336 }
else if (nChannel == 1 && depth == 8) {
337 dest.
resize((
unsigned int)height, (
unsigned int)width);
339 unsigned char *input = (
unsigned char *)src->imageData;
340 unsigned char *beginOutput = (
unsigned char *)dest.
bitmap;
342 for (
int i = 0; i < height; i++) {
343 unsigned char *line = input;
344 unsigned char *output = beginOutput + lineStep * (4 * width * (height - 1 - i)) + (1 - lineStep) * 4 * width * i;
345 for (
int j = 0; j < width; j++) {
403 int nChannel = src->nChannels;
404 int depth = src->depth;
405 int height = src->height;
406 int width = src->width;
407 int widthStep = src->widthStep;
408 int lineStep = (flip) ? 1 : 0;
411 if (widthStep == width) {
412 if (nChannel == 1 && depth == 8) {
413 dest.
resize((
unsigned int)height, (
unsigned int)width);
414 memcpy(dest.
bitmap, src->imageData, (
size_t)(height * width));
416 if (nChannel == 3 && depth == 8) {
417 dest.
resize((
unsigned int)height, (
unsigned int)width);
418 BGRToGrey((
unsigned char *)src->imageData, dest.
bitmap, (
unsigned int)width, (
unsigned int)height,
false);
421 if (nChannel == 1 && depth == 8) {
422 dest.
resize((
unsigned int)height, (
unsigned int)width);
423 for (
int i = 0; i < height; i++) {
424 memcpy(dest.
bitmap + i * width, src->imageData + i * widthStep, (
size_t)width);
427 if (nChannel == 3 && depth == 8) {
428 dest.
resize((
unsigned int)height, (
unsigned int)width);
429 for (
int i = 0; i < height; i++) {
430 BGRToGrey((
unsigned char *)src->imageData + i * widthStep, dest.
bitmap + i * width, (
unsigned int)width, 1,
436 if (nChannel == 1 && depth == 8) {
437 dest.
resize((
unsigned int)height, (
unsigned int)width);
438 unsigned char *beginOutput = (
unsigned char *)dest.
bitmap;
439 for (
int i = 0; i < height; i++) {
440 memcpy(beginOutput + lineStep * (4 * width * (height - 1 - i)), src->imageData + i * widthStep, (
size_t)width);
443 if (nChannel == 3 && depth == 8) {
444 dest.
resize((
unsigned int)height, (
unsigned int)width);
446 BGRToGrey((
unsigned char *)src->imageData , dest.
bitmap , (
unsigned int)width,
447 (
unsigned int)height ,
true);
500 CvSize size = cvSize(width, height);
504 if (dest->nChannels != channels || dest->depth != depth || dest->height != height || dest->width != width) {
505 if (dest->nChannels != 0)
506 cvReleaseImage(&dest);
507 dest = cvCreateImage(size, depth, channels);
510 dest = cvCreateImage(size, depth, channels);
513 unsigned char *input = (
unsigned char *)src.
bitmap;
514 unsigned char *output = (
unsigned char *)dest->imageData;
518 int widthStep = dest->widthStep;
520 for (i = 0; i < height; i++) {
521 output = (
unsigned char *)dest->imageData + i * widthStep;
522 unsigned char *line = input;
523 for (j = 0; j < width; j++) {
524 *output++ = *(line + 2);
525 *output++ = *(line + 1);
581 unsigned int width = src.
getWidth();
582 CvSize size = cvSize((
int)width, (
int)height);
586 if (dest->nChannels != channels || dest->depth != depth || dest->height != (
int)height ||
587 dest->width != (
int)width) {
588 if (dest->nChannels != 0)
589 cvReleaseImage(&dest);
590 dest = cvCreateImage(size, depth, channels);
593 dest = cvCreateImage(size, depth, channels);
595 unsigned int widthStep = (
unsigned int)dest->widthStep;
597 if (width == widthStep) {
598 memcpy(dest->imageData, src.
bitmap, width * height);
601 for (
unsigned int i = 0; i < height; i++) {
602 memcpy(dest->imageData + i * widthStep, src.
bitmap + i * width, width);
607 #if VISP_HAVE_OPENCV_VERSION >= 0x020100 657 if (src.type() == CV_8UC4) {
658 dest.
resize((
unsigned int)src.rows, (
unsigned int)src.cols);
660 for (
unsigned int i = 0; i < dest.
getRows(); ++i)
661 for (
unsigned int j = 0; j < dest.
getCols(); ++j) {
662 cv::Vec4b tmp = src.at<cv::Vec4b>((int)i, (
int)j);
668 dest[dest.
getRows() - i - 1][j] = rgbaVal;
670 dest[i][j] = rgbaVal;
672 }
else if (src.type() == CV_8UC3) {
673 dest.
resize((
unsigned int)src.rows, (
unsigned int)src.cols);
680 if (checkSSSE3 && src.isContinuous() && !flip) {
683 int size = src.rows*src.cols;
684 const uchar* bgr = src.ptr<uchar>();
685 unsigned char* rgba = (
unsigned char*) dest.
bitmap;
689 const __m128i mask_1 = _mm_set_epi8(-1, 9, 10, 11, -1, 6, 7, 8, -1, 3, 4, 5, -1, 0, 1, 2);
690 const __m128i mask_2 = _mm_set_epi8(-1, -1, -1, -1, -1, -1, -1, -1, -1, 15, -1, -1, -1, 12, 13, 14);
691 const __m128i mask_3 = _mm_set_epi8(-1, 5, 6, 7, -1, 2, 3, 4, -1, -1, 0, 1, -1, -1, -1, -1);
692 const __m128i mask_4 = _mm_set_epi8(-1, -1, -1, -1, -1, 14, 15, -1, -1, 11, 12, 13, -1, 8, 9, 10);
693 const __m128i mask_5 = _mm_set_epi8(-1, 1, 2, 3, -1, -1, -1, 0, -1, -1, -1, -1, -1, -1, -1, -1);
694 const __m128i mask_6 = _mm_set_epi8(-1, 13, 14, 15, -1, 10, 11, 12, -1, 7, 8, 9, -1, 4, 5, 6);
697 int size_vec = size - 16;
700 for (; i <= size_vec; i += 16) {
702 const __m128i data1 = _mm_loadu_si128((
const __m128i *)bgr);
703 const __m128i data2 = _mm_loadu_si128((
const __m128i *)(bgr + 16));
704 const __m128i data3 = _mm_loadu_si128((
const __m128i *)(bgr + 32));
706 res[0] = _mm_shuffle_epi8(data1, mask_1);
707 res[1] = _mm_or_si128(_mm_shuffle_epi8(data1, mask_2), _mm_shuffle_epi8(data2, mask_3));
708 res[2] = _mm_or_si128(_mm_shuffle_epi8(data2, mask_4), _mm_shuffle_epi8(data3, mask_5));
709 res[3] = _mm_shuffle_epi8(data3, mask_6);
711 _mm_storeu_si128((__m128i *)rgba, res[0]);
712 _mm_storeu_si128((__m128i *)(rgba+16), res[1]);
713 _mm_storeu_si128((__m128i *)(rgba+32), res[2]);
714 _mm_storeu_si128((__m128i *)(rgba+48), res[3]);
721 for (; i < size; i++) {
722 *rgba = *(bgr+2); rgba++;
723 *rgba = *(bgr+1); rgba++;
724 *rgba = *(bgr); rgba++;
733 for (
unsigned int i = 0; i < dest.
getRows(); ++i) {
734 for (
unsigned int j = 0; j < dest.
getCols(); ++j) {
735 cv::Vec3b tmp = src.at<cv::Vec3b>((int)i, (
int)j);
740 dest[dest.
getRows() - i - 1][j] = rgbaVal;
742 dest[i][j] = rgbaVal;
747 }
else if (src.type() == CV_8UC1) {
748 dest.
resize((
unsigned int)src.rows, (
unsigned int)src.cols);
750 for (
unsigned int i = 0; i < dest.
getRows(); ++i) {
751 for (
unsigned int j = 0; j < dest.
getCols(); ++j) {
752 rgbaVal = src.at<
unsigned char>((int)i, (
int)j);
754 dest[dest.
getRows() - i - 1][j] = rgbaVal;
756 dest[i][j] = rgbaVal;
806 if (src.type() == CV_8UC1) {
807 dest.
resize((
unsigned int)src.rows, (
unsigned int)src.cols);
808 if (src.isContinuous() && !flip) {
809 memcpy(dest.
bitmap, src.data, (
size_t)(src.rows * src.cols));
812 for (
unsigned int i = 0; i < dest.
getRows(); ++i) {
813 memcpy(dest.
bitmap + i * dest.
getCols(), src.data + (dest.
getRows() - i - 1) * src.step1(), (size_t)src.step);
816 for (
unsigned int i = 0; i < dest.
getRows(); ++i) {
817 memcpy(dest.
bitmap + i * dest.
getCols(), src.data + i * src.step1(), (size_t)src.step);
821 }
else if (src.type() == CV_8UC3) {
822 dest.
resize((
unsigned int)src.rows, (
unsigned int)src.cols);
823 if (src.isContinuous() ) {
824 BGRToGrey((
unsigned char *)src.data, (
unsigned char *)dest.
bitmap, (
unsigned int)src.cols, (
unsigned int)src.rows,
828 for (
unsigned int i = 0; i < dest.
getRows(); ++i) {
829 BGRToGrey((
unsigned char *)src.data + i * src.step1(),
831 (
unsigned int)dest.
getCols(), 1,
false);
834 for (
unsigned int i = 0; i < dest.
getRows(); ++i) {
836 (
unsigned int)dest.
getCols(), 1,
false);
882 cv::cvtColor(vpToMat, dest, cv::COLOR_RGBA2BGR);
927 dest = tmpMap.clone();
936 #ifdef VISP_HAVE_YARP 1022 dest.
resize(src->height(), src->width());
1024 memcpy(dest.
bitmap, src->getRawImage(), src->height() * src->width() *
sizeof(yarp::sig::PixelMono));
1026 dest.
bitmap = src->getRawImage();
1114 dest.
resize(src->height(), src->width());
1116 memcpy(dest.
bitmap, src->getRawImage(), src->height() * src->width() *
sizeof(yarp::sig::PixelRgba));
1118 dest.
bitmap =
static_cast<vpRGBa *
>(src->getRawImage());
1156 for (
unsigned int i = 0; i < src.
getRows(); i++) {
1157 for (
unsigned int j = 0; j < src.
getWidth(); j++) {
1158 dest->pixel(j, i).r = src[i][j].R;
1159 dest->pixel(j, i).g = src[i][j].G;
1160 dest->pixel(j, i).b = src[i][j].B;
1205 dest.
resize(src->height(), src->width());
1206 for (
int i = 0; i < src->height(); i++) {
1207 for (
int j = 0; j < src->width(); j++) {
1208 dest[i][j].R = src->pixel(j, i).r;
1209 dest[i][j].G = src->pixel(j, i).g;
1210 dest[i][j].B = src->pixel(j, i).b;
1238 int r, g, b, cr, cg, cb, y1, y2;
1248 cb = ((*s - 128) * 454) >> 8;
1249 cg = (*s++ - 128) * 88;
1251 cr = ((*s - 128) * 359) >> 8;
1252 cg = (cg + (*s++ - 128) * 183) >> 8;
1261 *d++ =
static_cast<unsigned char>(r);
1262 *d++ =
static_cast<unsigned char>(g);
1263 *d++ =
static_cast<unsigned char>(b);
1273 *d++ =
static_cast<unsigned char>(r);
1274 *d++ =
static_cast<unsigned char>(g);
1275 *d++ =
static_cast<unsigned char>(b);
1293 int r, g, b, cr, cg, cb, y1, y2;
1303 cb = ((*s - 128) * 454) >> 8;
1304 cg = (*s++ - 128) * 88;
1306 cr = ((*s - 128) * 359) >> 8;
1307 cg = (cg + (*s++ - 128) * 183) >> 8;
1316 *d++ =
static_cast<unsigned char>(r);
1317 *d++ =
static_cast<unsigned char>(g);
1318 *d++ =
static_cast<unsigned char>(b);
1327 *d++ =
static_cast<unsigned char>(r);
1328 *d++ =
static_cast<unsigned char>(g);
1329 *d++ =
static_cast<unsigned char>(b);
1342 unsigned int i = 0, j = 0;
1344 while (j < size * 2) {
1345 grey[i++] = yuyv[j];
1346 grey[i++] = yuyv[j + 2];
1361 for (
unsigned int i = size / 4; i; i--) {
1362 int U = (int)((*yuv++ - 128) * 0.354);
1366 int V = (int)((*yuv++ - 128) * 0.707);
1394 *rgba++ = (
unsigned char)R;
1395 *rgba++ = (
unsigned char)G;
1396 *rgba++ = (
unsigned char)B;
1418 *rgba++ = (
unsigned char)R;
1419 *rgba++ = (
unsigned char)G;
1420 *rgba++ = (
unsigned char)B;
1442 *rgba++ = (
unsigned char)R;
1443 *rgba++ = (
unsigned char)G;
1444 *rgba++ = (
unsigned char)B;
1466 *rgba++ = (
unsigned char)R;
1467 *rgba++ = (
unsigned char)G;
1468 *rgba++ = (
unsigned char)B;
1473 unsigned int i = 0, j = 0;
1474 unsigned char r, g, b;
1475 while (j < numpixels * 3 / 2) {
1477 YUVToRGB(yuv[j + 1], yuv[j], yuv[j + 3], r, g, b);
1484 YUVToRGB(yuv[j + 2], yuv[j], yuv[j + 3], r, g, b);
1491 YUVToRGB(yuv[j + 4], yuv[j], yuv[j + 3], r, g, b);
1498 YUVToRGB(yuv[j + 5], yuv[j], yuv[j + 3], r, g, b);
1523 for (
unsigned int i = size / 2; i; i--) {
1524 int U = (int)((*yuv++ - 128) * 0.354);
1527 int V = (int)((*yuv++ - 128) * 0.707);
1551 *rgba++ = (
unsigned char)R;
1552 *rgba++ = (
unsigned char)G;
1553 *rgba++ = (
unsigned char)B;
1575 *rgba++ = (
unsigned char)R;
1576 *rgba++ = (
unsigned char)G;
1577 *rgba++ = (
unsigned char)B;
1583 unsigned int i = 0, j = 0;
1584 unsigned char r, g, b;
1586 while (j < size * 2) {
1588 YUVToRGB(yuv[j + 1], yuv[j], yuv[j + 2], r, g, b);
1595 YUVToRGB(yuv[j + 3], yuv[j], yuv[j + 2], r, g, b);
1614 unsigned int i = 0, j = 0;
1615 while (j < size * 3 / 2) {
1616 grey[i] = yuv[j + 1];
1617 grey[i + 1] = yuv[j + 2];
1618 grey[i + 2] = yuv[j + 4];
1619 grey[i + 3] = yuv[j + 5];
1639 for (
unsigned int i = size / 2; i; i--) {
1640 int U = (int)((*yuv++ - 128) * 0.354);
1643 int V = (int)((*yuv++ - 128) * 0.707);
1667 *rgb++ = (
unsigned char)R;
1668 *rgb++ = (
unsigned char)G;
1669 *rgb++ = (
unsigned char)B;
1690 *rgb++ = (
unsigned char)R;
1691 *rgb++ = (
unsigned char)G;
1692 *rgb++ = (
unsigned char)B;
1697 unsigned int i = 0, j = 0;
1698 unsigned char r, g, b;
1700 while (j < size * 2) {
1702 YUVToRGB(yuv[j + 1], yuv[j], yuv[j + 2], r, g, b);
1708 YUVToRGB(yuv[j + 3], yuv[j], yuv[j + 2], r, g, b);
1728 unsigned int i = 0, j = 0;
1730 while (j < size * 2) {
1731 grey[i++] = yuv[j + 1];
1732 grey[i++] = yuv[j + 3];
1747 for (
unsigned int i = size / 4; i; i--) {
1748 int U = (int)((*yuv++ - 128) * 0.354);
1752 int V = (int)((*yuv++ - 128) * 0.707);
1780 *rgb++ = (
unsigned char)R;
1781 *rgb++ = (
unsigned char)G;
1782 *rgb++ = (
unsigned char)B;
1803 *rgb++ = (
unsigned char)R;
1804 *rgb++ = (
unsigned char)G;
1805 *rgb++ = (
unsigned char)B;
1826 *rgb++ = (
unsigned char)R;
1827 *rgb++ = (
unsigned char)G;
1828 *rgb++ = (
unsigned char)B;
1849 *rgb++ = (
unsigned char)R;
1850 *rgb++ = (
unsigned char)G;
1851 *rgb++ = (
unsigned char)B;
1856 unsigned int i = 0, j = 0;
1857 unsigned char r, g, b;
1859 while (j < size * 3 / 2) {
1860 YUVToRGB(yuv[j + 1], yuv[j], yuv[j + 3], r, g, b);
1866 YUVToRGB(yuv[j + 2], yuv[j], yuv[j + 3], r, g, b);
1872 YUVToRGB(yuv[j + 4], yuv[j], yuv[j + 3], r, g, b);
1878 YUVToRGB(yuv[j + 5], yuv[j], yuv[j + 3], r, g, b);
1900 int U, V, R, G, B, V2, U5, UV;
1902 unsigned int size = width * height;
1903 unsigned char *iU = yuv + size;
1904 unsigned char *iV = yuv + 5 * size / 4;
1905 for (
unsigned int i = 0; i < height / 2; i++) {
1906 for (
unsigned int j = 0; j < width / 2; j++) {
1907 U = (int)((*iU++ - 128) * 0.354);
1909 V = (int)((*iV++ - 128) * 0.707);
1914 yuv = yuv + width - 1;
1917 yuv = yuv - width + 1;
1941 *rgba++ = (
unsigned char)R;
1942 *rgba++ = (
unsigned char)G;
1943 *rgba++ = (
unsigned char)B;
1965 *rgba++ = (
unsigned char)R;
1966 *rgba++ = (
unsigned char)G;
1967 *rgba++ = (
unsigned char)B;
1969 rgba = rgba + 4 * width - 7;
1990 *rgba++ = (
unsigned char)R;
1991 *rgba++ = (
unsigned char)G;
1992 *rgba++ = (
unsigned char)B;
2014 *rgba++ = (
unsigned char)R;
2015 *rgba++ = (
unsigned char)G;
2016 *rgba++ = (
unsigned char)B;
2018 rgba = rgba - 4 * width + 1;
2032 int U, V, R, G, B, V2, U5, UV;
2034 unsigned int size = width * height;
2035 unsigned char *iU = yuv + size;
2036 unsigned char *iV = yuv + 5 * size / 4;
2037 for (
unsigned int i = 0; i < height / 2; i++) {
2038 for (
unsigned int j = 0; j < width / 2; j++) {
2039 U = (int)((*iU++ - 128) * 0.354);
2041 V = (int)((*iV++ - 128) * 0.707);
2046 yuv = yuv + width - 1;
2049 yuv = yuv - width + 1;
2073 *rgb++ = (
unsigned char)R;
2074 *rgb++ = (
unsigned char)G;
2075 *rgb++ = (
unsigned char)B;
2096 *rgb++ = (
unsigned char)R;
2097 *rgb++ = (
unsigned char)G;
2098 *rgb = (
unsigned char)B;
2099 rgb = rgb + 3 * width - 5;
2120 *rgb++ = (
unsigned char)R;
2121 *rgb++ = (
unsigned char)G;
2122 *rgb++ = (
unsigned char)B;
2143 *rgb++ = (
unsigned char)R;
2144 *rgb++ = (
unsigned char)G;
2145 *rgb = (
unsigned char)B;
2146 rgb = rgb - 3 * width + 1;
2160 for (
unsigned int i = 0; i < size; i++) {
2173 for (
unsigned int i = 0; i < size; i++) {
2174 int U = (int)((*yuv++ - 128) * 0.354);
2177 int V = (int)((*yuv++ - 128) * 0.707);
2203 *rgba++ = (
unsigned char)R;
2204 *rgba++ = (
unsigned char)G;
2205 *rgba++ = (
unsigned char)B;
2216 for (
unsigned int i = 0; i < size; i++) {
2217 int U = (int)((*yuv++ - 128) * 0.354);
2220 int V = (int)((*yuv++ - 128) * 0.707);
2246 *rgb++ = (
unsigned char)R;
2247 *rgb++ = (
unsigned char)G;
2248 *rgb++ = (
unsigned char)B;
2260 for (
unsigned int i = 0; i < size; i++) {
2276 int U, V, R, G, B, V2, U5, UV;
2278 unsigned int size = width * height;
2279 unsigned char *iV = yuv + size;
2280 unsigned char *iU = yuv + 5 * size / 4;
2281 for (
unsigned int i = 0; i < height / 2; i++) {
2282 for (
unsigned int j = 0; j < width / 2; j++) {
2283 U = (int)((*iU++ - 128) * 0.354);
2285 V = (int)((*iV++ - 128) * 0.707);
2290 yuv = yuv + width - 1;
2293 yuv = yuv - width + 1;
2317 *rgba++ = (
unsigned char)R;
2318 *rgba++ = (
unsigned char)G;
2319 *rgba++ = (
unsigned char)B;
2341 *rgba++ = (
unsigned char)R;
2342 *rgba++ = (
unsigned char)G;
2343 *rgba++ = (
unsigned char)B;
2345 rgba = rgba + 4 * width - 7;
2366 *rgba++ = (
unsigned char)R;
2367 *rgba++ = (
unsigned char)G;
2368 *rgba++ = (
unsigned char)B;
2390 *rgba++ = (
unsigned char)R;
2391 *rgba++ = (
unsigned char)G;
2392 *rgba++ = (
unsigned char)B;
2394 rgba = rgba - 4 * width + 1;
2408 int U, V, R, G, B, V2, U5, UV;
2410 unsigned int size = width * height;
2411 unsigned char *iV = yuv + size;
2412 unsigned char *iU = yuv + 5 * size / 4;
2413 for (
unsigned int i = 0; i < height / 2; i++) {
2414 for (
unsigned int j = 0; j < width / 2; j++) {
2415 U = (int)((*iU++ - 128) * 0.354);
2417 V = (int)((*iV++ - 128) * 0.707);
2422 yuv = yuv + width - 1;
2425 yuv = yuv - width + 1;
2449 *rgb++ = (
unsigned char)R;
2450 *rgb++ = (
unsigned char)G;
2451 *rgb++ = (
unsigned char)B;
2472 *rgb++ = (
unsigned char)R;
2473 *rgb++ = (
unsigned char)G;
2474 *rgb = (
unsigned char)B;
2475 rgb = rgb + 3 * width - 5;
2496 *rgb++ = (
unsigned char)R;
2497 *rgb++ = (
unsigned char)G;
2498 *rgb++ = (
unsigned char)B;
2519 *rgb++ = (
unsigned char)R;
2520 *rgb++ = (
unsigned char)G;
2521 *rgb = (
unsigned char)B;
2522 rgb = rgb - 3 * width + 1;
2539 int U, V, R, G, B, V2, U5, UV;
2540 int Y0, Y1, Y2, Y3, Y4, Y5, Y6, Y7, Y8, Y9, Y10, Y11, Y12, Y13, Y14, Y15;
2541 unsigned int size = width * height;
2542 unsigned char *iV = yuv + size;
2543 unsigned char *iU = yuv + 17 * size / 16;
2544 for (
unsigned int i = 0; i < height / 4; i++) {
2545 for (
unsigned int j = 0; j < width / 4; j++) {
2546 U = (int)((*iU++ - 128) * 0.354);
2548 V = (int)((*iV++ - 128) * 0.707);
2555 yuv = yuv + width - 3;
2560 yuv = yuv + width - 3;
2565 yuv = yuv + width - 3;
2570 yuv = yuv - 3 * width + 1;
2594 *rgba++ = (
unsigned char)R;
2595 *rgba++ = (
unsigned char)G;
2596 *rgba++ = (
unsigned char)B;
2618 *rgba++ = (
unsigned char)R;
2619 *rgba++ = (
unsigned char)G;
2620 *rgba++ = (
unsigned char)B;
2642 *rgba++ = (
unsigned char)R;
2643 *rgba++ = (
unsigned char)G;
2644 *rgba++ = (
unsigned char)B;
2666 *rgba++ = (
unsigned char)R;
2667 *rgba++ = (
unsigned char)G;
2668 *rgba++ = (
unsigned char)B;
2670 rgba = rgba + 4 * width - 15;
2690 *rgba++ = (
unsigned char)R;
2691 *rgba++ = (
unsigned char)G;
2692 *rgba++ = (
unsigned char)B;
2714 *rgba++ = (
unsigned char)R;
2715 *rgba++ = (
unsigned char)G;
2716 *rgba++ = (
unsigned char)B;
2738 *rgba++ = (
unsigned char)R;
2739 *rgba++ = (
unsigned char)G;
2740 *rgba++ = (
unsigned char)B;
2762 *rgba++ = (
unsigned char)R;
2763 *rgba++ = (
unsigned char)G;
2764 *rgba++ = (
unsigned char)B;
2766 rgba = rgba + 4 * width - 15;
2786 *rgba++ = (
unsigned char)R;
2787 *rgba++ = (
unsigned char)G;
2788 *rgba++ = (
unsigned char)B;
2810 *rgba++ = (
unsigned char)R;
2811 *rgba++ = (
unsigned char)G;
2812 *rgba++ = (
unsigned char)B;
2834 *rgba++ = (
unsigned char)R;
2835 *rgba++ = (
unsigned char)G;
2836 *rgba++ = (
unsigned char)B;
2858 *rgba++ = (
unsigned char)R;
2859 *rgba++ = (
unsigned char)G;
2860 *rgba++ = (
unsigned char)B;
2862 rgba = rgba + 4 * width - 15;
2882 *rgba++ = (
unsigned char)R;
2883 *rgba++ = (
unsigned char)G;
2884 *rgba++ = (
unsigned char)B;
2906 *rgba++ = (
unsigned char)R;
2907 *rgba++ = (
unsigned char)G;
2908 *rgba++ = (
unsigned char)B;
2930 *rgba++ = (
unsigned char)R;
2931 *rgba++ = (
unsigned char)G;
2932 *rgba++ = (
unsigned char)B;
2954 *rgba++ = (
unsigned char)R;
2955 *rgba++ = (
unsigned char)G;
2956 *rgba++ = (
unsigned char)B;
2958 rgba = rgba - 12 * width + 1;
2972 int U, V, R, G, B, V2, U5, UV;
2973 int Y0, Y1, Y2, Y3, Y4, Y5, Y6, Y7, Y8, Y9, Y10, Y11, Y12, Y13, Y14, Y15;
2974 unsigned int size = width * height;
2975 unsigned char *iV = yuv + size;
2976 unsigned char *iU = yuv + 17 * size / 16;
2977 for (
unsigned int i = 0; i < height / 4; i++) {
2978 for (
unsigned int j = 0; j < width / 4; j++) {
2979 U = (int)((*iU++ - 128) * 0.354);
2981 V = (int)((*iV++ - 128) * 0.707);
2988 yuv = yuv + width - 3;
2993 yuv = yuv + width - 3;
2998 yuv = yuv + width - 3;
3003 yuv = yuv - 3 * width + 1;
3027 *rgb++ = (
unsigned char)R;
3028 *rgb++ = (
unsigned char)G;
3029 *rgb++ = (
unsigned char)B;
3050 *rgb++ = (
unsigned char)R;
3051 *rgb++ = (
unsigned char)G;
3052 *rgb++ = (
unsigned char)B;
3073 *rgb++ = (
unsigned char)R;
3074 *rgb++ = (
unsigned char)G;
3075 *rgb++ = (
unsigned char)B;
3096 *rgb++ = (
unsigned char)R;
3097 *rgb++ = (
unsigned char)G;
3098 *rgb = (
unsigned char)B;
3099 rgb = rgb + 3 * width - 11;
3119 *rgb++ = (
unsigned char)R;
3120 *rgb++ = (
unsigned char)G;
3121 *rgb++ = (
unsigned char)B;
3142 *rgb++ = (
unsigned char)R;
3143 *rgb++ = (
unsigned char)G;
3144 *rgb++ = (
unsigned char)B;
3165 *rgb++ = (
unsigned char)R;
3166 *rgb++ = (
unsigned char)G;
3167 *rgb++ = (
unsigned char)B;
3188 *rgb++ = (
unsigned char)R;
3189 *rgb++ = (
unsigned char)G;
3190 *rgb = (
unsigned char)B;
3191 rgb = rgb + 3 * width - 11;
3211 *rgb++ = (
unsigned char)R;
3212 *rgb++ = (
unsigned char)G;
3213 *rgb++ = (
unsigned char)B;
3234 *rgb++ = (
unsigned char)R;
3235 *rgb++ = (
unsigned char)G;
3236 *rgb++ = (
unsigned char)B;
3257 *rgb++ = (
unsigned char)R;
3258 *rgb++ = (
unsigned char)G;
3259 *rgb++ = (
unsigned char)B;
3280 *rgb++ = (
unsigned char)R;
3281 *rgb++ = (
unsigned char)G;
3282 *rgb = (
unsigned char)B;
3283 rgb = rgb + 3 * width - 11;
3303 *rgb++ = (
unsigned char)R;
3304 *rgb++ = (
unsigned char)G;
3305 *rgb++ = (
unsigned char)B;
3326 *rgb++ = (
unsigned char)R;
3327 *rgb++ = (
unsigned char)G;
3328 *rgb++ = (
unsigned char)B;
3349 *rgb++ = (
unsigned char)R;
3350 *rgb++ = (
unsigned char)G;
3351 *rgb++ = (
unsigned char)B;
3372 *rgb++ = (
unsigned char)R;
3373 *rgb++ = (
unsigned char)G;
3374 *rgb++ = (
unsigned char)B;
3375 rgb = rgb - 9 * width + 1;
3391 unsigned char *pt_input = rgb;
3392 unsigned char *pt_end = rgb + 3 * size;
3393 unsigned char *pt_output = rgba;
3395 while (pt_input != pt_end) {
3396 *(pt_output++) = *(pt_input++);
3397 *(pt_output++) = *(pt_input++);
3398 *(pt_output++) = *(pt_input++);
3412 unsigned char *pt_input = rgba;
3413 unsigned char *pt_end = rgba + 4 * size;
3414 unsigned char *pt_output = rgb;
3416 while (pt_input != pt_end) {
3417 *(pt_output++) = *(pt_input++);
3418 *(pt_output++) = *(pt_input++);
3419 *(pt_output++) = *(pt_input++);
3432 #if !VISP_HAVE_SSSE3 3442 const __m128i mask_R1 = _mm_set_epi8(-1, -1, -1, -1, 15, -1, 12, -1, 9, -1, 6, -1, 3, -1, 0, -1);
3443 const __m128i mask_R2 = _mm_set_epi8(5, -1, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1);
3444 const __m128i mask_R3 = _mm_set_epi8(-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 14, -1, 11, -1, 8, -1);
3445 const __m128i mask_R4 = _mm_set_epi8(13, -1, 10, -1, 7, -1, 4, -1, 1, -1, -1, -1, -1, -1, -1, -1);
3448 const __m128i mask_G1 = _mm_set_epi8(-1, -1, -1, -1, -1, -1, 13, -1, 10, -1, 7, -1, 4, -1, 1, -1);
3449 const __m128i mask_G2 = _mm_set_epi8(6, -1, 3, -1, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1);
3450 const __m128i mask_G3 = _mm_set_epi8(-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 15, -1, 12, -1, 9, -1);
3451 const __m128i mask_G4 = _mm_set_epi8(14, -1, 11, -1, 8, -1, 5, -1, 2, -1, -1, -1, -1, -1, -1, -1);
3454 const __m128i mask_B1 = _mm_set_epi8(-1, -1, -1, -1, -1, -1, 14, -1, 11, -1, 8, -1, 5, -1, 2, -1);
3455 const __m128i mask_B2 = _mm_set_epi8(7, -1, 4, -1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1);
3456 const __m128i mask_B3 = _mm_set_epi8(-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 13, -1, 10, -1);
3457 const __m128i mask_B4 = _mm_set_epi8(15, -1, 12, -1, 9, -1, 6, -1, 3, -1, 0, -1, -1, -1, -1, -1);
3460 const __m128i mask_low1 = _mm_set_epi8(-1, -1, -1, -1, -1, -1, -1, -1, 15, 13, 11, 9, 7, 5, 3, 1);
3461 const __m128i mask_low2 = _mm_set_epi8(15, 13, 11, 9, 7, 5, 3, 1, -1, -1, -1, -1, -1, -1, -1, -1);
3464 const __m128i coeff_R = _mm_set_epi16(13933, 13933, 13933, 13933, 13933, 13933, 13933, 13933);
3465 const __m128i coeff_G = _mm_set_epi16((
short int)46871, (
short int)46871, (
short int)46871, (
short int)46871,
3466 (
short int)46871, (
short int)46871, (
short int)46871, (
short int)46871);
3467 const __m128i coeff_B = _mm_set_epi16(4732, 4732, 4732, 4732, 4732, 4732, 4732, 4732);
3469 for (; i <= size - 16; i += 16) {
3471 const __m128i data1 = _mm_loadu_si128((
const __m128i *)rgb);
3472 const __m128i data2 = _mm_loadu_si128((
const __m128i *)(rgb + 16));
3473 const __m128i data3 = _mm_loadu_si128((
const __m128i *)(rgb + 32));
3475 const __m128i red_0_7 = _mm_or_si128(_mm_shuffle_epi8(data1, mask_R1), _mm_shuffle_epi8(data2, mask_R2));
3476 const __m128i green_0_7 = _mm_or_si128(_mm_shuffle_epi8(data1, mask_G1), _mm_shuffle_epi8(data2, mask_G2));
3477 const __m128i blue_0_7 = _mm_or_si128(_mm_shuffle_epi8(data1, mask_B1), _mm_shuffle_epi8(data2, mask_B2));
3479 const __m128i grays_0_7 =
3480 _mm_adds_epu16(_mm_mulhi_epu16(red_0_7, coeff_R),
3481 _mm_adds_epu16(_mm_mulhi_epu16(green_0_7, coeff_G), _mm_mulhi_epu16(blue_0_7, coeff_B)));
3483 const __m128i red_8_15 = _mm_or_si128(_mm_shuffle_epi8(data2, mask_R3), _mm_shuffle_epi8(data3, mask_R4));
3484 const __m128i green_8_15 = _mm_or_si128(_mm_shuffle_epi8(data2, mask_G3), _mm_shuffle_epi8(data3, mask_G4));
3485 const __m128i blue_8_15 = _mm_or_si128(_mm_shuffle_epi8(data2, mask_B3), _mm_shuffle_epi8(data3, mask_B4));
3487 const __m128i grays_8_15 =
3488 _mm_adds_epu16(_mm_mulhi_epu16(red_8_15, coeff_R),
3489 _mm_adds_epu16(_mm_mulhi_epu16(green_8_15, coeff_G), _mm_mulhi_epu16(blue_8_15, coeff_B)));
3491 _mm_storeu_si128((__m128i *)grey,
3492 _mm_or_si128(_mm_shuffle_epi8(grays_0_7, mask_low1), _mm_shuffle_epi8(grays_8_15, mask_low2)));
3499 for (; i < size; i++) {
3500 *grey = (
unsigned char)(0.2126 * (*rgb) + 0.7152 * (*(rgb + 1)) + 0.0722 * (*(rgb + 2)));
3507 unsigned char *pt_input = rgb;
3508 unsigned char *pt_end = rgb + size * 3;
3509 unsigned char *pt_output = grey;
3511 while (pt_input != pt_end) {
3512 *pt_output = (
unsigned char)(0.2126 * (*pt_input) + 0.7152 * (*(pt_input + 1)) + 0.0722 * (*(pt_input + 2)));
3528 #if !VISP_HAVE_SSSE3 3538 const __m128i mask_R1 = _mm_set_epi8(-1, -1, -1, -1, -1, -1, -1, -1, 12, -1, 8, -1, 4, -1, 0, -1);
3539 const __m128i mask_R2 = _mm_set_epi8(12, -1, 8, -1, 4, -1, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1);
3542 const __m128i mask_G1 = _mm_set_epi8(-1, -1, -1, -1, -1, -1, -1, -1, 13, -1, 9, -1, 5, -1, 1, -1);
3543 const __m128i mask_G2 = _mm_set_epi8(13, -1, 9, -1, 5, -1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1);
3546 const __m128i mask_B1 = _mm_set_epi8(-1, -1, -1, -1, -1, -1, -1, -1, 14, -1, 10, -1, 6, -1, 2, -1);
3547 const __m128i mask_B2 = _mm_set_epi8(14, -1, 10, -1, 6, -1, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1);
3550 const __m128i mask_low1 = _mm_set_epi8(-1, -1, -1, -1, -1, -1, -1, -1, 15, 13, 11, 9, 7, 5, 3, 1);
3551 const __m128i mask_low2 = _mm_set_epi8(15, 13, 11, 9, 7, 5, 3, 1, -1, -1, -1, -1, -1, -1, -1, -1);
3554 const __m128i coeff_R = _mm_set_epi16(13933, 13933, 13933, 13933, 13933, 13933, 13933, 13933);
3555 const __m128i coeff_G = _mm_set_epi16((
short int)46871, (
short int)46871, (
short int)46871, (
short int)46871,
3556 (
short int)46871, (
short int)46871, (
short int)46871, (
short int)46871);
3557 const __m128i coeff_B = _mm_set_epi16(4732, 4732, 4732, 4732, 4732, 4732, 4732, 4732);
3559 for (; i <= size - 16; i += 16) {
3561 const __m128i data1 = _mm_loadu_si128((
const __m128i *)rgba);
3562 const __m128i data2 = _mm_loadu_si128((
const __m128i *)(rgba + 16));
3564 const __m128i red_0_7 = _mm_or_si128(_mm_shuffle_epi8(data1, mask_R1), _mm_shuffle_epi8(data2, mask_R2));
3565 const __m128i green_0_7 = _mm_or_si128(_mm_shuffle_epi8(data1, mask_G1), _mm_shuffle_epi8(data2, mask_G2));
3566 const __m128i blue_0_7 = _mm_or_si128(_mm_shuffle_epi8(data1, mask_B1), _mm_shuffle_epi8(data2, mask_B2));
3568 const __m128i grays_0_7 =
3569 _mm_adds_epu16(_mm_mulhi_epu16(red_0_7, coeff_R),
3570 _mm_adds_epu16(_mm_mulhi_epu16(green_0_7, coeff_G), _mm_mulhi_epu16(blue_0_7, coeff_B)));
3573 const __m128i data3 = _mm_loadu_si128((
const __m128i *)(rgba + 32));
3574 const __m128i data4 = _mm_loadu_si128((
const __m128i *)(rgba + 48));
3576 const __m128i red_8_15 = _mm_or_si128(_mm_shuffle_epi8(data3, mask_R1), _mm_shuffle_epi8(data4, mask_R2));
3577 const __m128i green_8_15 = _mm_or_si128(_mm_shuffle_epi8(data3, mask_G1), _mm_shuffle_epi8(data4, mask_G2));
3578 const __m128i blue_8_15 = _mm_or_si128(_mm_shuffle_epi8(data3, mask_B1), _mm_shuffle_epi8(data4, mask_B2));
3580 const __m128i grays_8_15 =
3581 _mm_adds_epu16(_mm_mulhi_epu16(red_8_15, coeff_R),
3582 _mm_adds_epu16(_mm_mulhi_epu16(green_8_15, coeff_G), _mm_mulhi_epu16(blue_8_15, coeff_B)));
3584 _mm_storeu_si128((__m128i *)grey,
3585 _mm_or_si128(_mm_shuffle_epi8(grays_0_7, mask_low1), _mm_shuffle_epi8(grays_8_15, mask_low2)));
3592 for (; i < size; i++) {
3593 *grey = (
unsigned char)(0.2126 * (*rgba) + 0.7152 * (*(rgba + 1)) + 0.0722 * (*(rgba + 2)));
3600 unsigned char *pt_input = rgba;
3601 unsigned char *pt_end = rgba + size * 4;
3602 unsigned char *pt_output = grey;
3604 while (pt_input != pt_end) {
3605 *pt_output = (
unsigned char)(0.2126 * (*pt_input) + 0.7152 * (*(pt_input + 1)) + 0.0722 * (*(pt_input + 2)));
3619 unsigned char *pt_input = grey;
3620 unsigned char *pt_end = grey + size;
3621 unsigned char *pt_output = rgba;
3623 while (pt_input != pt_end) {
3624 unsigned char p = *pt_input;
3626 *(pt_output + 1) = p;
3627 *(pt_output + 2) = p;
3641 unsigned char *pt_input = grey;
3642 unsigned char *pt_end = grey + size;
3643 unsigned char *pt_output = rgb;
3645 while (pt_input != pt_end) {
3646 unsigned char p = *pt_input;
3648 *(pt_output + 1) = p;
3649 *(pt_output + 2) = p;
3668 int lineStep = (flip) ? -(
int)(width * 3) : (
int)(width * 3);
3671 unsigned char *src = (flip) ? (bgr + (width * height * 3) + lineStep) : bgr;
3673 for (
unsigned int i = 0; i < height; i++) {
3674 unsigned char *line = src;
3675 for (
unsigned int j = 0; j < width; j++) {
3676 *rgba++ = *(line + 2);
3677 *rgba++ = *(line + 1);
3678 *rgba++ = *(line + 0);
3697 #if !VISP_HAVE_SSSE3 3704 const __m128i mask_B1 = _mm_set_epi8(-1, -1, -1, -1, 15, -1, 12, -1, 9, -1, 6, -1, 3, -1, 0, -1);
3705 const __m128i mask_B2 = _mm_set_epi8(5, -1, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1);
3706 const __m128i mask_B3 = _mm_set_epi8(-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 14, -1, 11, -1, 8, -1);
3707 const __m128i mask_B4 = _mm_set_epi8(13, -1, 10, -1, 7, -1, 4, -1, 1, -1, -1, -1, -1, -1, -1, -1);
3710 const __m128i mask_G1 = _mm_set_epi8(-1, -1, -1, -1, -1, -1, 13, -1, 10, -1, 7, -1, 4, -1, 1, -1);
3711 const __m128i mask_G2 = _mm_set_epi8(6, -1, 3, -1, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1);
3712 const __m128i mask_G3 = _mm_set_epi8(-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 15, -1, 12, -1, 9, -1);
3713 const __m128i mask_G4 = _mm_set_epi8(14, -1, 11, -1, 8, -1, 5, -1, 2, -1, -1, -1, -1, -1, -1, -1);
3716 const __m128i mask_R1 = _mm_set_epi8(-1, -1, -1, -1, -1, -1, 14, -1, 11, -1, 8, -1, 5, -1, 2, -1);
3717 const __m128i mask_R2 = _mm_set_epi8(7, -1, 4, -1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1);
3718 const __m128i mask_R3 = _mm_set_epi8(-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 13, -1, 10, -1);
3719 const __m128i mask_R4 = _mm_set_epi8(15, -1, 12, -1, 9, -1, 6, -1, 3, -1, 0, -1, -1, -1, -1, -1);
3722 const __m128i mask_low1 = _mm_set_epi8(-1, -1, -1, -1, -1, -1, -1, -1, 15, 13, 11, 9, 7, 5, 3, 1);
3723 const __m128i mask_low2 = _mm_set_epi8(15, 13, 11, 9, 7, 5, 3, 1, -1, -1, -1, -1, -1, -1, -1, -1);
3746 const __m128i coeff_R = _mm_set_epi16(13933, 13933, 13933, 13933, 13933, 13933, 13933, 13933);
3747 const __m128i coeff_G = _mm_set_epi16((
short int)46871, (
short int)46871, (
short int)46871, (
short int)46871,
3748 (
short int)46871, (
short int)46871, (
short int)46871, (
short int)46871);
3749 const __m128i coeff_B = _mm_set_epi16(4732, 4732, 4732, 4732, 4732, 4732, 4732, 4732);
3752 int i = ((int)height) - 1;
3753 int lineStep = -(int)(width * 3);
3754 bgr = bgr + (width * (height - 1) * 3);
3756 unsigned char *linePtr = bgr;
3757 unsigned char r, g, b;
3760 for (; i >= 0; i--) {
3763 for (; j <= width - 16; j += 16) {
3765 const __m128i data1 = _mm_loadu_si128((
const __m128i *)bgr);
3766 const __m128i data2 = _mm_loadu_si128((
const __m128i *)(bgr + 16));
3767 const __m128i data3 = _mm_loadu_si128((
const __m128i *)(bgr + 32));
3769 const __m128i red_0_7 = _mm_or_si128(_mm_shuffle_epi8(data1, mask_R1), _mm_shuffle_epi8(data2, mask_R2));
3770 const __m128i green_0_7 = _mm_or_si128(_mm_shuffle_epi8(data1, mask_G1), _mm_shuffle_epi8(data2, mask_G2));
3771 const __m128i blue_0_7 = _mm_or_si128(_mm_shuffle_epi8(data1, mask_B1), _mm_shuffle_epi8(data2, mask_B2));
3773 const __m128i grays_0_7 =
3774 _mm_adds_epu16(_mm_mulhi_epu16(red_0_7, coeff_R),
3775 _mm_adds_epu16(_mm_mulhi_epu16(green_0_7, coeff_G), _mm_mulhi_epu16(blue_0_7, coeff_B)));
3777 const __m128i red_8_15 = _mm_or_si128(_mm_shuffle_epi8(data2, mask_R3), _mm_shuffle_epi8(data3, mask_R4));
3778 const __m128i green_8_15 = _mm_or_si128(_mm_shuffle_epi8(data2, mask_G3), _mm_shuffle_epi8(data3, mask_G4));
3779 const __m128i blue_8_15 = _mm_or_si128(_mm_shuffle_epi8(data2, mask_B3), _mm_shuffle_epi8(data3, mask_B4));
3781 const __m128i grays_8_15 =
3782 _mm_adds_epu16(_mm_mulhi_epu16(red_8_15, coeff_R), _mm_adds_epu16(_mm_mulhi_epu16(green_8_15, coeff_G),
3783 _mm_mulhi_epu16(blue_8_15, coeff_B)));
3785 _mm_storeu_si128((__m128i *)grey, _mm_or_si128(_mm_shuffle_epi8(grays_0_7, mask_low1),
3786 _mm_shuffle_epi8(grays_8_15, mask_low2)));
3792 for (; j < width; j++) {
3796 *grey++ = (
unsigned char)(0.2126 * r + 0.7152 * g + 0.0722 * b);
3799 linePtr += lineStep;
3804 for (; i >= 0; i--) {
3805 for (
unsigned int j = 0; j < width; j++) {
3809 *grey++ = (
unsigned char)(0.2126 * r + 0.7152 * g + 0.0722 * b);
3812 linePtr += lineStep;
3817 unsigned int size = width * height;
3820 for (; i <= size - 16; i += 16) {
3822 const __m128i data1 = _mm_loadu_si128((
const __m128i *)bgr);
3823 const __m128i data2 = _mm_loadu_si128((
const __m128i *)(bgr + 16));
3824 const __m128i data3 = _mm_loadu_si128((
const __m128i *)(bgr + 32));
3826 const __m128i red_0_7 = _mm_or_si128(_mm_shuffle_epi8(data1, mask_R1), _mm_shuffle_epi8(data2, mask_R2));
3827 const __m128i green_0_7 = _mm_or_si128(_mm_shuffle_epi8(data1, mask_G1), _mm_shuffle_epi8(data2, mask_G2));
3828 const __m128i blue_0_7 = _mm_or_si128(_mm_shuffle_epi8(data1, mask_B1), _mm_shuffle_epi8(data2, mask_B2));
3830 const __m128i grays_0_7 =
3831 _mm_adds_epu16(_mm_mulhi_epu16(red_0_7, coeff_R),
3832 _mm_adds_epu16(_mm_mulhi_epu16(green_0_7, coeff_G), _mm_mulhi_epu16(blue_0_7, coeff_B)));
3834 const __m128i red_8_15 = _mm_or_si128(_mm_shuffle_epi8(data2, mask_R3), _mm_shuffle_epi8(data3, mask_R4));
3835 const __m128i green_8_15 = _mm_or_si128(_mm_shuffle_epi8(data2, mask_G3), _mm_shuffle_epi8(data3, mask_G4));
3836 const __m128i blue_8_15 = _mm_or_si128(_mm_shuffle_epi8(data2, mask_B3), _mm_shuffle_epi8(data3, mask_B4));
3838 const __m128i grays_8_15 =
3839 _mm_adds_epu16(_mm_mulhi_epu16(red_8_15, coeff_R),
3840 _mm_adds_epu16(_mm_mulhi_epu16(green_8_15, coeff_G), _mm_mulhi_epu16(blue_8_15, coeff_B)));
3842 _mm_storeu_si128((__m128i *)grey, _mm_or_si128(_mm_shuffle_epi8(grays_0_7, mask_low1),
3843 _mm_shuffle_epi8(grays_8_15, mask_low2)));
3850 for (; i < size; i++) {
3851 *grey = (
unsigned char)(0.2126 * (*(bgr + 2)) + 0.7152 * (*(bgr + 1)) + 0.0722 * (*bgr));
3861 int lineStep = (flip) ? -(
int)(width * 3) : (
int)(width * 3);
3864 unsigned char *src = (flip) ? bgr + (width * height * 3) + lineStep : bgr;
3866 for (
unsigned int i = 0; i < height; i++) {
3867 unsigned char *line = src;
3868 for (
unsigned int j = 0; j < width; j++) {
3869 *grey++ = (
unsigned char)(0.2126 * *(line + 2) + 0.7152 * *(line + 1) + 0.0722 * *(line + 0));
3891 int lineStep = (flip) ? -(
int)(width * 3) : (
int)(width * 3);
3894 unsigned char *src = (flip) ? (rgb + (width * height * 3) + lineStep) : rgb;
3899 for (i = 0; i < height; i++) {
3900 unsigned char *line = src;
3901 for (j = 0; j < width; j++) {
3902 *rgba++ = *(line++);
3903 *rgba++ = *(line++);
3904 *rgba++ = *(line++);
3922 #if !VISP_HAVE_SSSE3 3928 int i = ((int)height) - 1;
3929 int lineStep = -(int)(width * 3);
3930 rgb = rgb + (width * (height - 1) * 3);
3932 unsigned char *linePtr = rgb;
3933 unsigned char r, g, b;
3937 const __m128i mask_R1 = _mm_set_epi8(-1, -1, -1, -1, 15, -1, 12, -1, 9, -1, 6, -1, 3, -1, 0, -1);
3938 const __m128i mask_R2 = _mm_set_epi8(5, -1, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1);
3939 const __m128i mask_R3 = _mm_set_epi8(-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 14, -1, 11, -1, 8, -1);
3940 const __m128i mask_R4 = _mm_set_epi8(13, -1, 10, -1, 7, -1, 4, -1, 1, -1, -1, -1, -1, -1, -1, -1);
3943 const __m128i mask_G1 = _mm_set_epi8(-1, -1, -1, -1, -1, -1, 13, -1, 10, -1, 7, -1, 4, -1, 1, -1);
3944 const __m128i mask_G2 = _mm_set_epi8(6, -1, 3, -1, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1);
3945 const __m128i mask_G3 = _mm_set_epi8(-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 15, -1, 12, -1, 9, -1);
3946 const __m128i mask_G4 = _mm_set_epi8(14, -1, 11, -1, 8, -1, 5, -1, 2, -1, -1, -1, -1, -1, -1, -1);
3949 const __m128i mask_B1 = _mm_set_epi8(-1, -1, -1, -1, -1, -1, 14, -1, 11, -1, 8, -1, 5, -1, 2, -1);
3950 const __m128i mask_B2 = _mm_set_epi8(7, -1, 4, -1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1);
3951 const __m128i mask_B3 = _mm_set_epi8(-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 13, -1, 10, -1);
3952 const __m128i mask_B4 = _mm_set_epi8(15, -1, 12, -1, 9, -1, 6, -1, 3, -1, 0, -1, -1, -1, -1, -1);
3955 const __m128i mask_low1 = _mm_set_epi8(-1, -1, -1, -1, -1, -1, -1, -1, 15, 13, 11, 9, 7, 5, 3, 1);
3956 const __m128i mask_low2 = _mm_set_epi8(15, 13, 11, 9, 7, 5, 3, 1, -1, -1, -1, -1, -1, -1, -1, -1);
3959 const __m128i coeff_R = _mm_set_epi16(13933, 13933, 13933, 13933, 13933, 13933, 13933, 13933);
3960 const __m128i coeff_G = _mm_set_epi16((
short int)46871, (
short int)46871, (
short int)46871, (
short int)46871,
3961 (
short int)46871, (
short int)46871, (
short int)46871, (
short int)46871);
3962 const __m128i coeff_B = _mm_set_epi16(4732, 4732, 4732, 4732, 4732, 4732, 4732, 4732);
3964 for (; i >= 0; i--) {
3967 for (; j <= width - 16; j += 16) {
3969 const __m128i data1 = _mm_loadu_si128((
const __m128i *)rgb);
3970 const __m128i data2 = _mm_loadu_si128((
const __m128i *)(rgb + 16));
3971 const __m128i data3 = _mm_loadu_si128((
const __m128i *)(rgb + 32));
3973 const __m128i red_0_7 = _mm_or_si128(_mm_shuffle_epi8(data1, mask_R1), _mm_shuffle_epi8(data2, mask_R2));
3974 const __m128i green_0_7 = _mm_or_si128(_mm_shuffle_epi8(data1, mask_G1), _mm_shuffle_epi8(data2, mask_G2));
3975 const __m128i blue_0_7 = _mm_or_si128(_mm_shuffle_epi8(data1, mask_B1), _mm_shuffle_epi8(data2, mask_B2));
3977 const __m128i grays_0_7 =
3978 _mm_adds_epu16(_mm_mulhi_epu16(red_0_7, coeff_R),
3979 _mm_adds_epu16(_mm_mulhi_epu16(green_0_7, coeff_G), _mm_mulhi_epu16(blue_0_7, coeff_B)));
3981 const __m128i red_8_15 = _mm_or_si128(_mm_shuffle_epi8(data2, mask_R3), _mm_shuffle_epi8(data3, mask_R4));
3982 const __m128i green_8_15 = _mm_or_si128(_mm_shuffle_epi8(data2, mask_G3), _mm_shuffle_epi8(data3, mask_G4));
3983 const __m128i blue_8_15 = _mm_or_si128(_mm_shuffle_epi8(data2, mask_B3), _mm_shuffle_epi8(data3, mask_B4));
3985 const __m128i grays_8_15 =
3986 _mm_adds_epu16(_mm_mulhi_epu16(red_8_15, coeff_R), _mm_adds_epu16(_mm_mulhi_epu16(green_8_15, coeff_G),
3987 _mm_mulhi_epu16(blue_8_15, coeff_B)));
3989 _mm_storeu_si128((__m128i *)grey, _mm_or_si128(_mm_shuffle_epi8(grays_0_7, mask_low1),
3990 _mm_shuffle_epi8(grays_8_15, mask_low2)));
3996 for (; j < width; j++) {
4000 *grey++ = (
unsigned char)(0.2126 * r + 0.7152 * g + 0.0722 * b);
4003 linePtr += lineStep;
4008 for (; i >= 0; i--) {
4009 for (
unsigned int j = 0; j < width; j++) {
4013 *grey++ = (
unsigned char)(0.2126 * r + 0.7152 * g + 0.0722 * b);
4016 linePtr += lineStep;
4023 int lineStep = (flip) ? -(
int)(width * 3) : (
int)(width * 3);
4026 unsigned char *src = (flip) ? rgb + (width * height * 3) + lineStep : rgb;
4033 for (i = 0; i < height; i++) {
4034 unsigned char *line = src;
4035 for (j = 0; j < width; j++) {
4039 *grey++ = (
unsigned char)(0.2126 * r + 0.7152 * g + 0.0722 * b);
4054 void vpImageConvert::computeYCbCrLUT()
4056 if (YCbCrLUTcomputed ==
false) {
4061 int aux = index - 128;
4062 vpImageConvert::vpCrr[index] = (int)(364.6610 * aux) >> 8;
4063 vpImageConvert::vpCgb[index] = (int)(-89.8779 * aux) >> 8;
4064 vpImageConvert::vpCgr[index] = (int)(-185.8154 * aux) >> 8;
4065 vpImageConvert::vpCbb[index] = (int)(460.5724 * aux) >> 8;
4068 YCbCrLUTcomputed =
true;
4095 unsigned char *pt_ycbcr = ycbcr;
4096 unsigned char *pt_rgb = rgb;
4100 vpImageConvert::computeYCbCrLUT();
4105 int val_r, val_g, val_b;
4111 val_r = *pt_ycbcr + vpImageConvert::vpCrr[*crv];
4112 val_g = *pt_ycbcr + vpImageConvert::vpCgb[*cbv] + vpImageConvert::vpCgr[*crv];
4113 val_b = *pt_ycbcr + vpImageConvert::vpCbb[*cbv];
4115 vpDEBUG_TRACE(5,
"[%d] R: %d G: %d B: %d\n", size, val_r, val_g, val_b);
4117 *pt_rgb++ = (val_r < 0) ? 0u : ((val_r > 255) ? 255u : (
unsigned char)val_r);
4118 *pt_rgb++ = (val_g < 0) ? 0u : ((val_g > 255) ? 255u : (
unsigned char)val_g);
4119 *pt_rgb++ = (val_b < 0) ? 0u : ((val_b > 255) ? 255u : (
unsigned char)val_b);
4152 unsigned char *pt_ycbcr = ycbcr;
4153 unsigned char *pt_rgba = rgba;
4157 vpImageConvert::computeYCbCrLUT();
4162 int val_r, val_g, val_b;
4168 val_r = *pt_ycbcr + vpImageConvert::vpCrr[*crv];
4169 val_g = *pt_ycbcr + vpImageConvert::vpCgb[*cbv] + vpImageConvert::vpCgr[*crv];
4170 val_b = *pt_ycbcr + vpImageConvert::vpCbb[*cbv];
4172 vpDEBUG_TRACE(5,
"[%d] R: %d G: %d B: %d\n", size, val_r, val_g, val_b);
4174 *pt_rgba++ = (val_r < 0) ? 0u : ((val_r > 255) ? 255u : (
unsigned char)val_r);
4175 *pt_rgba++ = (val_g < 0) ? 0u : ((val_g > 255) ? 255u : (
unsigned char)val_g);
4176 *pt_rgba++ = (val_b < 0) ? 0u : ((val_b > 255) ? 255u : (
unsigned char)val_b);
4201 unsigned int i = 0, j = 0;
4203 while (j < size * 2) {
4205 grey[i++] = yuv[j + 2];
4232 unsigned char *pt_ycbcr = ycrcb;
4233 unsigned char *pt_rgb = rgb;
4237 vpImageConvert::computeYCbCrLUT();
4242 int val_r, val_g, val_b;
4248 val_r = *pt_ycbcr + vpImageConvert::vpCrr[*crv];
4249 val_g = *pt_ycbcr + vpImageConvert::vpCgb[*cbv] + vpImageConvert::vpCgr[*crv];
4250 val_b = *pt_ycbcr + vpImageConvert::vpCbb[*cbv];
4252 vpDEBUG_TRACE(5,
"[%d] R: %d G: %d B: %d\n", size, val_r, val_g, val_b);
4254 *pt_rgb++ = (val_r < 0) ? 0u : ((val_r > 255) ? 255u : (
unsigned char)val_r);
4255 *pt_rgb++ = (val_g < 0) ? 0u : ((val_g > 255) ? 255u : (
unsigned char)val_g);
4256 *pt_rgb++ = (val_b < 0) ? 0u : ((val_b > 255) ? 255u : (
unsigned char)val_b);
4287 unsigned char *pt_ycbcr = ycrcb;
4288 unsigned char *pt_rgba = rgba;
4292 vpImageConvert::computeYCbCrLUT();
4297 int val_r, val_g, val_b;
4303 val_r = *pt_ycbcr + vpImageConvert::vpCrr[*crv];
4304 val_g = *pt_ycbcr + vpImageConvert::vpCgb[*cbv] + vpImageConvert::vpCgr[*crv];
4305 val_b = *pt_ycbcr + vpImageConvert::vpCbb[*cbv];
4307 vpDEBUG_TRACE(5,
"[%d] R: %d G: %d B: %d\n", size, val_r, val_g, val_b);
4309 *pt_rgba++ = (val_r < 0) ? 0u : ((val_r > 255) ? 255u : (
unsigned char)val_r);
4310 *pt_rgba++ = (val_g < 0) ? 0u : ((val_g > 255) ? 255u : (
unsigned char)val_g);
4311 *pt_rgba++ = (val_b < 0) ? 0u : ((val_b > 255) ? 255u : (
unsigned char)val_b);
4358 unsigned int width = src.
getWidth();
4359 unsigned char *input;
4376 for (
unsigned int j = 0; j < 4; j++) {
4377 if (tabChannel[j] != NULL) {
4378 if (tabChannel[j]->getHeight() != height || tabChannel[j]->getWidth() != width) {
4379 tabChannel[j]->
resize(height, width);
4381 dst = (
unsigned char *)tabChannel[j]->bitmap;
4383 input = (
unsigned char *)src.
bitmap + j;
4388 for (; i < n; i += 4) {
4405 for (; i < n; i++) {
4426 std::map<unsigned int, unsigned int> mapOfWidths, mapOfHeights;
4447 if (mapOfWidths.size() == 1 && mapOfHeights.size() == 1) {
4448 unsigned int width = mapOfWidths.begin()->first;
4449 unsigned int height = mapOfHeights.begin()->first;
4451 RGBa.
resize(height, width);
4453 unsigned int size = width * height;
4454 for (
unsigned int i = 0; i < size; i++) {
4488 int i = (((int)size) << 1) - 1;
4489 int j = (int)size - 1;
4492 int y = grey16[i--];
4493 grey[j--] =
static_cast<unsigned char>((y + (grey16[i--] << 8)) >> 8);
4511 int i = (((int)size) << 1) - 1;
4512 int j = (int)(size * 4 - 1);
4515 int y = grey16[i--];
4516 unsigned char v =
static_cast<unsigned char>((y + (grey16[i--] << 8)) >> 8);
4524 void vpImageConvert::HSV2RGB(
const double *hue_,
const double *saturation_,
const double *value_,
unsigned char *rgb,
4525 unsigned int size,
unsigned int step)
4527 for (
unsigned int i = 0; i < size; i++) {
4528 double hue = hue_[i], saturation = saturation_[i], value = value_[i];
4530 if (
vpMath::equal(saturation, 0.0, std::numeric_limits<double>::epsilon())) {
4534 double h = hue * 6.0;
4535 double s = saturation;
4538 if (
vpMath::equal(h, 6.0, std::numeric_limits<double>::epsilon())) {
4542 double f = h - (int)h;
4543 double p = v * (1.0 - s);
4544 double q = v * (1.0 - s * f);
4545 double t = v * (1.0 - s * (1.0 - f));
4587 rgb[i * step + 1] = (
unsigned char)
vpMath::round(saturation * 255.0);
4588 rgb[i * step + 2] = (
unsigned char)
vpMath::round(value * 255.0);
4594 void vpImageConvert::RGB2HSV(
const unsigned char *rgb,
double *hue,
double *saturation,
double *value,
4595 unsigned int size,
unsigned int step)
4597 for (
unsigned int i = 0; i < size; i++) {
4598 double red, green, blue;
4602 red = rgb[i * step] / 255.0;
4603 green = rgb[i * step + 1] / 255.0;
4604 blue = rgb[i * step + 2] / 255.0;
4607 max = ((std::max))(red, blue);
4608 min = ((std::min))(green, blue);
4610 max = ((std::max))(green, blue);
4611 min = ((std::min))(red, blue);
4616 if (!
vpMath::equal(max, 0.0, std::numeric_limits<double>::epsilon())) {
4617 s = (max - min) / max;
4622 if (
vpMath::equal(s, 0.0, std::numeric_limits<double>::epsilon())) {
4625 double delta = max - min;
4626 if (
vpMath::equal(delta, 0.0, std::numeric_limits<double>::epsilon())) {
4630 if (
vpMath::equal(red, max, std::numeric_limits<double>::epsilon())) {
4631 h = (green - blue) / delta;
4632 }
else if (
vpMath::equal(green, max, std::numeric_limits<double>::epsilon())) {
4633 h = 2 + (blue - red) / delta;
4635 h = 4 + (red - green) / delta;
4641 }
else if (h > 1.0) {
4667 vpImageConvert::HSV2RGB(hue, saturation, value, rgba, size, 4);
4683 unsigned char *rgba,
unsigned int size)
4685 for (
unsigned int i = 0; i < size; i++) {
4686 double h = hue[i] / 255.0, s = saturation[i] / 255.0, v = value[i] / 255.0;
4706 vpImageConvert::RGB2HSV(rgba, hue, saturation, value, size, 4);
4721 unsigned char *value,
unsigned int size)
4723 for (
unsigned int i = 0; i < size; i++) {
4727 hue[i] = (
unsigned char)(255.0 * h);
4728 saturation[i] = (
unsigned char)(255.0 * s);
4729 value[i] = (
unsigned char)(255.0 * v);
4745 vpImageConvert::HSV2RGB(hue, saturation, value, rgb, size, 3);
4758 unsigned char *rgb,
unsigned int size)
4760 for (
unsigned int i = 0; i < size; i++) {
4761 double h = hue[i] / 255.0, s = saturation[i] / 255.0, v = value[i] / 255.0;
4780 vpImageConvert::RGB2HSV(rgb, hue, saturation, value, size, 3);
4794 unsigned char *value,
unsigned int size)
4796 for (
unsigned int i = 0; i < size; i++) {
4801 hue[i] = (
unsigned char)(255.0 * h);
4802 saturation[i] = (
unsigned char)(255.0 * s);
4803 value[i] = (
unsigned char)(255.0 * v);
static void BGRToRGBa(unsigned char *bgr, unsigned char *rgba, unsigned int width, unsigned int height, bool flip=false)
static void YUYVToRGBa(unsigned char *yuyv, unsigned char *rgba, unsigned int width, unsigned int height)
static void RGBToGrey(unsigned char *rgb, unsigned char *grey, unsigned int size)
static void convert(const vpImage< unsigned char > &src, vpImage< vpRGBa > &dest)
void resize(unsigned int h, unsigned int w)
resize the image : Image initialization
static void HSVToRGB(const double *hue, const double *saturation, const double *value, unsigned char *rgb, unsigned int size)
unsigned char B
Blue component.
static void RGBToRGBa(unsigned char *rgb, unsigned char *rgba, unsigned int size)
unsigned int getRows() const
static void BGRToGrey(unsigned char *bgr, unsigned char *grey, unsigned int width, unsigned int height, bool flip=false)
static void RGBaToHSV(const unsigned char *rgba, double *hue, double *saturation, double *value, unsigned int size)
Type * bitmap
points toward the bitmap
static void MONO16ToGrey(unsigned char *grey16, unsigned char *grey, unsigned int size)
static bool equal(double x, double y, double s=0.001)
static void YUV422ToRGB(unsigned char *yuv, unsigned char *rgb, unsigned int size)
static void YUV420ToGrey(unsigned char *yuv, unsigned char *grey, unsigned int size)
static void GreyToRGBa(unsigned char *grey, unsigned char *rgba, unsigned int size)
error that can be emited by ViSP classes.
static void YUV422ToRGBa(unsigned char *yuv, unsigned char *rgba, unsigned int size)
static void YCbCrToRGB(unsigned char *ycbcr, unsigned char *rgb, unsigned int size)
static void YUV411ToRGB(unsigned char *yuv, unsigned char *rgb, unsigned int size)
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 YUVToRGB(unsigned char y, unsigned char u, unsigned char v, unsigned char &r, unsigned char &g, unsigned char &b)
unsigned char G
Green component.
static void GreyToRGB(unsigned char *grey, unsigned char *rgb, unsigned int size)
static void RGBToHSV(const unsigned char *rgb, double *hue, double *saturation, double *value, unsigned int size)
static void YUV444ToRGBa(unsigned char *yuv, unsigned char *rgba, unsigned int size)
static void YUV420ToRGBa(unsigned char *yuv, unsigned char *rgba, unsigned int width, unsigned int height)
static void YVU9ToRGBa(unsigned char *yuv, unsigned char *rgba, unsigned int width, unsigned int height)
static void YUV422ToGrey(unsigned char *yuv, unsigned char *grey, unsigned int size)
static void YVU9ToRGB(unsigned char *yuv, unsigned char *rgb, unsigned int width, unsigned int height)
static void YV12ToRGBa(unsigned char *yuv, unsigned char *rgba, unsigned int width, unsigned int height)
static void YCbCrToGrey(unsigned char *ycbcr, unsigned char *grey, unsigned int size)
unsigned int getCols() const
unsigned char A
Additionnal component.
static void YUYVToGrey(unsigned char *yuyv, unsigned char *grey, unsigned int size)
static void MONO16ToRGBa(unsigned char *grey16, unsigned char *rgba, unsigned int size)
VISP_EXPORT bool checkSSSE3()
static void HSVToRGBa(const double *hue, const double *saturation, const double *value, unsigned char *rgba, unsigned int size)
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)
unsigned int getNumberOfPixel() const
static int round(double x)
static void YUYVToRGB(unsigned char *yuyv, unsigned char *rgb, unsigned int width, unsigned int height)
static void YUV444ToRGB(unsigned char *yuv, unsigned char *rgb, unsigned int size)
static void YUV444ToGrey(unsigned char *yuv, unsigned char *grey, unsigned int size)
unsigned int getHeight() const
static void YUV411ToRGBa(unsigned char *yuv, unsigned char *rgba, unsigned int size)
unsigned int getSize() const
unsigned char R
Red component.
static void YCbCrToRGBa(unsigned char *ycbcr, unsigned char *rgb, unsigned int size)
static void YUV411ToGrey(unsigned char *yuv, unsigned char *grey, unsigned int size)
static void RGBaToRGB(unsigned char *rgba, unsigned char *rgb, unsigned int size)
static void YCrCbToRGB(unsigned char *ycbcr, unsigned char *rgb, unsigned int size)
static void YCrCbToRGBa(unsigned char *ycbcr, unsigned char *rgb, unsigned int size)
unsigned int getWidth() const
static void RGBaToGrey(unsigned char *rgba, unsigned char *grey, unsigned int size)
static void createDepthHistogram(const vpImage< uint16_t > &src_depth, vpImage< vpRGBa > &dest_rgba)
void getMinMaxValue(Type &min, Type &max) const
Look for the minimum and the maximum value within the bitmap.
static void YV12ToRGB(unsigned char *yuv, unsigned char *rgb, unsigned int width, unsigned int height)
static void YUV420ToRGB(unsigned char *yuv, unsigned char *rgb, unsigned int width, unsigned int height)