Colors

From Avisynth wiki
(Difference between revisions)
Jump to: navigation, search
m (category)
m (color_yuv)
Line 1: Line 1:
 
[[Category:Advanced_topics]]
 
[[Category:Advanced_topics]]
In some filters ([[BlankClip]], [[Letterbox]], [[AddBorders]] and [[Fade|FadeXXX]]) a color argument can be specified. In all cases the color should be specified in [[RGB]] format even if the colorformat of the input clip is [[YUV]]. This can be done in hexadecimal or decimal notation.  
+
In some filters ([[BlankClip]], [[Letterbox]], [[AddBorders]] and [[Fade|FadeXXX]]) a color argument can be specified. In all cases (except [[#color_yuv|this one]]) the color should be specified in [[RGB]] format even if the color format of the input clip is [[YUV]]. This can be done in hexadecimal or decimal notation.  
  
 
In '''hexadecimal notation''' the number is composed as follows: the first two digits denote the red channel, the next two the green channel and the last two the blue channel. The hexadecimal number must be preceded with a $.  
 
In '''hexadecimal notation''' the number is composed as follows: the first two digits denote the red channel, the next two the green channel and the last two the blue channel. The hexadecimal number must be preceded with a $.  
Line 21: Line 21:
 
Common named colors can be found in the file '''colors_rgb.avsi''', which should be present in your plugin autoload folder. Thus BlankClip(color='''color_brown''') gives the same brown frames. See the page [[Color_presets |Color presets]] for a visual preview.
 
Common named colors can be found in the file '''colors_rgb.avsi''', which should be present in your plugin autoload folder. Thus BlankClip(color='''color_brown''') gives the same brown frames. See the page [[Color_presets |Color presets]] for a visual preview.
  
Note that black RGB=$000000 will be converted to Y=16, U=V=128 if the colorformat of the input clip is YUV, since the default color conversion RGB [0,255] –> YUV [16,235] is used.
+
Note that black RGB=$000000 will be converted to Y=16, U=V=128 if the color format of the input clip is YUV, since the default color conversion RGB [0,255] –> YUV [16,235] is used.
  
todo: add category
+
====color_yuv====
 +
* [[BlankClip]] allows specifying colors in YUV format. This is not very well documented ([[TODO]]), but if you know the YUV color you want, the math is similar to the above:
 +
color_rgb = (r*65536) + (g*256) + b
 +
color_yuv = (y*65536) + (u*256) + v

Revision as of 08:01, 9 January 2016

In some filters (BlankClip, Letterbox, AddBorders and FadeXXX) a color argument can be specified. In all cases (except this one) the color should be specified in RGB format even if the color format of the input clip is YUV. This can be done in hexadecimal or decimal notation.

In hexadecimal notation the number is composed as follows: the first two digits denote the red channel, the next two the green channel and the last two the blue channel. The hexadecimal number must be preceded with a $.

In decimal notation the number is as follows: the red channel value is multiplied by 65536, the green channel value is multiplied by 256 and the two resulting products are both added to the blue channel value.

Let's consider an example. Brown is given by R=$A5 (165), G=$2A (42), B=$2A (42). Thus

BlankClip(color=$A52A2A)

gives a brown frame. Converting each channel to decimal (remember that A=10, B=11, C=12, D=14, E=14, F=15) gives

R = $A5 = 10*16^1 +  5*16^0 = 165
G = $2A =  2*16^1 + 10*16^0 =  42
B = $2A =  2*16^1 + 10*16^0 =  42

165*65536 + 42*256 + 42 = 10824234

Thus creating a brown frame specifying the color in decimal notation gives

BlankClip(color=10824234)

Common named colors can be found in the file colors_rgb.avsi, which should be present in your plugin autoload folder. Thus BlankClip(color=color_brown) gives the same brown frames. See the page Color presets for a visual preview.

Note that black RGB=$000000 will be converted to Y=16, U=V=128 if the color format of the input clip is YUV, since the default color conversion RGB [0,255] –> YUV [16,235] is used.

color_yuv

  • BlankClip allows specifying colors in YUV format. This is not very well documented (TODO), but if you know the YUV color you want, the math is similar to the above:
color_rgb = (r*65536) + (g*256) + b
color_yuv = (y*65536) + (u*256) + v
Personal tools