[theora] YCbCr <-> RGB conversion question
conrad at metadecks.org
Mon Jun 15 19:25:04 PDT 2009
2009/6/16 Ondrej Certik <ondrej at certik.cz>:
> I coded some routines for YCbCr <-> RGB conversion, both using
> floating point numbers and using integer arithmetics, code is
> Let's say I want to convert from RGB to YCbCr and back. First the
> integer arithmetics:
> In : from colors import *
> In : a = [255, 0, 255]
> In : RGB2YCbCr(a)
> Out: (107, 202, 222)
> In : YCbCr2RGB(RGB2YCbCr(a))
> Out: array([255, 1, 255])
> As you can see, the G component was increased from 0 to 1. Those
> routines are the same as here:
> Now let's try floating point conversions:
> In : RGB2YCbCr_precise(a)
> Out: array([106, 202, 222], dtype=uint8)
> In : YCbCr2RGB_precise(RGB2YCbCr_precise(a))
> Out: array([255, 0, 254], dtype=uint8)
> This time the B component was decreased by 1... Those floating point
> routines were done by me, and I followed the theora spec.
> So my questions are:
> * does anyone here have a code, that can convert back and forth
> without loosing precision?
> * does it make sense for those routines to work back and forth exactly?
> I am new to this, so I am not sure what the common practise is, but it
> seems weird to me, that if I convert the picture from YCbCr to RGB and
> back couple times, the image will slowly deteriorate.
Have you compared to the code in liboggplay?
(speaking of which, python bindings to liboggplay would be elite --
that would add audio, sync and seeking support :-)
More information about the theora