View Full Version : best rgb yuv conversation
bergi
2nd September 2002, 14:44
I'm testing some wavelet transform, using rgb and yuv color format. I've found many different conversation formulars with different loss, and different ranges, but what formular is used in the standart windows codecs?
alexnoe
6th September 2002, 12:45
When I need that conversion, I used the formula that caused an YUV overlay to look exactly as the RGB-original.
The AVI file format descriptions I have say
Y = 0.299 R + 0.587 G + 0.114 B
U = 0.493 (B - Y)
V = 0.877 (R - Y)
But for my overlay, it definitely didn't work. The colors were somehow "weak". I had to scale the values.
I really don't remember the formula any more, since I did that a year ago or even more, but you can try to extract it from my RGB->YUV source code:
http://www.alexander-noe.de/Video/RGBNYUV/
Guest
8th September 2002, 01:41
Your formulas are wrong.
alexnoe
8th September 2002, 14:20
They are not "my" formulas...they are copy+pasted from an AVI file description.
I know that they can't be correct. As I said, the color was somehow weak if I used them for a RGB->YUV conversion and copied it to an overlay.
Would you be so kind to give the correct ones? You seem to know them...would you mind to share your knowledge?
dividee
8th September 2002, 17:30
By converting avisynth code to formula I get this (rec601):
scaled_Y = 0.299 R + 0.587 B + 0.114 G
Y = 0.859 scaled_Y + 16
U = 0.496 (B - scaled_Y) + 128 (needs clipping)
V = 0.627 (R - scaled_Y) + 128 (needs clipping)
or if you prefer:
Y = 0.257 R + 0.504 G + 0.098 B + 16
U = -0.148 R - 0.291 G + 0.439 B + 128
V = 0.439 R - 0.368 G - 0.071 B + 128
That's assuming the standard representation of 8 bits/components, of course.
Guest
9th September 2002, 05:09
That looks much better. :)
bergi
9th September 2002, 09:06
Thanks!
An other question, there are many different types yuv color formats like yuv12.
i think standard is yuv12 and looks like this
---------
|yuv|y |
---------
|y |y |
---------
Can anybody tell me a good page about yuv color formats or explain it on the forum?
alexnoe
9th September 2002, 09:12
yv12 is (at least for DirectDraw overlays)
------------------
|yyyyyyy...
|yyyyyyy...
|yyyyyyy...
|yyyyyyy...
|v v v v...
|
|v v v v...
|
|u u u u...
|
|u u u u...
|
Unfortunately, the page were I found this some time ago is down :(
EDIT
does anyone have an idea why there are different RGB->YUV formulas? I can promise that the last one won't work with DirectDraw overlays...
mpucoder
9th September 2002, 13:42
Different standards, and mistakes. Some people confuse YIQ, YCbCr, and YPbPr for YUV.
Edit: btw, DVD uses three different standards (ITU-601, aka SMPTE-170 M, is one), so if you are working with DVD source make sure you check which one was used to encode.
http://mpucoder.kewlhair.com/DVD/dvdmpeg.html
Balling
28th August 2021, 16:29
0.493 is just a mistake in BT.470. It is actually 0.492.
DTL
24th September 2021, 23:55
1/1000 error in data is much less error at the full awful idea to use YUV for small 2:1 bitrate compression after subsampling to 4:2:0. Nowdays mpegs can easily reach 1000:1 compression rate but awful 4:2:0 old compression idea still bugs the data today too. I hope someday YUV will be only for processing luma/chroma separately and the awful 4:2:2 and 4:2:0 data-damaging ideas goes to the same grave as interlace scan.
vBulletin® v3.8.11, Copyright ©2000-2024, vBulletin Solutions Inc.