博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
YUV420只绘制Y通道
阅读量:4058 次
发布时间:2019-05-25

本文共 1064 字,大约阅读时间需要 3 分钟。

前段时间整个一个yuv文件,格式为352x240,YUV420格式的,即YYYYUUVV,准备使用Qt进行重绘显示。不知道为什么转换为RGB显示出来乱乱的,

最近做只显示出Y通道的灰度图像,刚做成功。

灰度图像即RGB三颜色是一样的,需要建立一个8位的256级的灰度索引表,用0~255表示颜色的深度。

然后构建一个8位的QImage并设置它的颜色索引表,让它去颜色表中查颜色。

Qt中的QImage提供了对每一个像素的操作。

关键是setPixel这个函数。

void QImage::setPixel(const QPoint & position, uint index_or_rgb)

Sets the pixel index or color at the given position to index_or_rgb.
If the image's format is either monochrome or 8-bit, the given index_or_rgb value must be an index in the image's color table, otherwise the parameter must be a QRgb value.
If position is not a valid coordinate pair in the image, or if index_or_rgb >= colorCount() in the case of monochrome and 8-bit images, the result is undefined.
Warning: This function is expensive due to the call of the internal detach() function called within; if performance is a concern, we recommend the use of scanLine() to access pixel data directly.

上面的代码还是让人费解的。修改为下面的效果是一样的。从代码的理解上也是,从Y平面数组中查找了Y通道的每个像素点的数据

然后查灰度颜色表,再设置QImage每个像素点的颜色。(即灰度)

现在显示Y通道的图像成功了,下一步要加入U,V让图像显示出颜色来以加深根据YUV数据进行RGB图像重构的方法。

以及YUV数据存储跟实际像素的对应关系。

你可能感兴趣的文章
【leetcode】Pascal's Triangle II (python)
查看>>
java自定义容器排序的两种方法
查看>>
如何成为编程高手
查看>>
本科生的编程水平到底有多高
查看>>
AngularJS2中最基本的文件说明
查看>>
从头开始学习jsp(2)——jsp的基本语法
查看>>
使用与或运算完成两个整数的相加
查看>>
备忘:java中的递归
查看>>
DIV/CSS:一个贴在左上角的标签
查看>>
Solr及Spring-Data-Solr入门学习
查看>>
Vue组件
查看>>
python_time模块
查看>>
python_configparser(解析ini)
查看>>
selenium学习资料
查看>>
<转>文档视图指针互获
查看>>
从mysql中 导出/导入表及数据
查看>>
HQL语句大全(转)
查看>>
几个常用的Javascript字符串处理函数 spilt(),join(),substring()和indexof()
查看>>
javascript传参字符串 与引号的嵌套调用
查看>>
swiper插件的的使用
查看>>