RGB到YUV 的转变

作者在 2008-08-07 18:36:17 发布以下内容
我们平常德尔图片一般采用RGB编码储存,但是图像处理的时候需要使用 YUV 格式
他们的转换可以使用下面的方式实现

RGBtoYUV (RGBColor *p,float *yptr,float *uptr,float *vptr)
{
    int i,j;
    int t1,t2;
    
    for(i=0;i<height;i++)
    for(j=0;j<width;j++)
    {
        tl=(height-i-1)*width+j;
        t2=(width*i+j);
        *(yptr+t1)=0.2990*(p+t2)->r+0.587*(p+t2)->g+0.114*(p+t2)->b;
        *(uptr+t1)=-0.1687*(p+t2)->r-0.3313*(p+t2)->g+0.5*(p+t2)->b;
        *(vptr+t1)=0.5000*(p+t2)->r-0.4187*(p+t2)->g-0.0813*(p+t2)->b;
    }
}

图像 | 阅读 6851 次
文章评论,共0条
游客请输入验证码
浏览1936598次