54 #include "private/vpBayerConversion.h" 55 #include "private/vpImageConvert_impl.h" 56 #include <Simd/SimdLib.hpp> 57 #include <visp3/core/vpImageConvert.h> 59 bool vpImageConvert::YCbCrLUTcomputed =
false;
60 int vpImageConvert::vpCrr[256];
61 int vpImageConvert::vpCgb[256];
62 int vpImageConvert::vpCgr[256];
63 int vpImageConvert::vpCbb[256];
114 for (
unsigned int i = 0; i < max_xy; i++ )
116 float val = 255.f * ( src.
bitmap[i] - min ) / ( max - min );
119 else if ( val > 255 )
122 dest.
bitmap[i] = (
unsigned char)val;
154 for (
unsigned int i = 0; i < max_xy; i++ )
156 double val = 255. * ( src.
bitmap[i] - min ) / ( max - min );
159 else if ( val > 255 )
162 dest.
bitmap[i] = (
unsigned char)val;
177 for (
unsigned int i = 0; i < src.
getSize(); i++ )
178 dest.
bitmap[i] = static_cast< unsigned char >( src.
bitmap[i] >> bitshift );
192 for (
unsigned int i = 0; i < src.
getSize(); i++ )
193 dest.
bitmap[i] = static_cast< unsigned char >( src.
bitmap[i] << bitshift );
219 vp_createDepthHistogram(src_depth, dest_rgba);
231 vp_createDepthHistogram(src_depth, dest_depth);
244 vp_createDepthHistogram(src_depth, dest_rgba);
256 vp_createDepthHistogram(src_depth, dest_depth);
260 #ifdef VISP_HAVE_OPENCV 310 int nChannel = src->nChannels;
311 int depth = src->depth;
312 int height = src->height;
313 int width = src->width;
314 int widthStep = src->widthStep;
315 int lineStep = ( flip ) ? 1 : 0;
317 if ( nChannel == 3 && depth == 8 )
319 dest.
resize( (
unsigned int)height, (
unsigned int)width );
322 unsigned char *input = (
unsigned char *)src->imageData;
323 unsigned char *beginOutput = (
unsigned char *)dest.
bitmap;
325 for (
int i = 0; i < height; i++ )
327 unsigned char *line = input;
328 unsigned char *output =
329 beginOutput + lineStep * ( 4 * width * ( height - 1 - i ) ) + ( 1 - lineStep ) * 4 * width * i;
330 for (
int j = 0; j < width; j++ )
332 *( output++ ) = *( line + 2 );
333 *( output++ ) = *( line + 1 );
334 *( output++ ) = *( line );
343 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++ )
352 unsigned char *line = input;
353 unsigned char *output =
354 beginOutput + lineStep * ( 4 * width * ( height - 1 - i ) ) + ( 1 - lineStep ) * 4 * width * i;
355 for (
int j = 0; j < width; j++ )
357 *output++ = *( line );
358 *output++ = *( line );
359 *output++ = *( line );
415 int nChannel = src->nChannels;
416 int depth = src->depth;
417 int height = src->height;
418 int width = src->width;
419 int widthStep = src->widthStep;
420 int lineStep = ( flip ) ? 1 : 0;
424 if ( widthStep == width )
426 if ( nChannel == 1 && depth == 8 )
428 dest.
resize( (
unsigned int)height, (
unsigned int)width );
429 memcpy( dest.
bitmap, src->imageData, (
size_t )( height * width ) );
431 if ( nChannel == 3 && depth == 8 )
433 dest.
resize( (
unsigned int)height, (
unsigned int)width );
434 BGRToGrey( (
unsigned char *)src->imageData, dest.
bitmap, (
unsigned int)width, (
unsigned int)height,
false );
439 if ( nChannel == 1 && depth == 8 )
441 dest.
resize( (
unsigned int)height, (
unsigned int)width );
442 for (
int i = 0; i < height; i++ )
444 memcpy( dest.
bitmap + i * width, src->imageData + i * widthStep, (
size_t)width );
447 if ( nChannel == 3 && depth == 8 )
449 dest.
resize( (
unsigned int)height, (
unsigned int)width );
450 for (
int i = 0; i < height; i++ )
452 BGRToGrey( (
unsigned char *)src->imageData + i * widthStep, dest.
bitmap + i * width, (
unsigned int)width, 1,
460 if ( nChannel == 1 && depth == 8 )
462 dest.
resize( (
unsigned int)height, (
unsigned int)width );
463 unsigned char *beginOutput = (
unsigned char *)dest.
bitmap;
464 for (
int i = 0; i < height; i++ )
466 memcpy( beginOutput + lineStep * ( 4 * width * ( height - 1 - i ) ), src->imageData + i * widthStep,
470 if ( nChannel == 3 && depth == 8 )
472 dest.
resize( (
unsigned int)height, (
unsigned int)width );
474 BGRToGrey( (
unsigned char *)src->imageData , dest.
bitmap , (
unsigned int)width,
475 (
unsigned int)height ,
true );
529 CvSize size = cvSize( width, height );
534 if ( dest->nChannels != channels || dest->depth != depth || dest->height != height || dest->width != width )
536 if ( dest->nChannels != 0 )
537 cvReleaseImage( &dest );
538 dest = cvCreateImage( size, depth, channels );
542 dest = cvCreateImage( size, depth, channels );
545 unsigned char *input = (
unsigned char *)src.
bitmap;
546 unsigned char *output = (
unsigned char *)dest->imageData;
550 int widthStep = dest->widthStep;
552 for ( i = 0; i < height; i++ )
554 output = (
unsigned char *)dest->imageData + i * widthStep;
555 unsigned char *line = input;
556 for ( j = 0; j < width; j++ )
558 *output++ = *( line + 2 );
559 *output++ = *( line + 1 );
560 *output++ = *( line );
616 unsigned int width = src.
getWidth();
617 CvSize size = cvSize( (
int)width, (
int)height );
622 if ( dest->nChannels != channels || dest->depth != depth || dest->height != (
int)height ||
623 dest->width != (
int)width )
625 if ( dest->nChannels != 0 )
626 cvReleaseImage( &dest );
627 dest = cvCreateImage( size, depth, channels );
631 dest = cvCreateImage( size, depth, channels );
633 unsigned int widthStep = (
unsigned int)dest->widthStep;
635 if ( width == widthStep )
637 memcpy( dest->imageData, src.
bitmap, width * height );
642 for (
unsigned int i = 0; i < height; i++ )
644 memcpy( dest->imageData + i * widthStep, src.
bitmap + i * width, width );
649 #if VISP_HAVE_OPENCV_VERSION >= 0x020100 700 dest.
resize( (
unsigned int)src.rows, (
unsigned int)src.cols );
702 if ( src.type() == CV_8UC4 )
705 for (
unsigned int i = 0; i < dest.
getRows(); ++i )
706 for (
unsigned int j = 0; j < dest.
getCols(); ++j )
708 cv::Vec4b tmp = src.at< cv::Vec4b >( (int)i, (
int)j );
714 dest[dest.
getRows() - i - 1][j] = rgbaVal;
716 dest[i][j] = rgbaVal;
719 else if ( src.type() == CV_8UC3 )
721 if ( src.isContinuous() && !flip )
723 SimdRgbToBgra( src.data, src.cols, src.rows, src.step[0], reinterpret_cast< uint8_t * >( dest.
bitmap ),
730 for (
unsigned int i = 0; i < dest.
getRows(); ++i )
732 for (
unsigned int j = 0; j < dest.
getCols(); ++j )
734 cv::Vec3b tmp = src.at< cv::Vec3b >( (int)i, (
int)j );
740 dest[dest.
getRows() - i - 1][j] = rgbaVal;
744 dest[i][j] = rgbaVal;
750 else if ( src.type() == CV_8UC1 )
752 if ( src.isContinuous() && !flip )
754 SimdGrayToBgra( src.data, src.cols, src.rows, src.step[0], reinterpret_cast< uint8_t * >( dest.
bitmap ),
760 for (
unsigned int i = 0; i < dest.
getRows(); ++i )
762 for (
unsigned int j = 0; j < dest.
getCols(); ++j )
764 rgbaVal = src.at<
unsigned char >( (int)i, (
int)j );
767 dest[dest.
getRows() - i - 1][j] = rgbaVal;
771 dest[i][j] = rgbaVal;
824 if ( src.type() == CV_8UC1 )
826 dest.
resize( (
unsigned int)src.rows, (
unsigned int)src.cols );
827 if ( src.isContinuous() && !flip )
829 memcpy( dest.
bitmap, src.data, (
size_t )( src.rows * src.cols ) );
835 for (
unsigned int i = 0; i < dest.
getRows(); ++i )
843 for (
unsigned int i = 0; i < dest.
getRows(); ++i )
845 memcpy( dest.
bitmap + i * dest.
getCols(), src.data + i * src.step1(), (size_t)src.step );
850 else if ( src.type() == CV_8UC3 )
852 dest.
resize( (
unsigned int)src.rows, (
unsigned int)src.cols );
853 if ( src.isContinuous() )
855 BGRToGrey( (
unsigned char *)src.data, (
unsigned char *)dest.
bitmap, (
unsigned int)src.cols,
856 (
unsigned int)src.rows, flip, nThreads );
862 for (
unsigned int i = 0; i < dest.
getRows(); ++i )
864 BGRToGrey( (
unsigned char *)src.data + i * src.step1(),
866 (
unsigned int)dest.
getCols(), 1, false );
871 for (
unsigned int i = 0; i < dest.
getRows(); ++i )
873 BGRToGrey( (
unsigned char *)src.data + i * src.step1(), (
unsigned char *)dest.
bitmap + i * dest.
getCols(),
874 (
unsigned int)dest.
getCols(), 1, false );
879 else if ( src.type() == CV_8UC4 )
881 dest.
resize( (
unsigned int)src.rows, (
unsigned int)src.cols );
882 if ( src.isContinuous() )
884 BGRaToGrey( (
unsigned char *)src.data, (
unsigned char *)dest.
bitmap, (
unsigned int)src.cols,
885 (
unsigned int)src.rows, flip, nThreads );
891 for (
unsigned int i = 0; i < dest.
getRows(); ++i )
893 BGRaToGrey( (
unsigned char *)src.data + i * src.step1(),
895 (
unsigned int)dest.
getCols(), 1, false );
900 for (
unsigned int i = 0; i < dest.
getRows(); ++i )
903 (
unsigned int)dest.
getCols(), 1, false );
950 cv::cvtColor( vpToMat, dest, cv::COLOR_RGBA2BGR );
997 dest = tmpMap.clone();
1008 #ifdef VISP_HAVE_YARP 1097 dest.
resize( src->height(), src->width() );
1099 memcpy( dest.
bitmap, src->getRawImage(), src->height() * src->width() *
sizeof( yarp::sig::PixelMono ) );
1101 dest.
bitmap = src->getRawImage();
1191 dest.
resize( src->height(), src->width() );
1193 memcpy( dest.
bitmap, src->getRawImage(), src->height() * src->width() *
sizeof( yarp::sig::PixelRgba ) );
1195 dest.
bitmap =
static_cast< vpRGBa *
>( src->getRawImage() );
1234 for (
unsigned int i = 0; i < src.
getRows(); i++ )
1236 for (
unsigned int j = 0; j < src.
getWidth(); j++ )
1238 dest->pixel( j, i ).r = src[i][j].R;
1239 dest->pixel( j, i ).g = src[i][j].G;
1240 dest->pixel( j, i ).b = src[i][j].B;
1286 dest.
resize( src->height(), src->width() );
1287 for (
int i = 0; i < src->height(); i++ )
1289 for (
int j = 0; j < src->width(); j++ )
1291 dest[i][j].R = src->pixel( j, i ).r;
1292 dest[i][j].G = src->pixel( j, i ).g;
1293 dest[i][j].B = src->pixel( j, i ).b;
1301 #define vpSAT( c ) \ 1302 if ( c & ( ~255 ) ) \ 1327 int r, g, b, cr, cg, cb, y1, y2;
1339 cb = ( ( *s - 128 ) * 454 ) >> 8;
1340 cg = ( *s++ - 128 ) * 88;
1342 cr = ( ( *s - 128 ) * 359 ) >> 8;
1343 cg = ( cg + ( *s++ - 128 ) * 183 ) >> 8;
1348 vpSAT( r ) vpSAT( g ) vpSAT( b )
1350 *d++ =
static_cast< unsigned char >( r );
1351 *d++ =
static_cast< unsigned char >( g );
1352 *d++ =
static_cast< unsigned char >( b );
1358 vpSAT( r ) vpSAT( g ) vpSAT( b )
1360 *d++ =
static_cast< unsigned char >( r );
1361 *d++ =
static_cast< unsigned char >( g );
1362 *d++ =
static_cast< unsigned char >( b );
1384 int r, g, b, cr, cg, cb, y1, y2;
1396 cb = ( ( *s - 128 ) * 454 ) >> 8;
1397 cg = ( *s++ - 128 ) * 88;
1399 cr = ( ( *s - 128 ) * 359 ) >> 8;
1400 cg = ( cg + ( *s++ - 128 ) * 183 ) >> 8;
1405 vpSAT( r ) vpSAT( g ) vpSAT( b )
1407 *d++ =
static_cast< unsigned char >( r );
1408 *d++ =
static_cast< unsigned char >( g );
1409 *d++ =
static_cast< unsigned char >( b );
1414 vpSAT( r ) vpSAT( g ) vpSAT( b )
1416 *d++ =
static_cast< unsigned char >( r );
1417 *d++ =
static_cast< unsigned char >( g );
1418 *d++ =
static_cast< unsigned char >( b );
1436 unsigned int i = 0, j = 0;
1438 while ( j < size * 2 )
1440 grey[i++] = yuyv[j];
1441 grey[i++] = yuyv[j + 2];
1460 for (
unsigned int i = size / 4; i; i-- )
1462 int U = (int)( ( *yuv++ - 128 ) * 0.354 );
1466 int V = (int)( ( *yuv++ - 128 ) * 0.707 );
1477 if ( ( R >> 8 ) > 0 )
1483 if ( ( G >> 8 ) > 0 )
1489 if ( ( B >> 8 ) > 0 )
1494 *rgba++ = (
unsigned char)R;
1495 *rgba++ = (
unsigned char)G;
1496 *rgba++ = (
unsigned char)B;
1501 if ( ( R >> 8 ) > 0 )
1507 if ( ( G >> 8 ) > 0 )
1513 if ( ( B >> 8 ) > 0 )
1518 *rgba++ = (
unsigned char)R;
1519 *rgba++ = (
unsigned char)G;
1520 *rgba++ = (
unsigned char)B;
1525 if ( ( R >> 8 ) > 0 )
1531 if ( ( G >> 8 ) > 0 )
1537 if ( ( B >> 8 ) > 0 )
1542 *rgba++ = (
unsigned char)R;
1543 *rgba++ = (
unsigned char)G;
1544 *rgba++ = (
unsigned char)B;
1549 if ( ( R >> 8 ) > 0 )
1555 if ( ( G >> 8 ) > 0 )
1561 if ( ( B >> 8 ) > 0 )
1566 *rgba++ = (
unsigned char)R;
1567 *rgba++ = (
unsigned char)G;
1568 *rgba++ = (
unsigned char)B;
1573 unsigned int i = 0, j = 0;
1574 unsigned char r, g, b;
1575 while ( j < numpixels * 3 / 2 )
1578 YUVToRGB( yuv[j + 1], yuv[j], yuv[j + 3], r, g, b );
1585 YUVToRGB( yuv[j + 2], yuv[j], yuv[j + 3], r, g, b );
1592 YUVToRGB( yuv[j + 4], yuv[j], yuv[j + 3], r, g, b );
1599 YUVToRGB( yuv[j + 5], yuv[j], yuv[j + 3], r, g, b );
1629 for (
unsigned int i = size / 2; i; i-- )
1631 int U = (int)( ( *yuv++ - 128 ) * 0.354 );
1634 int V = (int)( ( *yuv++ - 128 ) * 0.707 );
1641 if ( ( R >> 8 ) > 0 )
1647 if ( ( G >> 8 ) > 0 )
1653 if ( ( B >> 8 ) > 0 )
1658 *rgba++ = (
unsigned char)R;
1659 *rgba++ = (
unsigned char)G;
1660 *rgba++ = (
unsigned char)B;
1665 if ( ( R >> 8 ) > 0 )
1671 if ( ( G >> 8 ) > 0 )
1677 if ( ( B >> 8 ) > 0 )
1682 *rgba++ = (
unsigned char)R;
1683 *rgba++ = (
unsigned char)G;
1684 *rgba++ = (
unsigned char)B;
1690 unsigned int i = 0, j = 0;
1691 unsigned char r, g, b;
1693 while ( j < size * 2 )
1696 YUVToRGB( yuv[j + 1], yuv[j], yuv[j + 2], r, g, b );
1703 YUVToRGB( yuv[j + 3], yuv[j], yuv[j + 2], r, g, b );
1725 unsigned int i = 0, j = 0;
1726 while ( j < size * 3 / 2 )
1728 grey[i] = yuv[j + 1];
1729 grey[i + 1] = yuv[j + 2];
1730 grey[i + 2] = yuv[j + 4];
1731 grey[i + 3] = yuv[j + 5];
1754 for (
unsigned int i = size / 2; i; i-- )
1756 int U = (int)( ( *yuv++ - 128 ) * 0.354 );
1759 int V = (int)( ( *yuv++ - 128 ) * 0.707 );
1766 if ( ( R >> 8 ) > 0 )
1772 if ( ( G >> 8 ) > 0 )
1778 if ( ( B >> 8 ) > 0 )
1783 *rgb++ = (
unsigned char)R;
1784 *rgb++ = (
unsigned char)G;
1785 *rgb++ = (
unsigned char)B;
1789 if ( ( R >> 8 ) > 0 )
1795 if ( ( G >> 8 ) > 0 )
1801 if ( ( B >> 8 ) > 0 )
1806 *rgb++ = (
unsigned char)R;
1807 *rgb++ = (
unsigned char)G;
1808 *rgb++ = (
unsigned char)B;
1813 unsigned int i = 0, j = 0;
1814 unsigned char r, g, b;
1816 while ( j < size * 2 )
1819 YUVToRGB( yuv[j + 1], yuv[j], yuv[j + 2], r, g, b );
1825 YUVToRGB( yuv[j + 3], yuv[j], yuv[j + 2], r, g, b );
1848 unsigned int i = 0, j = 0;
1850 while ( j < size * 2 )
1852 grey[i++] = yuv[j + 1];
1853 grey[i++] = yuv[j + 3];
1871 for (
unsigned int i = size / 4; i; i-- )
1873 int U = (int)( ( *yuv++ - 128 ) * 0.354 );
1877 int V = (int)( ( *yuv++ - 128 ) * 0.707 );
1888 if ( ( R >> 8 ) > 0 )
1894 if ( ( G >> 8 ) > 0 )
1900 if ( ( B >> 8 ) > 0 )
1905 *rgb++ = (
unsigned char)R;
1906 *rgb++ = (
unsigned char)G;
1907 *rgb++ = (
unsigned char)B;
1911 if ( ( R >> 8 ) > 0 )
1917 if ( ( G >> 8 ) > 0 )
1923 if ( ( B >> 8 ) > 0 )
1928 *rgb++ = (
unsigned char)R;
1929 *rgb++ = (
unsigned char)G;
1930 *rgb++ = (
unsigned char)B;
1934 if ( ( R >> 8 ) > 0 )
1940 if ( ( G >> 8 ) > 0 )
1946 if ( ( B >> 8 ) > 0 )
1951 *rgb++ = (
unsigned char)R;
1952 *rgb++ = (
unsigned char)G;
1953 *rgb++ = (
unsigned char)B;
1957 if ( ( R >> 8 ) > 0 )
1963 if ( ( G >> 8 ) > 0 )
1969 if ( ( B >> 8 ) > 0 )
1974 *rgb++ = (
unsigned char)R;
1975 *rgb++ = (
unsigned char)G;
1976 *rgb++ = (
unsigned char)B;
1981 unsigned int i = 0, j = 0;
1982 unsigned char r, g, b;
1984 while ( j < size * 3 / 2 )
1986 YUVToRGB( yuv[j + 1], yuv[j], yuv[j + 3], r, g, b );
1992 YUVToRGB( yuv[j + 2], yuv[j], yuv[j + 3], r, g, b );
1998 YUVToRGB( yuv[j + 4], yuv[j], yuv[j + 3], r, g, b );
2004 YUVToRGB( yuv[j + 5], yuv[j], yuv[j + 3], r, g, b );
2030 int U, V, R, G, B, V2, U5, UV;
2032 unsigned int size = width * height;
2033 unsigned char *iU = yuv + size;
2034 unsigned char *iV = yuv + 5 * size / 4;
2035 for (
unsigned int i = 0; i < height / 2; i++ )
2037 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;
2056 if ( ( R >> 8 ) > 0 )
2062 if ( ( G >> 8 ) > 0 )
2068 if ( ( B >> 8 ) > 0 )
2073 *rgba++ = (
unsigned char)R;
2074 *rgba++ = (
unsigned char)G;
2075 *rgba++ = (
unsigned char)B;
2080 if ( ( R >> 8 ) > 0 )
2086 if ( ( G >> 8 ) > 0 )
2092 if ( ( B >> 8 ) > 0 )
2097 *rgba++ = (
unsigned char)R;
2098 *rgba++ = (
unsigned char)G;
2099 *rgba++ = (
unsigned char)B;
2101 rgba = rgba + 4 * width - 7;
2105 if ( ( R >> 8 ) > 0 )
2111 if ( ( G >> 8 ) > 0 )
2117 if ( ( B >> 8 ) > 0 )
2122 *rgba++ = (
unsigned char)R;
2123 *rgba++ = (
unsigned char)G;
2124 *rgba++ = (
unsigned char)B;
2129 if ( ( R >> 8 ) > 0 )
2135 if ( ( G >> 8 ) > 0 )
2141 if ( ( B >> 8 ) > 0 )
2146 *rgba++ = (
unsigned char)R;
2147 *rgba++ = (
unsigned char)G;
2148 *rgba++ = (
unsigned char)B;
2150 rgba = rgba - 4 * width + 1;
2169 int U, V, R, G, B, V2, U5, UV;
2171 unsigned int size = width * height;
2172 unsigned char *iU = yuv + size;
2173 unsigned char *iV = yuv + 5 * size / 4;
2174 for (
unsigned int i = 0; i < height / 2; i++ )
2176 for (
unsigned int j = 0; j < width / 2; j++ )
2178 U = (int)( ( *iU++ - 128 ) * 0.354 );
2180 V = (int)( ( *iV++ - 128 ) * 0.707 );
2185 yuv = yuv + width - 1;
2188 yuv = yuv - width + 1;
2195 if ( ( R >> 8 ) > 0 )
2201 if ( ( G >> 8 ) > 0 )
2207 if ( ( B >> 8 ) > 0 )
2212 *rgb++ = (
unsigned char)R;
2213 *rgb++ = (
unsigned char)G;
2214 *rgb++ = (
unsigned char)B;
2218 if ( ( R >> 8 ) > 0 )
2224 if ( ( G >> 8 ) > 0 )
2230 if ( ( B >> 8 ) > 0 )
2235 *rgb++ = (
unsigned char)R;
2236 *rgb++ = (
unsigned char)G;
2237 *rgb = (
unsigned char)B;
2238 rgb = rgb + 3 * width - 5;
2242 if ( ( R >> 8 ) > 0 )
2248 if ( ( G >> 8 ) > 0 )
2254 if ( ( B >> 8 ) > 0 )
2259 *rgb++ = (
unsigned char)R;
2260 *rgb++ = (
unsigned char)G;
2261 *rgb++ = (
unsigned char)B;
2265 if ( ( R >> 8 ) > 0 )
2271 if ( ( G >> 8 ) > 0 )
2277 if ( ( B >> 8 ) > 0 )
2282 *rgb++ = (
unsigned char)R;
2283 *rgb++ = (
unsigned char)G;
2284 *rgb = (
unsigned char)B;
2285 rgb = rgb - 3 * width + 1;
2302 for (
unsigned int i = 0; i < size; i++ )
2320 for (
unsigned int i = 0; i < size; i++ )
2322 int U = (int)( ( *yuv++ - 128 ) * 0.354 );
2325 int V = (int)( ( *yuv++ - 128 ) * 0.707 );
2334 if ( ( R >> 8 ) > 0 )
2340 if ( ( G >> 8 ) > 0 )
2346 if ( ( B >> 8 ) > 0 )
2351 *rgba++ = (
unsigned char)R;
2352 *rgba++ = (
unsigned char)G;
2353 *rgba++ = (
unsigned char)B;
2368 for (
unsigned int i = 0; i < size; i++ )
2370 int U = (int)( ( *yuv++ - 128 ) * 0.354 );
2373 int V = (int)( ( *yuv++ - 128 ) * 0.707 );
2382 if ( ( R >> 8 ) > 0 )
2388 if ( ( G >> 8 ) > 0 )
2394 if ( ( B >> 8 ) > 0 )
2399 *rgb++ = (
unsigned char)R;
2400 *rgb++ = (
unsigned char)G;
2401 *rgb++ = (
unsigned char)B;
2416 for (
unsigned int i = 0; i < size; i++ )
2437 int U, V, R, G, B, V2, U5, UV;
2439 unsigned int size = width * height;
2440 unsigned char *iV = yuv + size;
2441 unsigned char *iU = yuv + 5 * size / 4;
2442 for (
unsigned int i = 0; i < height / 2; i++ )
2444 for (
unsigned int j = 0; j < width / 2; j++ )
2446 U = (int)( ( *iU++ - 128 ) * 0.354 );
2448 V = (int)( ( *iV++ - 128 ) * 0.707 );
2453 yuv = yuv + width - 1;
2456 yuv = yuv - width + 1;
2463 if ( ( R >> 8 ) > 0 )
2469 if ( ( G >> 8 ) > 0 )
2475 if ( ( B >> 8 ) > 0 )
2480 *rgba++ = (
unsigned char)R;
2481 *rgba++ = (
unsigned char)G;
2482 *rgba++ = (
unsigned char)B;
2487 if ( ( R >> 8 ) > 0 )
2493 if ( ( G >> 8 ) > 0 )
2499 if ( ( B >> 8 ) > 0 )
2504 *rgba++ = (
unsigned char)R;
2505 *rgba++ = (
unsigned char)G;
2506 *rgba++ = (
unsigned char)B;
2508 rgba = rgba + 4 * width - 7;
2512 if ( ( R >> 8 ) > 0 )
2518 if ( ( G >> 8 ) > 0 )
2524 if ( ( B >> 8 ) > 0 )
2529 *rgba++ = (
unsigned char)R;
2530 *rgba++ = (
unsigned char)G;
2531 *rgba++ = (
unsigned char)B;
2536 if ( ( R >> 8 ) > 0 )
2542 if ( ( G >> 8 ) > 0 )
2548 if ( ( B >> 8 ) > 0 )
2553 *rgba++ = (
unsigned char)R;
2554 *rgba++ = (
unsigned char)G;
2555 *rgba++ = (
unsigned char)B;
2557 rgba = rgba - 4 * width + 1;
2576 int U, V, R, G, B, V2, U5, UV;
2578 unsigned int size = width * height;
2579 unsigned char *iV = yuv + size;
2580 unsigned char *iU = yuv + 5 * size / 4;
2581 for (
unsigned int i = 0; i < height / 2; i++ )
2583 for (
unsigned int j = 0; j < width / 2; j++ )
2585 U = (int)( ( *iU++ - 128 ) * 0.354 );
2587 V = (int)( ( *iV++ - 128 ) * 0.707 );
2592 yuv = yuv + width - 1;
2595 yuv = yuv - width + 1;
2602 if ( ( R >> 8 ) > 0 )
2608 if ( ( G >> 8 ) > 0 )
2614 if ( ( B >> 8 ) > 0 )
2619 *rgb++ = (
unsigned char)R;
2620 *rgb++ = (
unsigned char)G;
2621 *rgb++ = (
unsigned char)B;
2625 if ( ( R >> 8 ) > 0 )
2631 if ( ( G >> 8 ) > 0 )
2637 if ( ( B >> 8 ) > 0 )
2642 *rgb++ = (
unsigned char)R;
2643 *rgb++ = (
unsigned char)G;
2644 *rgb = (
unsigned char)B;
2645 rgb = rgb + 3 * width - 5;
2649 if ( ( R >> 8 ) > 0 )
2655 if ( ( G >> 8 ) > 0 )
2661 if ( ( B >> 8 ) > 0 )
2666 *rgb++ = (
unsigned char)R;
2667 *rgb++ = (
unsigned char)G;
2668 *rgb++ = (
unsigned char)B;
2672 if ( ( R >> 8 ) > 0 )
2678 if ( ( G >> 8 ) > 0 )
2684 if ( ( B >> 8 ) > 0 )
2689 *rgb++ = (
unsigned char)R;
2690 *rgb++ = (
unsigned char)G;
2691 *rgb = (
unsigned char)B;
2692 rgb = rgb - 3 * width + 1;
2713 int U, V, R, G, B, V2, U5, UV;
2714 int Y0, Y1, Y2, Y3, Y4, Y5, Y6, Y7, Y8, Y9, Y10, Y11, Y12, Y13, Y14, Y15;
2715 unsigned int size = width * height;
2716 unsigned char *iV = yuv + size;
2717 unsigned char *iU = yuv + 17 * size / 16;
2718 for (
unsigned int i = 0; i < height / 4; i++ )
2720 for (
unsigned int j = 0; j < width / 4; j++ )
2722 U = (int)( ( *iU++ - 128 ) * 0.354 );
2724 V = (int)( ( *iV++ - 128 ) * 0.707 );
2731 yuv = yuv + width - 3;
2736 yuv = yuv + width - 3;
2741 yuv = yuv + width - 3;
2746 yuv = yuv - 3 * width + 1;
2753 if ( ( R >> 8 ) > 0 )
2759 if ( ( G >> 8 ) > 0 )
2765 if ( ( B >> 8 ) > 0 )
2770 *rgba++ = (
unsigned char)R;
2771 *rgba++ = (
unsigned char)G;
2772 *rgba++ = (
unsigned char)B;
2777 if ( ( R >> 8 ) > 0 )
2783 if ( ( G >> 8 ) > 0 )
2789 if ( ( B >> 8 ) > 0 )
2794 *rgba++ = (
unsigned char)R;
2795 *rgba++ = (
unsigned char)G;
2796 *rgba++ = (
unsigned char)B;
2801 if ( ( R >> 8 ) > 0 )
2807 if ( ( G >> 8 ) > 0 )
2813 if ( ( B >> 8 ) > 0 )
2818 *rgba++ = (
unsigned char)R;
2819 *rgba++ = (
unsigned char)G;
2820 *rgba++ = (
unsigned char)B;
2825 if ( ( R >> 8 ) > 0 )
2831 if ( ( G >> 8 ) > 0 )
2837 if ( ( B >> 8 ) > 0 )
2842 *rgba++ = (
unsigned char)R;
2843 *rgba++ = (
unsigned char)G;
2844 *rgba++ = (
unsigned char)B;
2846 rgba = rgba + 4 * width - 15;
2849 if ( ( R >> 8 ) > 0 )
2855 if ( ( G >> 8 ) > 0 )
2861 if ( ( B >> 8 ) > 0 )
2866 *rgba++ = (
unsigned char)R;
2867 *rgba++ = (
unsigned char)G;
2868 *rgba++ = (
unsigned char)B;
2873 if ( ( R >> 8 ) > 0 )
2879 if ( ( G >> 8 ) > 0 )
2885 if ( ( B >> 8 ) > 0 )
2890 *rgba++ = (
unsigned char)R;
2891 *rgba++ = (
unsigned char)G;
2892 *rgba++ = (
unsigned char)B;
2897 if ( ( R >> 8 ) > 0 )
2903 if ( ( G >> 8 ) > 0 )
2909 if ( ( B >> 8 ) > 0 )
2914 *rgba++ = (
unsigned char)R;
2915 *rgba++ = (
unsigned char)G;
2916 *rgba++ = (
unsigned char)B;
2921 if ( ( R >> 8 ) > 0 )
2927 if ( ( G >> 8 ) > 0 )
2933 if ( ( B >> 8 ) > 0 )
2938 *rgba++ = (
unsigned char)R;
2939 *rgba++ = (
unsigned char)G;
2940 *rgba++ = (
unsigned char)B;
2942 rgba = rgba + 4 * width - 15;
2945 if ( ( R >> 8 ) > 0 )
2951 if ( ( G >> 8 ) > 0 )
2957 if ( ( B >> 8 ) > 0 )
2962 *rgba++ = (
unsigned char)R;
2963 *rgba++ = (
unsigned char)G;
2964 *rgba++ = (
unsigned char)B;
2969 if ( ( R >> 8 ) > 0 )
2975 if ( ( G >> 8 ) > 0 )
2981 if ( ( B >> 8 ) > 0 )
2986 *rgba++ = (
unsigned char)R;
2987 *rgba++ = (
unsigned char)G;
2988 *rgba++ = (
unsigned char)B;
2993 if ( ( R >> 8 ) > 0 )
2999 if ( ( G >> 8 ) > 0 )
3005 if ( ( B >> 8 ) > 0 )
3010 *rgba++ = (
unsigned char)R;
3011 *rgba++ = (
unsigned char)G;
3012 *rgba++ = (
unsigned char)B;
3017 if ( ( R >> 8 ) > 0 )
3023 if ( ( G >> 8 ) > 0 )
3029 if ( ( B >> 8 ) > 0 )
3034 *rgba++ = (
unsigned char)R;
3035 *rgba++ = (
unsigned char)G;
3036 *rgba++ = (
unsigned char)B;
3038 rgba = rgba + 4 * width - 15;
3041 if ( ( R >> 8 ) > 0 )
3047 if ( ( G >> 8 ) > 0 )
3053 if ( ( B >> 8 ) > 0 )
3058 *rgba++ = (
unsigned char)R;
3059 *rgba++ = (
unsigned char)G;
3060 *rgba++ = (
unsigned char)B;
3065 if ( ( R >> 8 ) > 0 )
3071 if ( ( G >> 8 ) > 0 )
3077 if ( ( B >> 8 ) > 0 )
3082 *rgba++ = (
unsigned char)R;
3083 *rgba++ = (
unsigned char)G;
3084 *rgba++ = (
unsigned char)B;
3089 if ( ( R >> 8 ) > 0 )
3095 if ( ( G >> 8 ) > 0 )
3101 if ( ( B >> 8 ) > 0 )
3106 *rgba++ = (
unsigned char)R;
3107 *rgba++ = (
unsigned char)G;
3108 *rgba++ = (
unsigned char)B;
3113 if ( ( R >> 8 ) > 0 )
3119 if ( ( G >> 8 ) > 0 )
3125 if ( ( B >> 8 ) > 0 )
3130 *rgba++ = (
unsigned char)R;
3131 *rgba++ = (
unsigned char)G;
3132 *rgba++ = (
unsigned char)B;
3134 rgba = rgba - 12 * width + 1;
3152 int U, V, R, G, B, V2, U5, UV;
3153 int Y0, Y1, Y2, Y3, Y4, Y5, Y6, Y7, Y8, Y9, Y10, Y11, Y12, Y13, Y14, Y15;
3154 unsigned int size = width * height;
3155 unsigned char *iV = yuv + size;
3156 unsigned char *iU = yuv + 17 * size / 16;
3157 for (
unsigned int i = 0; i < height / 4; i++ )
3159 for (
unsigned int j = 0; j < width / 4; j++ )
3161 U = (int)( ( *iU++ - 128 ) * 0.354 );
3163 V = (int)( ( *iV++ - 128 ) * 0.707 );
3170 yuv = yuv + width - 3;
3175 yuv = yuv + width - 3;
3180 yuv = yuv + width - 3;
3185 yuv = yuv - 3 * width + 1;
3192 if ( ( R >> 8 ) > 0 )
3198 if ( ( G >> 8 ) > 0 )
3204 if ( ( B >> 8 ) > 0 )
3209 *rgb++ = (
unsigned char)R;
3210 *rgb++ = (
unsigned char)G;
3211 *rgb++ = (
unsigned char)B;
3215 if ( ( R >> 8 ) > 0 )
3221 if ( ( G >> 8 ) > 0 )
3227 if ( ( B >> 8 ) > 0 )
3232 *rgb++ = (
unsigned char)R;
3233 *rgb++ = (
unsigned char)G;
3234 *rgb++ = (
unsigned char)B;
3238 if ( ( R >> 8 ) > 0 )
3244 if ( ( G >> 8 ) > 0 )
3250 if ( ( B >> 8 ) > 0 )
3255 *rgb++ = (
unsigned char)R;
3256 *rgb++ = (
unsigned char)G;
3257 *rgb++ = (
unsigned char)B;
3261 if ( ( R >> 8 ) > 0 )
3267 if ( ( G >> 8 ) > 0 )
3273 if ( ( B >> 8 ) > 0 )
3278 *rgb++ = (
unsigned char)R;
3279 *rgb++ = (
unsigned char)G;
3280 *rgb = (
unsigned char)B;
3281 rgb = rgb + 3 * width - 11;
3284 if ( ( R >> 8 ) > 0 )
3290 if ( ( G >> 8 ) > 0 )
3296 if ( ( B >> 8 ) > 0 )
3301 *rgb++ = (
unsigned char)R;
3302 *rgb++ = (
unsigned char)G;
3303 *rgb++ = (
unsigned char)B;
3307 if ( ( R >> 8 ) > 0 )
3313 if ( ( G >> 8 ) > 0 )
3319 if ( ( B >> 8 ) > 0 )
3324 *rgb++ = (
unsigned char)R;
3325 *rgb++ = (
unsigned char)G;
3326 *rgb++ = (
unsigned char)B;
3330 if ( ( R >> 8 ) > 0 )
3336 if ( ( G >> 8 ) > 0 )
3342 if ( ( B >> 8 ) > 0 )
3347 *rgb++ = (
unsigned char)R;
3348 *rgb++ = (
unsigned char)G;
3349 *rgb++ = (
unsigned char)B;
3353 if ( ( R >> 8 ) > 0 )
3359 if ( ( G >> 8 ) > 0 )
3365 if ( ( B >> 8 ) > 0 )
3370 *rgb++ = (
unsigned char)R;
3371 *rgb++ = (
unsigned char)G;
3372 *rgb = (
unsigned char)B;
3373 rgb = rgb + 3 * width - 11;
3376 if ( ( R >> 8 ) > 0 )
3382 if ( ( G >> 8 ) > 0 )
3388 if ( ( B >> 8 ) > 0 )
3393 *rgb++ = (
unsigned char)R;
3394 *rgb++ = (
unsigned char)G;
3395 *rgb++ = (
unsigned char)B;
3399 if ( ( R >> 8 ) > 0 )
3405 if ( ( G >> 8 ) > 0 )
3411 if ( ( B >> 8 ) > 0 )
3416 *rgb++ = (
unsigned char)R;
3417 *rgb++ = (
unsigned char)G;
3418 *rgb++ = (
unsigned char)B;
3422 if ( ( R >> 8 ) > 0 )
3428 if ( ( G >> 8 ) > 0 )
3434 if ( ( B >> 8 ) > 0 )
3439 *rgb++ = (
unsigned char)R;
3440 *rgb++ = (
unsigned char)G;
3441 *rgb++ = (
unsigned char)B;
3445 if ( ( R >> 8 ) > 0 )
3451 if ( ( G >> 8 ) > 0 )
3457 if ( ( B >> 8 ) > 0 )
3462 *rgb++ = (
unsigned char)R;
3463 *rgb++ = (
unsigned char)G;
3464 *rgb = (
unsigned char)B;
3465 rgb = rgb + 3 * width - 11;
3468 if ( ( R >> 8 ) > 0 )
3474 if ( ( G >> 8 ) > 0 )
3480 if ( ( B >> 8 ) > 0 )
3485 *rgb++ = (
unsigned char)R;
3486 *rgb++ = (
unsigned char)G;
3487 *rgb++ = (
unsigned char)B;
3491 if ( ( R >> 8 ) > 0 )
3497 if ( ( G >> 8 ) > 0 )
3503 if ( ( B >> 8 ) > 0 )
3508 *rgb++ = (
unsigned char)R;
3509 *rgb++ = (
unsigned char)G;
3510 *rgb++ = (
unsigned char)B;
3514 if ( ( R >> 8 ) > 0 )
3520 if ( ( G >> 8 ) > 0 )
3526 if ( ( B >> 8 ) > 0 )
3531 *rgb++ = (
unsigned char)R;
3532 *rgb++ = (
unsigned char)G;
3533 *rgb++ = (
unsigned char)B;
3537 if ( ( R >> 8 ) > 0 )
3543 if ( ( G >> 8 ) > 0 )
3549 if ( ( B >> 8 ) > 0 )
3554 *rgb++ = (
unsigned char)R;
3555 *rgb++ = (
unsigned char)G;
3556 *rgb++ = (
unsigned char)B;
3557 rgb = rgb - 9 * width + 1;
3605 int lineStep = ( flip ) ? -(
int)( width * 3 ) : (
int)( width * 3 );
3608 unsigned char *src = ( flip ) ? ( rgb + ( width * height * 3 ) + lineStep ) : rgb;
3613 for ( i = 0; i < height; i++ )
3615 unsigned char *line = src;
3616 for ( j = 0; j < width; j++ )
3618 *rgba++ = *( line++ );
3619 *rgba++ = *( line++ );
3620 *rgba++ = *( line++ );
3644 SimdBgraToBgr( rgba, size, 1, size * 4, rgb, size * 3 );
3683 SimdRgbToGray( rgb, width, height, width * 3, grey, width );
3689 int lineStep = ( flip ) ? -(
int)( width * 3 ) : (
int)( width * 3 );
3692 unsigned char *src = ( flip ) ? rgb + ( width * height * 3 ) + lineStep : rgb;
3699 for ( i = 0; i < height; i++ )
3701 unsigned char *line = src;
3702 for ( j = 0; j < width; j++ )
3707 *grey++ = (
unsigned char)( 0.2126 * r + 0.7152 * g + 0.0722 * b );
3742 omp_set_num_threads( static_cast< int >( nThreads ) );
3744 #pragma omp parallel for 3746 for (
int i = 0; i < static_cast< int >( height ); i++ )
3748 SimdRgbaToGray( rgba + i * width * 4, width, 1, width * 4, grey + i * width, width );
3769 SimdRgbaToGray( rgba, size, 1, size * 4, grey, size );
3820 SimdGrayToBgr( grey, size, 1, size, rgb, size * 3 );
3849 int lineStep = ( flip ) ? -(
int)( width * 3 ) : (
int)( width * 3 );
3852 unsigned char *src = ( flip ) ? ( bgr + ( width * height * 3 ) + lineStep ) : bgr;
3854 for (
unsigned int i = 0; i < height; i++ )
3856 unsigned char *line = src;
3857 for (
unsigned int j = 0; j < width; j++ )
3859 *rgba++ = *( line + 2 );
3860 *rgba++ = *( line + 1 );
3861 *rgba++ = *( line + 0 );
3892 SimdBgraToRgba( bgra, width, height, width * 4, rgba, width * 4 );
3898 int lineStep = ( flip ) ? -(
int)( width * 4 ) : (
int)( width * 4 );
3901 unsigned char *src = ( flip ) ? ( bgra + ( width * height * 4 ) + lineStep ) : bgra;
3903 for (
unsigned int i = 0; i < height; i++ )
3905 unsigned char *line = src;
3906 for (
unsigned int j = 0; j < width; j++ )
3908 *rgba++ = *( line + 2 );
3909 *rgba++ = *( line + 1 );
3910 *rgba++ = *( line + 0 );
3911 *rgba++ = *( line + 3 );
3948 omp_set_num_threads( static_cast< int >( nThreads ) );
3950 #pragma omp parallel for 3952 for (
int i = 0; i < static_cast< int >( height ); i++ )
3954 SimdBgrToGray( bgr + i * width * 3, width, 1, width * 3, grey + i * width, width );
3961 int lineStep = ( flip ) ? -(
int)( width * 3 ) : (
int)( width * 3 );
3964 unsigned char *src = ( flip ) ? bgr + ( width * height * 3 ) + lineStep : bgr;
3966 for (
unsigned int i = 0; i < height; i++ )
3968 unsigned char *line = src;
3969 for (
unsigned int j = 0; j < width; j++ )
3971 *grey++ = (
unsigned char)( 0.2126 * *( line + 2 ) + 0.7152 * *( line + 1 ) + 0.0722 * *( line + 0 ) );
4009 omp_set_num_threads( static_cast< int >( nThreads ) );
4011 #pragma omp parallel for 4013 for (
int i = 0; i < static_cast< int >( height ); i++ )
4015 SimdBgraToGray( bgra + i * width * 4, width, 1, width * 4, grey + i * width, width );
4022 int lineStep = ( flip ) ? -(
int)( width * 4 ) : (
int)( width * 4 );
4025 unsigned char *src = ( flip ) ? bgra + ( width * height * 4 ) + lineStep : bgra;
4027 for (
unsigned int i = 0; i < height; i++ )
4029 unsigned char *line = src;
4030 for (
unsigned int j = 0; j < width; j++ )
4032 *grey++ = (
unsigned char)( 0.2126 * *( line + 2 ) + 0.7152 * *( line + 1 ) + 0.0722 * *( line + 0 ) );
4046 vpImageConvert::computeYCbCrLUT()
4048 if ( YCbCrLUTcomputed ==
false )
4055 int aux = index - 128;
4056 vpImageConvert::vpCrr[index] = (int)( 364.6610 * aux ) >> 8;
4057 vpImageConvert::vpCgb[index] = (int)( -89.8779 * aux ) >> 8;
4058 vpImageConvert::vpCgr[index] = (int)( -185.8154 * aux ) >> 8;
4059 vpImageConvert::vpCbb[index] = (int)( 460.5724 * aux ) >> 8;
4062 YCbCrLUTcomputed =
true;
4092 unsigned char *pt_ycbcr = ycbcr;
4093 unsigned char *pt_rgb = rgb;
4097 vpImageConvert::computeYCbCrLUT();
4103 int val_r, val_g, val_b;
4104 if ( !( col++ % 2 ) )
4110 val_r = *pt_ycbcr + vpImageConvert::vpCrr[*crv];
4111 val_g = *pt_ycbcr + vpImageConvert::vpCgb[*cbv] + vpImageConvert::vpCgr[*crv];
4112 val_b = *pt_ycbcr + vpImageConvert::vpCbb[*cbv];
4114 vpDEBUG_TRACE( 5,
"[%d] R: %d G: %d B: %d\n", size, val_r, val_g, val_b );
4116 *pt_rgb++ = ( val_r < 0 ) ? 0u : ( ( val_r > 255 ) ? 255u : (
unsigned char)val_r );
4117 *pt_rgb++ = ( val_g < 0 ) ? 0u : ( ( val_g > 255 ) ? 255u : (
unsigned char)val_g );
4118 *pt_rgb++ = ( val_b < 0 ) ? 0u : ( ( val_b > 255 ) ? 255u : (
unsigned char)val_b );
4154 unsigned char *pt_ycbcr = ycbcr;
4155 unsigned char *pt_rgba = rgba;
4159 vpImageConvert::computeYCbCrLUT();
4165 int val_r, val_g, val_b;
4166 if ( !( col++ % 2 ) )
4172 val_r = *pt_ycbcr + vpImageConvert::vpCrr[*crv];
4173 val_g = *pt_ycbcr + vpImageConvert::vpCgb[*cbv] + vpImageConvert::vpCgr[*crv];
4174 val_b = *pt_ycbcr + vpImageConvert::vpCbb[*cbv];
4176 vpDEBUG_TRACE( 5,
"[%d] R: %d G: %d B: %d\n", size, val_r, val_g, val_b );
4178 *pt_rgba++ = ( val_r < 0 ) ? 0u : ( ( val_r > 255 ) ? 255u : (
unsigned char)val_r );
4179 *pt_rgba++ = ( val_g < 0 ) ? 0u : ( ( val_g > 255 ) ? 255u : (
unsigned char)val_g );
4180 *pt_rgba++ = ( val_b < 0 ) ? 0u : ( ( val_b > 255 ) ? 255u : (
unsigned char)val_b );
4209 unsigned int i = 0, j = 0;
4211 while ( j < size * 2 )
4213 grey[i++] = ycbcr[j];
4214 grey[i++] = ycbcr[j + 2];
4245 unsigned char *pt_ycbcr = ycrcb;
4246 unsigned char *pt_rgb = rgb;
4250 vpImageConvert::computeYCbCrLUT();
4256 int val_r, val_g, val_b;
4257 if ( !( col++ % 2 ) )
4263 val_r = *pt_ycbcr + vpImageConvert::vpCrr[*crv];
4264 val_g = *pt_ycbcr + vpImageConvert::vpCgb[*cbv] + vpImageConvert::vpCgr[*crv];
4265 val_b = *pt_ycbcr + vpImageConvert::vpCbb[*cbv];
4267 vpDEBUG_TRACE( 5,
"[%d] R: %d G: %d B: %d\n", size, val_r, val_g, val_b );
4269 *pt_rgb++ = ( val_r < 0 ) ? 0u : ( ( val_r > 255 ) ? 255u : (
unsigned char)val_r );
4270 *pt_rgb++ = ( val_g < 0 ) ? 0u : ( ( val_g > 255 ) ? 255u : (
unsigned char)val_g );
4271 *pt_rgb++ = ( val_b < 0 ) ? 0u : ( ( val_b > 255 ) ? 255u : (
unsigned char)val_b );
4306 unsigned char *pt_ycbcr = ycrcb;
4307 unsigned char *pt_rgba = rgba;
4311 vpImageConvert::computeYCbCrLUT();
4317 int val_r, val_g, val_b;
4318 if ( !( col++ % 2 ) )
4324 val_r = *pt_ycbcr + vpImageConvert::vpCrr[*crv];
4325 val_g = *pt_ycbcr + vpImageConvert::vpCgb[*cbv] + vpImageConvert::vpCgr[*crv];
4326 val_b = *pt_ycbcr + vpImageConvert::vpCbb[*cbv];
4328 vpDEBUG_TRACE( 5,
"[%d] R: %d G: %d B: %d\n", size, val_r, val_g, val_b );
4330 *pt_rgba++ = ( val_r < 0 ) ? 0u : ( ( val_r > 255 ) ? 255u : (
unsigned char)val_r );
4331 *pt_rgba++ = ( val_g < 0 ) ? 0u : ( ( val_g > 255 ) ? 255u : (
unsigned char)val_g );
4332 *pt_rgba++ = ( val_b < 0 ) ? 0u : ( ( val_b > 255 ) ? 255u : (
unsigned char)val_b );
4400 unsigned char *ptrR = pR ? pR->
bitmap :
new unsigned char[src.
getSize()];
4401 unsigned char *ptrG = pG ? pG->
bitmap :
new unsigned char[src.
getSize()];
4402 unsigned char *ptrB = pB ? pB->
bitmap :
new unsigned char[src.
getSize()];
4403 unsigned char *ptrA = pa ? pa->
bitmap :
new unsigned char[src.
getSize()];
4405 SimdDeinterleaveBgra( reinterpret_cast< unsigned char * >( src.
bitmap ), src.
getWidth() *
sizeof(
vpRGBa ),
4443 std::map< unsigned int, unsigned int > mapOfWidths, mapOfHeights;
4468 if ( mapOfWidths.size() == 1 && mapOfHeights.size() == 1 )
4470 unsigned int width = mapOfWidths.begin()->first;
4471 unsigned int height = mapOfHeights.begin()->first;
4473 RGBa.
resize( height, width );
4475 if ( R != NULL && G != NULL && B != NULL && a != NULL )
4477 SimdInterleaveBgra( R->
bitmap, width, G->
bitmap, width, B->
bitmap, width, a->
bitmap, width, width, height,
4478 reinterpret_cast< uint8_t * >( RGBa.
bitmap ), width *
sizeof(
vpRGBa ) );
4482 unsigned int size = width * height;
4483 for (
unsigned int i = 0; i < size; i++ )
4526 int i = ( ( (int)size ) << 1 ) - 1;
4527 int j = (int)size - 1;
4531 int y = grey16[i--];
4532 grey[j--] =
static_cast< unsigned char >( ( y + ( grey16[i--] << 8 ) ) >> 8 );
4550 int i = ( ( (int)size ) << 1 ) - 1;
4551 int j = (int)( size * 4 - 1 );
4555 int y = grey16[i--];
4556 unsigned char v =
static_cast< unsigned char >( ( y + ( grey16[i--] << 8 ) ) >> 8 );
4575 vpImageConvert::HSV2RGB(
const double *hue_,
const double *saturation_,
const double *value_,
unsigned char *rgb,
4576 unsigned int size,
unsigned int step )
4578 for (
unsigned int i = 0; i < size; i++ )
4580 double hue = hue_[i], saturation = saturation_[i], value = value_[i];
4582 if (
vpMath::equal( saturation, 0.0, std::numeric_limits< double >::epsilon() ) )
4589 double h = hue * 6.0;
4590 double s = saturation;
4593 if (
vpMath::equal( h, 6.0, std::numeric_limits< double >::epsilon() ) )
4598 double f = h - (int)h;
4599 double p = v * ( 1.0 - s );
4600 double q = v * ( 1.0 - s * f );
4601 double t = v * ( 1.0 - s * ( 1.0 - f ) );
4643 rgb[i * step] = (
unsigned char)
vpMath::round( hue * 255.0 );
4644 rgb[i * step + 1] = (
unsigned char)
vpMath::round( saturation * 255.0 );
4645 rgb[i * step + 2] = (
unsigned char)
vpMath::round( value * 255.0 );
4662 vpImageConvert::RGB2HSV(
const unsigned char *rgb,
double *hue,
double *saturation,
double *value,
unsigned int size,
4665 for (
unsigned int i = 0; i < size; i++ )
4667 double red, green, blue;
4671 red = rgb[i * step] / 255.0;
4672 green = rgb[i * step + 1] / 255.0;
4673 blue = rgb[i * step + 2] / 255.0;
4677 max = ( ( std::max ) )( red, blue );
4678 min = ( ( std::min ) )( green, blue );
4682 max = ( ( std::max ) )( green, blue );
4683 min = ( ( std::min ) )( red, blue );
4688 if ( !
vpMath::equal( max, 0.0, std::numeric_limits< double >::epsilon() ) )
4690 s = ( max - min ) / max;
4697 if (
vpMath::equal( s, 0.0, std::numeric_limits< double >::epsilon() ) )
4703 double delta = max - min;
4704 if (
vpMath::equal( delta, 0.0, std::numeric_limits< double >::epsilon() ) )
4709 if (
vpMath::equal( red, max, std::numeric_limits< double >::epsilon() ) )
4711 h = ( green - blue ) / delta;
4713 else if (
vpMath::equal( green, max, std::numeric_limits< double >::epsilon() ) )
4715 h = 2 + ( blue - red ) / delta;
4719 h = 4 + ( red - green ) / delta;
4755 vpImageConvert::HSV2RGB( hue, saturation, value, rgba, size, 4 );
4772 unsigned char *rgba,
unsigned int size )
4774 for (
unsigned int i = 0; i < size; i++ )
4776 double h = hue[i] / 255.0, s = saturation[i] / 255.0, v = value[i] / 255.0;
4798 vpImageConvert::RGB2HSV( rgba, hue, saturation, value, size, 4 );
4814 unsigned char *value,
unsigned int size )
4816 for (
unsigned int i = 0; i < size; i++ )
4821 hue[i] = (
unsigned char)( 255.0 * h );
4822 saturation[i] = (
unsigned char)( 255.0 * s );
4823 value[i] = (
unsigned char)( 255.0 * v );
4841 vpImageConvert::HSV2RGB( hue, saturation, value, rgb, size, 3 );
4856 unsigned char *rgb,
unsigned int size )
4858 for (
unsigned int i = 0; i < size; i++ )
4860 double h = hue[i] / 255.0, s = saturation[i] / 255.0, v = value[i] / 255.0;
4880 vpImageConvert::RGB2HSV( rgb, hue, saturation, value, size, 3 );
4897 for (
unsigned int i = 0; i < size; i++ )
4903 hue[i] = (
unsigned char)( 255.0 * h );
4904 saturation[i] = (
unsigned char)( 255.0 * s );
4905 value[i] = (
unsigned char)( 255.0 * v );
4925 unsigned int nThreads )
4927 demosaicBGGRToRGBaBilinearTpl( bggr, rgba, width, height, nThreads );
4944 unsigned int height,
unsigned int nThreads )
4946 demosaicBGGRToRGBaBilinearTpl( bggr, rgba, width, height, nThreads );
4963 unsigned int nThreads )
4965 demosaicGBRGToRGBaBilinearTpl( gbrg, rgba, width, height, nThreads );
4982 unsigned int height,
unsigned int nThreads )
4984 demosaicGBRGToRGBaBilinearTpl( gbrg, rgba, width, height, nThreads );
5001 unsigned int nThreads )
5003 demosaicGRBGToRGBaBilinearTpl( grbg, rgba, width, height, nThreads );
5020 unsigned int height,
unsigned int nThreads )
5022 demosaicGRBGToRGBaBilinearTpl( grbg, rgba, width, height, nThreads );
5039 unsigned int nThreads )
5041 demosaicRGGBToRGBaBilinearTpl( rggb, rgba, width, height, nThreads );
5058 unsigned int height,
unsigned int nThreads )
5060 demosaicRGGBToRGBaBilinearTpl( rggb, rgba, width, height, nThreads );
5079 unsigned int nThreads )
5081 demosaicBGGRToRGBaMalvarTpl( bggr, rgba, width, height, nThreads );
5098 unsigned int nThreads )
5100 demosaicBGGRToRGBaMalvarTpl( bggr, rgba, width, height, nThreads );
5117 unsigned int nThreads )
5119 demosaicGBRGToRGBaMalvarTpl( gbrg, rgba, width, height, nThreads );
5136 unsigned int nThreads )
5138 demosaicGBRGToRGBaMalvarTpl( gbrg, rgba, width, height, nThreads );
5155 unsigned int nThreads )
5157 demosaicGRBGToRGBaMalvarTpl( grbg, rgba, width, height, nThreads );
5174 unsigned int nThreads )
5176 demosaicGRBGToRGBaMalvarTpl( grbg, rgba, width, height, nThreads );
5193 unsigned int nThreads )
5195 demosaicRGGBToRGBaMalvarTpl( rggb, rgba, width, height, nThreads );
5212 unsigned int nThreads )
5214 demosaicRGGBToRGBaMalvarTpl( rggb, rgba, width, height, nThreads );
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 demosaicBGGRToRGBaBilinear(const uint8_t *bggr, uint8_t *rgba, unsigned int width, unsigned int height, unsigned int nThreads=0)
static void demosaicRGGBToRGBaMalvar(const uint8_t *rggb, uint8_t *rgba, unsigned int width, unsigned int height, unsigned int nThreads=0)
static void convert(const vpImage< unsigned char > &src, vpImage< vpRGBa > &dest)
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 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 BGRaToRGBa(unsigned char *bgra, unsigned char *rgba, unsigned int width, unsigned int height, bool flip=false)
static void YUV420ToGrey(unsigned char *yuv, unsigned char *grey, 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)
static void demosaicGRBGToRGBaBilinear(const uint8_t *grbg, uint8_t *rgba, unsigned int width, unsigned int height, unsigned int nThreads=0)
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 GreyToRGBa(unsigned char *grey, unsigned char *rgba, unsigned int width, unsigned int height)
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 YCrCbToRGB(unsigned char *ycrcb, unsigned char *rgb, unsigned int size)
static void RGBToGrey(unsigned char *rgb, unsigned char *grey, unsigned int width, unsigned int height, bool flip=false)
static void YCrCbToRGBa(unsigned char *ycrcb, unsigned char *rgb, 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 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)
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)
static void RGBaToGrey(unsigned char *rgba, unsigned char *grey, unsigned int width, unsigned int height, unsigned int nThreads=0)
static void demosaicRGGBToRGBaBilinear(const uint8_t *rggb, uint8_t *rgba, unsigned int width, unsigned int height, unsigned int nThreads=0)
static void demosaicGRBGToRGBaMalvar(const uint8_t *grbg, uint8_t *rgba, unsigned int width, unsigned int height, unsigned int nThreads=0)
static void demosaicBGGRToRGBaMalvar(const uint8_t *bggr, uint8_t *rgba, unsigned int width, unsigned int height, unsigned int nThreads=0)
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)
static void BGRToGrey(unsigned char *bgr, unsigned char *grey, unsigned int width, unsigned int height, bool flip=false, unsigned int nThreads=0)
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 BGRaToGrey(unsigned char *bgra, unsigned char *grey, unsigned int width, unsigned int height, bool flip=false, unsigned int nThreads=0)
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 demosaicGBRGToRGBaMalvar(const uint8_t *gbrg, uint8_t *rgba, unsigned int width, unsigned int height, unsigned int nThreads=0)
unsigned int getWidth() const
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)