Log in

View Full Version : Color space conversions


Stormborec
15th December 2014, 19:21
Which color space do you use, when you need convert from YV12 to RGB, due to some plugin (e.g. virtualdubplugin)?
- RGB24 or RGB32 ?

Reel.Deel
15th December 2014, 19:26
VDub plugins require RGB32; more info here: http://avisynth.nl/index.php/FAQ_using_virtualdub_plugins

Stormborec
15th December 2014, 19:34
OK.
And specifically this Avisynth plugin: http://avisynth.nl/index.php/ColorBalance ? What adventages and disadvantages have using RGB24 vs. RGB32?
Speed vs. rounding errors?

Reel.Deel
15th December 2014, 19:55
I have never done any speed test with RGB24 vs RGB32 and I've never worked with any true RGB32 material in Avisynth.

RGB32 contains an alpha channel which most filters that accept this colorspace usually do not process or just copy the alpha channel from the input clip. Having said that speed will probably will be similar. When converting YUV to RGB24/32 rounding errors will be the same so this shouldn't be of any concern. The best thing to do is to try, compare, and make a decision based on the results.

Ok, found something useful:
http://avisynth.nl/index.php/Color_spaces

RGB24 and RGB32 are both an interleaved image format. The only difference between the two are that RGB32 contains an extra byte for each pixel.

The extra byte RGB32 contains is known as an alpha pixel, but it is actually quite seldom used. The reason RGB32 is considered the "best" format is purely from a programmers view. Handling RGB32 material is much easier than RGB24 material, because most processors operate on 32bits at the time, and not 24.

Stormborec
15th December 2014, 20:20
If I understand you well - better is avoid conversions YUV >>> RGB (to choose plugin/script, which uses YV12)

Reel.Deel
15th December 2014, 20:32
Avoiding YUV to RGB colorspace conversion is indeed is the best route but sometimes is a necessary evil. For native YUV color adjustment give SmoothAdjust (http://forum.doom9.org/showthread.php?t=154971) a try.

Stormborec
15th December 2014, 21:14
Yes. I'm trying now http://avisynth.nl/index.php/WhiteBalance

It seems, it does what I need, but maybe exist something better ... The SmoothAdjust can do also something like white balance?

Reel.Deel
15th December 2014, 21:43
With some ingenuity it may be possible to do white balance correction with SmoothAdjust, I'm sure it'll be cumbersome though. WhiteBalance is tailored for that specific purpose so it may be easier to achieve better results.
Another plugin that comes to minds is AutoAdjust (http://forum.doom9.org/showthread.php?t=167573), again, this may or may not work as well as WhiteBalance but may be worth a shot.

Here are some scripts that are specifically designed for white balance correction.

AWB (http://forum.doom9.org/showthread.php?t=168062) by martin53
Gray Balance (http://forum.doom9.org/showpost.php?p=1629321&postcount=11) by Kisa_AG (have not tried this function)

feisty2
15th December 2014, 23:25
At some point, it's always better to filter under rgb if ur gonna encode at 4:4:4

feisty2
15th December 2014, 23:33
Filter under rgb = about 2bits more precision than the same bitdepth ycbcr
Filter under high bitdepth linear rgb = gamma aware filtering, more correct results theoretically

Stormborec
16th December 2014, 18:57
Thanks :thanks:
The Gray balance looks interesting. I'll try it, if the White balance fails for me.