YUV4:2:2转换成RGB的代码
来源:互联网 发布:vmp脱壳软件 编辑:程序博客网 时间:2024/05/20 09:45
- int convert_yuv_to_rgb_pixel(int y,int u, int v)
- {
- uint pixel32 = 0;
- uchar *pixel = (uchar *)&pixel32;
- int r, g, b;
- r = y + (1.370705 * (v-128));
- g = y - (0.698001 * (v-128)) - (0.337633 * (u-128));
- b = y + (1.732446 * (u-128));
- if(r > 255) r = 255;
- if(g > 255) g = 255;
- if(b > 255) b = 255;
- if(r < 0) r = 0;
- if(g < 0) g = 0;
- if(b < 0) b = 0;
- pixel[0] = r * 220 / 256;
- pixel[1] = g * 220 / 256;
- pixel[2] = b * 220 / 256;
- return pixel32;
- }
- /*yuv格式转换为rgb格式*/
- int convert_yuv_to_rgb_buffer(uchar *yuv, uchar *rgb, uint width,uint height)
- {
- uint in, out = 0;
- uint pixel_16;
- uchar pixel_24[3];
- uint pixel32;
- int y0, u, y1, v;
- for(in = 0; in < width * height * 2; in += 4) {
- pixel_16 =
- yuv[in + 3] << 24 |
- yuv[in + 2] << 16 |
- yuv[in + 1] << 8 |
- yuv[in + 0];//YUV422每个像素2字节,每两个像素共用一个Cr,Cb值,即u和v,RGB24每个像素3个字节
- y0 = (pixel_16 & 0x000000ff);
- u = (pixel_16 & 0x0000ff00) >> 8;
- y1 = (pixel_16 & 0x00ff0000) >> 16;
- v = (pixel_16 & 0xff000000) >> 24;
- pixel32 = convert_yuv_to_rgb_pixel(y0, u, v);
- pixel_24[0] = (pixel32 & 0x000000ff);
- pixel_24[1] = (pixel32 & 0x0000ff00) >> 8;
- pixel_24[2] = (pixel32 & 0x00ff0000) >> 16;
- rgb[out++] = pixel_24[0];
- rgb[out++] = pixel_24[1];
- rgb[out++] = pixel_24[2];//rgb的一个像素
- pixel32 = convert_yuv_to_rgb_pixel(y1, u, v);
- pixel_24[0] = (pixel32 & 0x000000ff);
- pixel_24[1] = (pixel32 & 0x0000ff00) >> 8;
- pixel_24[2] = (pixel32 & 0x00ff0000) >> 16;
- rgb[out++] = pixel_24[0];
- rgb[out++] = pixel_24[1];
- rgb[out++] = pixel_24[2];
- }
- return 0;
- }
V4L2_PIX_FMT_YUYV — Packed format with ½ horizontal chroma resolution, also known as YUV 4:2:2
In this format each four bytes is two pixels. Each four bytes is two Y's, a Cb and a Cr. Each Y goes to one of the pixels, and the Cb and Cr belong to both pixels. As you can see, the Cr and Cb components have half the horizontal resolution of the Y component.V4L2_PIX_FMT_YUYV
is known in the Windows environment as YUY2.
Color Sample Location.
0 0
- YUV4:2:2转换成RGB的代码
- YUV4:2:2转换成RGB的代码
- YUV4:2:0格式的帧信息
- YUV4:2:2格式压缩成JPEG
- YUV4:2:2与YUV4:2:0区别
- YUV4:2:2和YUV4:2:0 区别
- yuv4:2:0 转成 IplImage
- YUV4:2:2 UYVY图像旋转
- YUV4:2:2 UYVY图像旋转
- YUV4:2:0 与色度采样
- RGB转换为HSV的VC++代码
- RGB转换为HSV的VC++代码
- 视频YUV4:2:2转4:2:0的TI DSP源代码
- 视频YUV4:2:2转4:2:0的TI DSP源代码
- 视频YUV4:2:2转4:2:0的TI DSP源代码
- 视频YUV4:2:2转4:2:0的TI DSP源代码
- [转] RGB到HSV转换的vc代码
- 各种RGB和YUV相互转换的代码
- 第三章 第六题
- 关于JS里面的变量提升
- BaiduMap 显示地图
- P122 第6题 小写转大写
- 虚拟机 virtualbox 安装 CUDA 可行性说明
- YUV4:2:2转换成RGB的代码
- Sturts2 HelloWorld
- Android Studio - UNEXPECTED TOP-LEVEL EXCEPTION:
- View controller-based status bar appearance
- Arcgis标注语义换行
- Go 语言中的 Array,Slice,Map 和 Set
- C#一些委托类型
- [LeetCode] Longest Palindromic Substring
- 传智播客网络营销学院1期学员高薪曝光,程序员汗颜?