Home > Archive > Compression > April 2005 > Color model of MPEG-2?
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Color model of MPEG-2?
|
|
| Wolfgang v. Hansen 2005-04-25, 3:55 am |
| Hi,
how can I convert the YCbCr of an MPEG-2 video to RGB? The specification
(ISO/IEC 13818-2 | H.262, section 6.3.6) says that it "does not define the
display process" but gives several conversion formulae to choose from.
Unfortunately, the video stream I try to decode does not contain a
sequence_display_extension() which means that everything "is assumed to be
implicitly defined by the application". Is there a standard formula to
convert YCbCr to RGB? My video sequence has been directly encoded by a PAL
video camera.
Greetings,
Wolfgang
| |
|
| Hi Wolfgang,
I use these conversion formulae:
Y = 0.257R + 0.504G + 0.098B + 16
Cb = -0.148R - 0.291G + 0.439B + 128
Cr = 0.439R - 0.368G - 0.071B + 128
G = 1.164(Y-16) - 0.391(Cb-128) -0.813(Cr-128)
R = 1.164(Y-16) + 1.596(Cr-128)
B = 1.164(Y-16) + 2.018(Cb-128)
R, G and B range from 0 to 255.
Y ranges from 16 to 235.
Cb and Cr range from 16 to 240.
Hope that helps you.
Nils
www.simdesign.nl
"Wolfgang v. Hansen" <wvhansen@fom.fgan.de> wrote in message
news:Pine.WNT.4.62.0504250711180.1732@WLT064...
> Hi,
>
> how can I convert the YCbCr of an MPEG-2 video to RGB? The specification
> (ISO/IEC 13818-2 | H.262, section 6.3.6) says that it "does not define the
> display process" but gives several conversion formulae to choose from.
> Unfortunately, the video stream I try to decode does not contain a
> sequence_display_extension() which means that everything "is assumed to be
> implicitly defined by the application". Is there a standard formula to
> convert YCbCr to RGB? My video sequence has been directly encoded by a PAL
> video camera.
>
> Greetings,
>
> Wolfgang
| |
| Wolfgang v. Hansen 2005-04-26, 8:55 am |
| On Mon, 25 Apr 2005, Nils wrote:
> I use these conversion formulae:
>
> Y = 0.257R + 0.504G + 0.098B + 16
> Cb = -0.148R - 0.291G + 0.439B + 128
> Cr = 0.439R - 0.368G - 0.071B + 128
>
> G = 1.164(Y-16) - 0.391(Cb-128) -0.813(Cr-128)
> R = 1.164(Y-16) + 1.596(Cr-128)
> B = 1.164(Y-16) + 2.018(Cb-128)
Where did you get these from? It seems that your conversion formulae are
yet another solution. BTW, I even tried a very simple conversion based on
Y = (R + G + B) / 3, i.e. equals weights, and it gave reasonable results.
Maybe it is not so important which formula is chosen?
> R, G and B range from 0 to 255.
> Y ranges from 16 to 235.
> Cb and Cr range from 16 to 240.
How do you deal with Y, Cb or Cr lying outside their range? The decoding
process delivers everything in the range 0 to 255.
Wolfgang
| |
|
| > Where did you get these from?
They are, or should be from the original MPEG2 spec. You can optimize these
by using integer math only.
> How do you deal with Y, Cb or Cr lying outside their range? The decoding
> process delivers everything in the range 0 to 255.
Just trunc the resulting R, G and B to the range of [0..255]
Nils
"Wolfgang v. Hansen" <wvhansen@fom.fgan.de> wrote in message
news:Pine.WNT.4.62.0504260721310.100@WLT064...
> On Mon, 25 Apr 2005, Nils wrote:
>
>
> Where did you get these from? It seems that your conversion formulae are
> yet another solution. BTW, I even tried a very simple conversion based on
> Y = (R + G + B) / 3, i.e. equals weights, and it gave reasonable results.
> Maybe it is not so important which formula is chosen?
>
>
> How do you deal with Y, Cb or Cr lying outside their range? The decoding
> process delivers everything in the range 0 to 255.
>
>
> Wolfgang
| |
|
|
| Wolfgang v. Hansen 2005-04-27, 8:55 am |
| On Tue, 26 Apr 2005, Jim Leonard wrote:
> Wolfgang v. Hansen wrote:
>
> It most certainly does. I suggest you read this:
> http://www.faqs.org/faqs/graphics/colorspace-faq/
After reading sections C-28 to C-30 it seems that the "correct" parameters
for YCbCr are those that are listed in the MPEG-2 standard as "BT.470-2
System B, G", "SMPTE 170M" and (with minor differences) "FCC". I am still
a little bit since the colorspace-faq refers a lot to "BT.709" --
especially because computer monitors seem to be compliant to this
recommendation. But the set of parameters for "BT.709" is quite
different... BTW, do I have to apply a gamma correction or would linear
transfer characteristics be a good assumption?
Wolfgang
|
|
|
|
|