用C读取YUV图像 [英] Reading YUV images in C

查看:1869
本文介绍了用C读取YUV图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


  1. 如何阅读任何YUV图像?


  2. 如何能在YUV图像的尺寸读取到缓冲区通过?



解决方案

  1. 通常,当人们谈论YUV他们谈论的 YUV 4:2:0 。参考到的任何的YUV图像是误导,因为有许多不同的格式,并且每个的处理方式不同。例如,生YUV 4:2:0(按照惯例,带延长 .yuv 文件)不包含任何尺寸数据;而 Y4M 文件通常做的。所以,你真的需要知道你正在处理什么样的形象与你开始阅读之前。对于YUV 4:2:0,你只需打开该文件,并读取顺序亮度(Y')和色度(的CbCr)成分,牢记色度分量被毁灭(亮度分量的四分之一大小)。之后,你通常转化为在Y'CbCr RGB这样就可以显示图片。


  2. 从我上面提到的,您只需不能确定的任何的YUV图像的尺寸。通常情况下,尺寸根本就没有在文件中。你要知道他们的前面 - 这就是为什么 网站上市YUV文件下载还列出他们的框架尺寸(和视频,数帧)。最YUV文件或者是CIF(352×288)或QCIF(176×144),虽然有一些文件从模拟视频是在稍微不同的SIF格式数字化。阅读不同格式这里


  1. How to read any yuv image?

  2. How can the dimensions of an YUV image be passed for reading to a buffer?

解决方案

  1. Usually, when people talk about YUV they talk about YUV 4:2:0. Your reference to any YUV image is misleading, because there are a number of different formats, and each is handled differently. For example, raw YUV 4:2:0 (by convention, files with an extension .yuv) doesn't contain any dimension data; whereas y4m files typically do. So you really need to know what sort of image you're dealing with before you start reading it. For YUV 4:2:0, you just open the file and read the luminance (Y') and chrominance (CbCr) components in that order, keeping in mind the chrominance components have been decimated (quarter size of the luminance components). After that you typically convert Y'CbCr to RGB so you can display the image.

  2. From what I've mentioned above, you simply can't determine the dimensions of any YUV image. Often, the dimensions are simply not in the file. You have to know them up front -- this is why most sites listing YUV files for download also list their frame dimensions (and for video, the number of frames). Most YUV files are either CIF (352x288) or QCIF (176x144), although there are some files digitized from analog video that are in the slightly different SIF format. Read about the different formats here.

这篇关于用C读取YUV图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆