Log in

View Full Version : YUV color picker?


Reel.Deel
24th February 2015, 15:30
Hi,

I was wondering if someone knows of a YUV color picker that can correctly tell you the hex value for a color in the 601/709 (TV and PC range)? Something like this but in YUV: http://www.w3schools.com/tags/ref_colorpicker.asp

I know AvsPmod displays YUV values but it does not have a color picker. There's the also the color presets (http://avisynth.nl/index.php/Color_presets) page in the wiki but colors are for RGB.


Edit: Blankclip has the color_yuv parameter but what is it based on? 601 or 709?

StainlessS
24th February 2015, 15:35
Googled "color picker yuv", seems no shortage of choice
1st on list
http://stnsoft.com/DVD/color_pick.html

Reel.Deel
24th February 2015, 15:38
Yeah, I saw that page while searching yesterday but what gets me is the slight color difference when using a 709 matrix. So I was looking for a something similar to that can tell me the correct value based on the matrix that I want to use.

StainlessS
24th February 2015, 16:28
This any good to you ?

EDIT: Take 3

Function RGB_2_YUV(Int RGB_Color,String Matrix) {
RGB_Color=RT_BitAnd(RGB_Color,$FFFFFF)
BlankClip(Width=16,Height=16,Length=1,Color=RGB_Color)
c=ConvertToYV12(matrix=matrix)
current_frame=0
Y=c.YPlaneMin() U=c.UPlaneMin() V=c.VPlaneMin()
Col = (((Y*256)+U)*256)+V
return Col
}

RGB=$FFFFFF
Matrix= "Rec601" # "Rec601", "Rec709", "PC601", "PC709"


YUV=RGB_2_YUV(RGB,Matrix)
SRGB=RT_Hex(RGB,6)
SYUV=RT_Hex(YUV,6)

Messageclip("RGB = $"+SRGB+" : YUV=$"+SYUV + " (Matrix="+Matrix+")")

StainlessS
24th February 2015, 17:44
Or this

Matrix = "Rec601" # "Rec601", "Rec709", "PC601", "PC709"
ColorsRGB = "colors_rgb.avsi"
ColorsYUV = "colors_yuv_"+Matrix+".avsi"

Assert(Exist(ColorsRGB),ColorsRGB+" Does not exist")

Exist(ColorsYUV) ? RT_FileDelete(ColorsYUV) : NOP

PAD = 40
INSERT=RT_String("(yuv values [Matrix='%s'])",Matrix)

GSCript("""
TEXT=RT_ReadTxtFromFile(ColorsRGB)
LINES=RT_TxtQueryLines(TEXT)

for(i=0,LINES-1) {
S=RT_TxtGetLine(TEXT,i)
S=(S!="")?RT_StrReplaceDeep(RT_StrReplace(S,Chr(9)," ")," "," "):S
S=(S!="")?RT_StrReplace(S,"(rgb values)",INSERT):S
While(RT_Ord(S)==32) {S=MidStr(S,2)}
if(RT_Ord(S)==RT_Ord("#") || RT_Ord(S)==0) {
S=(RT_Ord(S)==0)?Chr(10):S
RT_WriteFile(ColorsYUV,"%s",S,Append=True)
} Else {
Hx = RT_FindStr(S,"= $")
Assert(Hx!=0,"Cannot find Dollar")
SOUT=RT_StrReplace(LeftStr(S,Hx-1),"color_",Matrix+"_",sig=false)
SOUT=RT_StrPad(SOUT,40)
RGB=RT_HexValue(S,pos=Hx+3)
YUV=RGB_2_YUV(RGB,Matrix)
RT_Writefile(ColorsYUV,"%s= $%0.6X # RGB = $%0.6X",SOUT,YUV,RGB,Append=True)
}
}
""")
return MessageClip("Done")


Function RGB_2_YUV(Int RGB_Color,String Matrix) {
RGB_Color=RT_BitAnd(RGB_Color,$FFFFFF)
BlankClip(Width=16,Height=16,Length=1,Color=RGB_Color)
c=ConvertToYV12(matrix=matrix)
current_frame=0
Y=c.YPlaneMin() U=c.UPlaneMin() V=c.VPlaneMin()
Col = (((Y*256)+U)*256)+V
return Col
}

EDITED

Convert Colors_rgb_avsi to YUV file using chosen matrix.

Results: colors_yuv_Rec601.avsi

# list of common colors (yuv values [Matrix='Rec601'])

# source:
# http://en.wikipedia.org/wiki/List_of_colors
# http://en.wikipedia.org/wiki/X11_color_names
# http://www.cryer.co.uk/resources/javascript/html2.htm

global Rec601_aliceblue = $E4847C # RGB = $F0F8FF
global Rec601_antiquewhite = $DC7588 # RGB = $FAEBD7
global Rec601_aqua = $AAA610 # RGB = $00FFFF
global Rec601_aquamarine = $C6804B # RGB = $7FFFD4
global Rec601_azure = $E78279 # RGB = $F0FFFF
global Rec601_beige = $E07582 # RGB = $F5F5DC
global Rec601_bisque = $D86E8E # RGB = $FFE4C4
global Rec601_black = $108080 # RGB = $000000
global Rec601_blanchedalmond = $DC708B # RGB = $FFEBCD
global Rec601_blue = $29F06E # RGB = $0000FF
global Rec601_blueviolet = $5FC29D # RGB = $8A2BE2
global Rec601_brown = $546EB6 # RGB = $A52A2A
global Rec601_burlywood = $B36594 # RGB = $DEB887
global Rec601_cadetblue = $888A64 # RGB = $5F9EA0
global Rec601_chartreuse = $B1235A # RGB = $7FFF00
global Rec601_chocolate = $7E50B3 # RGB = $D2691E
global Rec601_coral = $9958BC # RGB = $FF7F50
global Rec601_cornflowerblue = $8CAE64 # RGB = $6495ED
global Rec601_cornsilk = $E47385 # RGB = $FFF8DC
global Rec601_crimson = $5874D5 # RGB = $DC143C
global Rec601_cyan = $AAA610 # RGB = $00FFFF
global Rec601_darkblue = $1EBD76 # RGB = $00008B
global Rec601_darkcyan = $649543 # RGB = $008B8B
global Rec601_darkgoldenrod = $84439F # RGB = $B8860B
global Rec601_darkgray = $A18080 # RGB = $A9A9A9
global Rec601_darkgreen = $42635B # RGB = $006400
global Rec601_darkkhaki = $A75E88 # RGB = $BDB76B
global Rec601_darkmagenta = $41A8B3 # RGB = $8B008B
global Rec601_darkoliveGreen = $60697B # RGB = $556B2F
global Rec601_darkorange = $9831BD # RGB = $FF8C00
global Rec601_darkorchid = $64B4A2 # RGB = $9932CC
global Rec601_darkred = $346BBD # RGB = $8B0000
global Rec601_darksalmon = $A367A6 # RGB = $E9967A
global Rec601_darkseaGreen = $A1736F # RGB = $8FBC8F
global Rec601_darkslateBlue = $4FA17F # RGB = $483D8B
global Rec601_darkslateGray = $4C8572 # RGB = $2F4F4F
global Rec601_darkturquoise = $8CA025 # RGB = $00CED1
global Rec601_darkviolet = $4BC7B2 # RGB = $9400D3
global Rec601_deeppink = $6A95DE # RGB = $FF1493
global Rec601_deepskyblue = $89B828 # RGB = $00BFFF
global Rec601_dimgray = $6A8080 # RGB = $696969
global Rec601_dodgerblue = $79C246 # RGB = $1E90FF
global Rec601_firebrick = $526BBF # RGB = $B22222
global Rec601_floralwhite = $E77B83 # RGB = $FFFAF0
global Rec601_forestgreen = $626159 # RGB = $228B22
global Rec601_fuchsia = $6ACADE # RGB = $FF00FF
global Rec601_gainsboro = $CD8080 # RGB = $DCDCDC
global Rec601_ghostwhite = $E68380 # RGB = $F8F8FF
global Rec601_gold = $BE1CA1 # RGB = $FFD700
global Rec601_goldenrod = $9E3EA1 # RGB = $DAA520
global Rec601_gray = $7E8080 # RGB = $808080
global Rec601_green = $515B51 # RGB = $008000
global Rec601_greenyellow = $C2316B # RGB = $ADFF2F
global Rec601_honeydew = $E67C7A # RGB = $F0FFF0
global Rec601_hotpink = $988BBD # RGB = $FF69B4
global Rec601_indianred = $7C6FB2 # RGB = $CD5C5C
global Rec601_indigo = $30AE98 # RGB = $4B0082
global Rec601_ivory = $EA7981 # RGB = $FFFFF0
global Rec601_khaki = $CF578B # RGB = $F0E68C
global Rec601_lavender = $D7897F # RGB = $E6E6FA
global Rec601_lavenderblush = $E28086 # RGB = $FFF0F5
global Rec601_lawngreen = $AF245A # RGB = $7CFC00
global Rec601_lemonchiffon = $E46C85 # RGB = $FFFACD
global Rec601_lightblue = $C08D6C # RGB = $ADD8E6
global Rec601_lightcoral = $9B6FB1 # RGB = $F08080
global Rec601_lightcyan = $E38572 # RGB = $E0FFFF
global Rec601_lightgoldenrodyellow = $E36E83 # RGB = $FAFAD2
global Rec601_lightgreen = $BB655D # RGB = $90EE90
global Rec601_lightgrey = $C58080 # RGB = $D3D3D3
global Rec601_lightpink = $C07A9F # RGB = $FFB6C1
global Rec601_lightsalmon = $AE61AC # RGB = $FFA07A
global Rec601_lightseagreen = $839240 # RGB = $20B2AA
global Rec601_lightskyblue = $B39E5E # RGB = $87CEFA
global Rec601_lightslategray = $828A77 # RGB = $778899
global Rec601_lightsteelblue = $B68E75 # RGB = $B0C4DE
global Rec601_lightyellow = $E87282 # RGB = $FFFFE0
global Rec601_lime = $913622 # RGB = $00FF00
global Rec601_limegreen = $895347 # RGB = $32CD32
global Rec601_linen = $E07A85 # RGB = $FAF0E6
global Rec601_magenta = $6ACADE # RGB = $FF00FF
global Rec601_maroon = $316DB8 # RGB = $800000
global Rec601_mediumaquamarine = $A28055 # RGB = $66CDAA
global Rec601_mediumblue = $24DA71 # RGB = $0000CD
global Rec601_mediumorchid = $7FA8A3 # RGB = $BA55D3
global Rec601_mediumpurple = $84AA88 # RGB = $9370DB
global Rec601_mediumseagreen = $857550 # RGB = $3CB371
global Rec601_mediumslatenlue = $7BB87F # RGB = $7B68EE
global Rec601_mediumspringgreen = $9D7B19 # RGB = $00FA9A
global Rec601_mediumturquoise = $A09244 # RGB = $48D1CC
global Rec601_mediumvioletred = $5B97C6 # RGB = $C71585
global Rec601_midnightblue = $2EA67A # RGB = $191970
global Rec601_mintcream = $E87F7C # RGB = $F5FFFA
global Rec601_mistyrose = $DA7B8C # RGB = $FFE4E1
global Rec601_moccasin = $D6678F # RGB = $FFE4B5
global Rec601_navajowhite = $D26692 # RGB = $FFDEAD
global Rec601_navy = $1DB877 # RGB = $000080
global Rec601_oldlace = $E37885 # RGB = $FDF5E6
global Rec601_olive = $714889 # RGB = $808000
global Rec601_olivedrab = $765678 # RGB = $6B8E23
global Rec601_orange = $A52AB3 # RGB = $FFA500
global Rec601_orangered = $7446D7 # RGB = $FF4500
global Rec601_orchid = $959DA7 # RGB = $DA70D6
global Rec601_palegoldenrod = $D36487 # RGB = $EEE8AA
global Rec601_palegreen = $C4635C # RGB = $98FB98
global Rec601_paleturquoise = $CC8964 # RGB = $AFEEEE
global Rec601_palevioletred = $8F80AC # RGB = $DB7093
global Rec601_papayawhip = $DF7289 # RGB = $FFEFD5
global Rec601_peachpuff = $D16C93 # RGB = $FFDAB9
global Rec601_peru = $8E57A5 # RGB = $CD853F
global Rec601_pink = $C67C9B # RGB = $FFC0CB
global Rec601_plum = $AF9296 # RGB = $DDA0DD
global Rec601_powderblue = $C58A6A # RGB = $B0E0E6
global Rec601_purple = $3DA5AF # RGB = $800080
global Rec601_red = $515AF0 # RGB = $FF0000
global Rec601_rosybrown = $967994 # RGB = $BC8F8F
global Rec601_royalblue = $6CBB66 # RGB = $4169E1
global Rec601_saddlebrown = $5860A2 # RGB = $8B4513
global Rec601_salmon = $9C68B7 # RGB = $FA8072
global Rec601_sandybrown = $AB56A8 # RGB = $F4A460
global Rec601_seagreen = $6A775B # RGB = $2E8B57
global Rec601_seashell = $E47B85 # RGB = $FFF5EE
global Rec601_sienna = $6764A5 # RGB = $A0522D
global Rec601_silver = $B58080 # RGB = $C0C0C0
global Rec601_skyblue = $B2975F # RGB = $87CEEB
global Rec601_slateblue = $6DB07F # RGB = $6A5ACD
global Rec601_slategray = $7B8978 # RGB = $708090
global Rec601_snow = $E87F82 # RGB = $FFFAFA
global Rec601_springgreen = $9D6E19 # RGB = $00FF7F
global Rec601_steelblue = $759F62 # RGB = $4682B4
global Rec601_tan = $AE6A90 # RGB = $D2B48C
global Rec601_teal = $5D9348 # RGB = $008080
global Rec601_thistle = $BD8789 # RGB = $D8BFD8
global Rec601_tomato = $8A5DC7 # RGB = $FF6347
global Rec601_turquoise = $A6913B # RGB = $40E0D0
global Rec601_violet = $A69FA8 # RGB = $EE82EE
global Rec601_wheat = $D06A8D # RGB = $F5DEB3
global Rec601_white = $EB8080 # RGB = $FFFFFF
global Rec601_whitesmoke = $E28080 # RGB = $F5F5F5
global Rec601_yellow = $D21092 # RGB = $FFFF00
global Rec601_yellowgreen = $A44375 # RGB = $9ACD32

#Gray colors
global Rec601_gray10 = $258080 # RGB = $191919
global Rec601_gray20 = $3B8080 # RGB = $323232
global Rec601_gray30 = $508080 # RGB = $4B4B4B
global Rec601_gray40 = $678080 # RGB = $656565
global Rec601_gray50 = $7D8080 # RGB = $7F7F7F
global Rec601_gray60 = $938080 # RGB = $989898
global Rec601_gray70 = $A88080 # RGB = $B1B1B1
global Rec601_gray80 = $BD8080 # RGB = $CACACA
global Rec601_gray90 = $D48080 # RGB = $E4E4E4

StainlessS
24th February 2015, 17:47
Or rec709: colors_yuv_Rec709.avsi

# list of common colors (yuv values [Matrix='Rec709'])

# source:
# http://en.wikipedia.org/wiki/List_of_colors
# http://en.wikipedia.org/wiki/X11_color_names
# http://www.cryer.co.uk/resources/javascript/html2.htm

global Rec709_aliceblue = $E4847C # RGB = $F0F8FF
global Rec709_antiquewhite = $DB7687 # RGB = $FAEBD7
global Rec709_aqua = $BC9A10 # RGB = $00FFFF
global Rec709_aquamarine = $D17A4A # RGB = $7FFFD4
global Rec709_azure = $E88279 # RGB = $F0FFFF
global Rec709_beige = $E17581 # RGB = $F5F5DC
global Rec709_bisque = $D76F8D # RGB = $FFE4C4
global Rec709_black = $108080 # RGB = $000000
global Rec709_blanchedalmond = $DC718A # RGB = $FFEBCD
global Rec709_blue = $20F076 # RGB = $0000FF
global Rec709_blueviolet = $52C7A2 # RGB = $8A2BE2
global Rec709_brown = $4B74B6 # RGB = $A52A2A
global Rec709_burlywood = $B26793 # RGB = $DEB887
global Rec709_cadetblue = $8C8764 # RGB = $5F9EA0
global Rec709_chartreuse = $C41D52 # RGB = $7FFF00
global Rec709_chocolate = $7955B1 # RGB = $D2691E
global Rec709_coral = $925EBA # RGB = $FF7F50
global Rec709_cornflowerblue = $8CAC67 # RGB = $6495ED
global Rec709_cornsilk = $E57384 # RGB = $FFF8DC
global Rec709_crimson = $487DD6 # RGB = $DC143C
global Rec709_cyan = $BC9A10 # RGB = $00FFFF
global Rec709_darkblue = $19BD7A # RGB = $00008B
global Rec709_darkcyan = $6E8E43 # RGB = $008B8B
global Rec709_darkgoldenrod = $85459B # RGB = $B8860B
global Rec709_darkgray = $A18080 # RGB = $A9A9A9
global Rec709_darkgreen = $4D5E58 # RGB = $006400
global Rec709_darkkhaki = $AA5E86 # RGB = $BDB76B
global Rec709_darkmagenta = $32AFB7 # RGB = $8B008B
global Rec709_darkoliveGreen = $646879 # RGB = $556B2F
global Rec709_darkorange = $9537B8 # RGB = $FF8C00
global Rec709_darkorchid = $57B9A7 # RGB = $9932CC
global Rec709_darkred = $2972BD # RGB = $8B0000
global Rec709_darksalmon = $9E6BA6 # RGB = $E9967A
global Rec709_darkseaGreen = $A6716E # RGB = $8FBC8F
global Rec709_darkslateBlue = $4BA182 # RGB = $483D8B
global Rec709_darkslateGray = $4E8372 # RGB = $2F4F4F
global Rec709_darkturquoise = $9B9625 # RGB = $00CED1
global Rec709_darkviolet = $38CEB9 # RGB = $9400D3
global Rec709_deeppink = $54A0E2 # RGB = $FF1493
global Rec709_deepskyblue = $95AF2A # RGB = $00BFFF
global Rec709_dimgray = $6A8080 # RGB = $696969
global Rec709_dodgerblue = $7EBC49 # RGB = $1E90FF
global Rec709_firebrick = $4772BF # RGB = $B22222
global Rec709_floralwhite = $E77B83 # RGB = $FFFAF0
global Rec709_forestgreen = $6E5C56 # RGB = $228B22
global Rec709_fuchsia = $4ED6E6 # RGB = $FF00FF
global Rec709_gainsboro = $CD8080 # RGB = $DCDCDC
global Rec709_ghostwhite = $E58380 # RGB = $F8F8FF
global Rec709_gold = $C31E9A # RGB = $FFD700
global Rec709_goldenrod = $9F409D # RGB = $DAA520
global Rec709_gray = $7E8080 # RGB = $808080
global Rec709_green = $5F554D # RGB = $008000
global Rec709_greenyellow = $CF2D64 # RGB = $ADFF2F
global Rec709_honeydew = $E77B7A # RGB = $F0FFF0
global Rec709_hotpink = $8A92BF # RGB = $FF69B4
global Rec709_indianred = $7475B2 # RGB = $CD5C5C
global Rec709_indigo = $26B29C # RGB = $4B0082
global Rec709_ivory = $EA7981 # RGB = $FFFFF0
global Rec709_khaki = $D25788 # RGB = $F0E68C
global Rec709_lavender = $D7897F # RGB = $E6E6FA
global Rec709_lavenderblush = $E18186 # RGB = $FFF0F5
global Rec709_lawngreen = $C11E52 # RGB = $7CFC00
global Rec709_lemonchiffon = $E56C84 # RGB = $FFFACD
global Rec709_lightblue = $C38A6D # RGB = $ADD8E6
global Rec709_lightcoral = $9275B1 # RGB = $F08080
global Rec709_lightcyan = $E58372 # RGB = $E0FFFF
global Rec709_lightgoldenrodyellow = $E46E82 # RGB = $FAFAD2
global Rec709_lightgreen = $C5605B # RGB = $90EE90
global Rec709_lightgrey = $C58080 # RGB = $D3D3D3
global Rec709_lightpink = $BA7DA0 # RGB = $FFB6C1
global Rec709_lightsalmon = $A866AB # RGB = $FFA07A
global Rec709_lightseagreen = $8E8B40 # RGB = $20B2AA
global Rec709_lightskyblue = $B79A5F # RGB = $87CEFA
global Rec709_lightslategray = $838978 # RGB = $778899
global Rec709_lightsteelblue = $B68D76 # RGB = $B0C4DE
global Rec709_lightyellow = $E97281 # RGB = $FFFFE0
global Rec709_lime = $AD2A1A # RGB = $00FF00
global Rec709_limegreen = $9A4C42 # RGB = $32CD32
global Rec709_linen = $DF7B85 # RGB = $FAF0E6
global Rec709_magenta = $4ED6E6 # RGB = $FF00FF
global Rec709_maroon = $2773B8 # RGB = $800000
global Rec709_mediumaquamarine = $AB7B54 # RGB = $66CDAA
global Rec709_mediumblue = $1DDA78 # RGB = $0000CD
global Rec709_mediumorchid = $73ADA7 # RGB = $BA55D3
global Rec709_mediumpurple = $7DAB8B # RGB = $9370DB
global Rec709_mediumseagreen = $906F4E # RGB = $3CB371
global Rec709_mediumslatenlue = $75B983 # RGB = $7B68EE
global Rec709_mediumspringgreen = $B36F16 # RGB = $00FA9A
global Rec709_mediumturquoise = $AA8C44 # RGB = $48D1CC
global Rec709_mediumvioletred = $499FCA # RGB = $C71585
global Rec709_midnightblue = $2BA67C # RGB = $191970
global Rec709_mintcream = $E97F7C # RGB = $F5FFFA
global Rec709_mistyrose = $D97C8C # RGB = $FFE4E1
global Rec709_moccasin = $D6698E # RGB = $FFE4B5
global Rec709_navajowhite = $D26790 # RGB = $FFDEAD
global Rec709_navy = $18B87B # RGB = $000080
global Rec709_oldlace = $E37984 # RGB = $FDF5E6
global Rec709_olive = $764885 # RGB = $808000
global Rec709_olivedrab = $7D5575 # RGB = $6B8E23
global Rec709_orange = $A42EAE # RGB = $FFA500
global Rec709_orangered = $694FD4 # RGB = $FF4500
global Rec709_orchid = $8AA2AA # RGB = $DA70D6
global Rec709_palegoldenrod = $D46485 # RGB = $EEE8AA
global Rec709_palegreen = $CF5E59 # RGB = $98FB98
global Rec709_paleturquoise = $D18664 # RGB = $AFEEEE
global Rec709_palevioletred = $8685AE # RGB = $DB7093
global Rec709_papayawhip = $DF7388 # RGB = $FFEFD5
global Rec709_peachpuff = $D06E92 # RGB = $FFDAB9
global Rec709_peru = $8B5AA2 # RGB = $CD853F
global Rec709_pink = $C17F9B # RGB = $FFC0CB
global Rec709_plum = $A89598 # RGB = $DDA0DD
global Rec709_powderblue = $C8876B # RGB = $B0E0E6
global Rec709_purple = $2FABB3 # RGB = $800080
global Rec709_red = $3F66F0 # RGB = $FF0000
global Rec709_rosybrown = $937B94 # RGB = $BC8F8F
global Rec709_royalblue = $6AB96A # RGB = $4169E1
global Rec709_saddlebrown = $5563A1 # RGB = $8B4513
global Rec709_salmon = $936EB6 # RGB = $FA8072
global Rec709_sandybrown = $A75AA6 # RGB = $F4A460
global Rec709_seagreen = $737359 # RGB = $2E8B57
global Rec709_seashell = $E47C85 # RGB = $FFF5EE
global Rec709_sienna = $6268A4 # RGB = $A0522D
global Rec709_silver = $B58080 # RGB = $C0C0C0
global Rec709_skyblue = $B69460 # RGB = $87CEEB
global Rec709_slateblue = $67B182 # RGB = $6A5ACD
global Rec709_slategray = $7C8978 # RGB = $708090
global Rec709_snow = $E88082 # RGB = $FFFAFA
global Rec709_springgreen = $B56115 # RGB = $00FF7F
global Rec709_steelblue = $789C64 # RGB = $4682B4
global Rec709_tan = $AE6B8F # RGB = $D2B48C
global Rec709_teal = $678D48 # RGB = $008080
global Rec709_thistle = $BA888A # RGB = $D8BFD8
global Rec709_tomato = $8064C6 # RGB = $FF6347
global Rec709_turquoise = $B2893A # RGB = $40E0D0
global Rec709_violet = $9AA5AB # RGB = $EE82EE
global Rec709_wheat = $D06B8C # RGB = $F5DEB3
global Rec709_white = $EB8080 # RGB = $FFFFFF
global Rec709_whitesmoke = $E28080 # RGB = $F5F5F5
global Rec709_yellow = $DB108A # RGB = $FFFF00
global Rec709_yellowgreen = $AD4170 # RGB = $9ACD32

#Gray colors
global Rec709_gray10 = $258080 # RGB = $191919
global Rec709_gray20 = $3B8080 # RGB = $323232
global Rec709_gray30 = $508080 # RGB = $4B4B4B
global Rec709_gray40 = $678080 # RGB = $656565
global Rec709_gray50 = $7D8080 # RGB = $7F7F7F
global Rec709_gray60 = $938080 # RGB = $989898
global Rec709_gray70 = $A88080 # RGB = $B1B1B1
global Rec709_gray80 = $BD8080 # RGB = $CACACA
global Rec709_gray90 = $D48080 # RGB = $E4E4E4

Reel.Deel
24th February 2015, 21:09
Thank you very much StainlessS! I admire how you always go the extra mile to help out! Just tried it out and it worked as expected. Thanks again. :)

StainlessS
24th February 2015, 22:06
you always go the extra mile
Be quiet, I'm not done yet. :)


#ColorPickerClip.avs

ColorsRGB = "colors_rgb.avsi"
DB = "Colors.DB"

MakeDB(DB,ColorsRGB)
MakeClip(DB).AssumeFPS(1.0)
Frames = (Height/48-10)+1
Loop(Frames,0,0)
Animate(0,Frames-1,"Spline36Resize",640,480,0,0,-0,480,640,480,0,Height-480,-0,480)
#ConvertToYV12() # To make the mp4
RT_FileDelete(DB) # EDIT: Added
Return last

Function RGB_2_YUV(Int RGB_Color,String Matrix) {
RGB_Color=RT_BitAnd(RGB_Color,$FFFFFF)
BlankClip(Width=16,Height=16,Length=1,Color=RGB_Color)
c=ConvertToYV12(matrix=matrix)
current_frame=0
Y=c.YPlaneMin() U=c.UPlaneMin() V=c.VPlaneMin()
Col = (((Y*256)+U)*256)+V
return Col
}

Function MakeDB(String DB,String ColorsRGB) {
myName="MakeDB: "
Assert(Exist(ColorsRGB),RT_String("%s %s Does not exist",myName,ColorsRGB))
Assert(DB!="",RT_String("%s DBase Name Cannot be null",myName))
Exist(DB) ? RT_FileDelete(DB) : NOP
GScript("""
RT_DBaseAlloc(DB,0,"iiis64")
TEXT=RT_ReadTxtFromFile(ColorsRGB)
LINES=RT_TxtQueryLines(TEXT)
for(i=0,LINES-1) {
S=RT_TxtGetLine(TEXT,i)
S=(S!="")?RT_StrReplaceDeep(RT_StrReplace(S,Chr(9)," ")," "," "):S
While(RT_Ord(S)==32) {S=MidStr(S,2)}
if(RT_Ord(S)!=RT_Ord("#") && RT_Ord(S)!=0) {
nm = RT_FindStr(S,"color_")
Assert(nm!=0,"Cannot find color name")
S = MidStr(S,nm)
nmend = RT_FindStr(S," ")
Assert(nm!=0,"Cannot find color name end")
Name = LeftStr(S,nmend)
S = MidStr(S,nmend)
Hx = RT_FindStr(S,"= $")
Assert(Hx!=0,"Cannot find Dollar")
RGB=RT_HexValue(S,pos=Hx+3)
YUV601=RGB_2_YUV(RGB,"Rec601")
YUV709=RGB_2_YUV(RGB,"Rec709")
RT_DBaseAppend(DB,RGB,YUV601,YUV709,Name)
}
}
""")
Return 0
}

Function MakeClip(String DB) {
H = 48
records = RT_DBaseRecords(DB)
nmtmpt = BlankClip(length=1,width=316,height=H,pixel_type="RGB32").KillAudio
hxtmpt = BlankClip(length=1,width=108,height=H,pixel_type="RGB32").KillAudio
NC = nmtmpt.BlankClip(color=$FFFFFF).Subtitle("Color Name",Align=5).LetterBox(2,2,2,2)
RGBC = hxtmpt.BlankClip(color=$FFFFFF).Subtitle("RGB",Align=5).LetterBox(2,2,2,2)
Y601C = hxtmpt.BlankClip(color=$FFFFFF).Subtitle("YUV rec601",Align=5).LetterBox(2,2,2,2)
Y709C = hxtmpt.BlankClip(color=$FFFFFF).Subtitle("YUV rec709",Align=5).LetterBox(2,2,2,2)
C = StackHorizontal(NC,RGBC,Y601C,Y709C)
GScript("""
for(i=0,records-1) {
RGB = RT_DBaseGetField(DB,i,0)
YUV601= RT_DBaseGetField(DB,i,1)
YUV709= RT_DBaseGetField(DB,i,2)
Name = RT_DBaseGetField(DB,i,3)
NC = nmtmpt.BlankClip(color=RGB).Subtitle(Name,Align=5).LetterBox(2,2,2,2)
RGBC = hxtmpt.BlankClip(color=$FFFFFF).Subtitle(RT_String("$%0.6X",RGB),Align=5).LetterBox(2,2,2,2)
Y601C = hxtmpt.BlankClip(color=$FFFFFF).Subtitle(RT_String("$%0.6X",YUV601),Align=5).LetterBox(2,2,2,2)
Y709C = hxtmpt.BlankClip(color=$FFFFFF).Subtitle(RT_String("$%0.6X",YUV709),Align=5).LetterBox(2,2,2,2)
TMPC = StackHorizontal(NC,RGBC,Y601C,Y709C)
C=StackVertical(C,TMPC)
}
""")
Return C
}


Frame 0 of 142 frames (2:22 @ 1.0FPS)
https://s20.postimg.cc/jaaahm1z1/Color_Picker_zps59b8db95.jpg (https://postimg.cc/image/g3fqxzhix/)

And here Mp4 version (Rec601, 2MB): LINK REMOVED, See Post #21
Jumps upwards one color at each frame (each second).

EDIT: VLC dont like the MP4, maybe because only 1.0 FPS (and/or 117kb/s).

EDIT:
Edit: Blankclip has the color_yuv parameter but what is it based on? 601 or 709?

I would say that it is not based on anything, its just YUV as RGB is just RGB.
Only during conversion does rec601 or rec709 have any meaning.
EDIT: Had to check, "Color_yuv only valid for YUV color spaces", error if using color_yuv with rgb result in BlankClip.

EDIT: The diligent amongst you might notice two copies of "color_palegoldenrod" in the mp4,
this is a duplicate in colors_rgb.avsi as installed by v2.6RC1, you might like to delete duplicate from your copy,
reported in RC1 devs thread.

EDIT: Changed posts #5 and #7, changed names from eg "global color_skyblue" to global Rec601_skyblue" and "global Rec709_skyblue"
so can use the different colors avsi scripts together without conflict.

EDIT: You can call avsi creation script using "PC601" and "PC709" as Matrix string instead of documented "PC.601" and "PC.709",
the dot would break the global names (dot not valid in a variable name) in result avsi scripts. (valid for both post #4 and #5)

Reel.Deel
22nd September 2015, 14:11
I'm wondering how can I use RGB_2_YUV(post #4 (http://forum.doom9.org/showthread.php?t=171835#post1711028)) to feed the color_yuv argument of Blankclip? Using Hex(RGB_2_YUV($191970, "Rec601")) returns "2ea67a" but it's missing $ and it's also a string.

vivan
22nd September 2015, 14:45
But you just don't need Hex.
BlankClip(pixel_type="YV12", color_yuv=RGB_2_YUV($191970, "Rec601"))
or why even use all of this when you can simply
BlankClip(pixel_type="YV12", color=$191970)

Reel.Deel
22nd September 2015, 14:55
But you just don't need Hex.
BlankClip(pixel_type="YV12", color_yuv=RGB_2_YUV($191970, "Rec601"))
or why even use all of this when you can simply
BlankClip(pixel_type="YV12", color=$191970)

Oops, I forgot about that. Thanks for the reminder. The reason I cannot use color=$191970 directly is because I'll get color differences depending on the matrix used. That's why I'm using RGB_2_YUV.

vivan
22nd September 2015, 15:01
The reason I cannot use color=$191970 directly is because I'll get color differences depending on the matrix used. That's why I'm using RGB_2_YUV.Well, if you need other than Rec601, then you can use
BlankClip(color=$191970).ConvertToYV12(matrix)
(which is exactly what StainlessS does to calculate value in his function)

jmac698
22nd September 2015, 20:10
Yes the hex value you want to use depends on the matrix, a rule of thumb is to use rec709. The differences aren't large (compared to rec601) but noticeable in green objects.

Reel.Deel
23rd September 2015, 01:59
Well, if you need other than Rec601, then you can use
BlankClip(color=$191970).ConvertToYV12(matrix)
(which is exactly what StainlessS does to calculate value in his function)

That works but it's indeed much slower:

~355fps

BlankClip(length=100000, width=1080, height=720, pixel_type="RGB24", color=$191970).ConvertToYV12(matrix="rec709")


~6878620fps :eek:
BlankClip(length=100000, width=1080, height=720, pixel_type="YV12", color_yuv=RGB_2_YUV($191970, "rec709"))

Gavino
23rd September 2015, 08:46
This should be much faster than 355fps:
BlankClip(length=1, width=1080, height=720, pixel_type="RGB24", color=$191970).ConvertToYV12(matrix="rec709")
Loop(100000)

Reel.Deel
23rd September 2015, 14:30
Yup, runs about 2847930fps. I somehow manage to sometimes overlook the obvious things in AviSynth :/.

fvisagie
24th September 2015, 10:56
If you'd like to calculate the RGB <-> YUV conversions directly, these may be of some use.
#-------------------------------------------
# YUVToRGB 1.1.0
# Converts YUV format colour value to equivalent RGB format
#
# Useful when
#
# Working in YUV colourspace but filter requires values to be specified in RGB format
# Working in RGB colourspace but filter results or measurements are presented in YUV format
#
# YUVToRGB(int YUV, string "matrix", string "range")
#
# <YUV> YUV format colour value in either decimal or hexadecimal notation
# <matrix> Colour coefficient matrix to use in conversion - "Rec601" / "Rec709" / "FCC", default "Rec601"
# <range> YUV range: "limited" ([16,235]) or "full" ([0,255]), default "full"
#
# Requirements
#
# YUV value must fall within gamut of valid RGB values, otherwise unexpected or unusable output may result
#
# References
#
# http://avisynth.nl/index.php/Color_conversions
#
# Version history
#
# 1.1.0 Francois Visagie
# Added <range> parameter
# Replaced calculations with Avisynth "programming values" from above reference
# Updated References URL
#
# 1.0.0 Francois Visagie
#

function YUVToRGB(int YUV, string "matrix", string "range") {
range = Default(range, "full")
y = Int(YUV/65536.0)
u = Int((YUV - y*65536)/256.0)
v = YUV - y*65536 - u*256
Eval(ColourCoefficients(matrix))
range == "full" ? Eval("""
r = y + 2.0*(v-128.0)*(1-Kr)
g = y - 2.0*(u-128.0)*(1-Kb)*Kb/Kg - 2.0*(v-128.0)*(1-Kr)*Kr/Kg
b = y + 2.0*(u-128.0)*(1-Kb)
""") : \
range == "limited" ? Eval("""
r = (255.0/219.0)*y + (255.0/112.0)*v*(1-Kr) - (255.0*16.0/219.0 + 255.0*128.0/112.0*(1-Kr))
g = (255.0/219.0)*y - (255.0/112.0)*u*(1-Kb)*Kb/Kg - (255.0/112.0)*v*(1-Kr)*Kr/Kg \
- (255.0*16.0/219.0 - 255.0/112.0*128.0*(1-Kb)*Kb/Kg - 255.0/112.0*128.0*(1-Kr)*Kr/Kg)
b = (255.0/219.0)*y + (255.0/112.0)*u*(1-Kb) - (255.0*16.0/219.0 + 255.0*128.0/112.0*(1-Kb))
""") : \
Assert(false, """YUVToRGB: Invalid 'range' value """"+range+""""""")
r = Min(255, Max(Round(r), 0))
g = Min(255, Max(Round(g), 0))
b = Min(255, Max(Round(b), 0))
return(r*65536 + g*256 + b)
}


#-------------------------------------------
# RGBToYUV 1.1.0
# Converts RGB format colour value to equivalent YUV format
#
# Useful when
#
# Working in RGB colourspace but filter requires values to be specified in YUV format
# Working in YUV colourspace but filter results or measurements are presented in RGB format
#
# RGBToYUV(int RGB, string "matrix", string "range")
#
# <RGB> RGB format colour value in either decimal or hexadecimal notation
# <matrix> Colour coefficient matrix to use in conversion - "Rec601" / "Rec709" / "FCC", default "Rec601"
# <range> YUV range: "limited" ([16,235]) or "full" ([0,255]), default "full"
#
# References
#
# http://avisynth.nl/index.php/Color_conversions
#
# Version history
#
# 1.1.0 Francois Visagie
# Added <range> parameter
# Replaced calculations with Avisynth "programming values" from above reference
# Updated References URL
#
# 1.0.0 Francois Visagie
#

function RGBToYUV(int RGB, string "matrix", string "range") {
range = Default(range, "full")
r = Int(RGB/65536.0)
g = Int((RGB - r*65536)/256.0)
b = RGB - r*65536 - g*256
Eval(ColourCoefficients(matrix))
range == "full" ? Eval("""
y = Kr*r + Kg*g + Kb*b
v = 0.5*r - 0.5*g*Kg/(1-Kr) - 0.5*b*Kb/(1-Kr) + 128.0
u = - 0.5*r*Kr/(1-Kb) - 0.5*g*Kg/(1-Kb) + 0.5*b + 128.0
""") : \
range == "limited" ? Eval("""
y = (Kr*219.0/255.0)*r + (Kg*219.0/255.0)*g + (Kb*219.0/255.0)*b + 16.0
v = 112.0/255.0*r - Kg*112.0/255.0*g/(1-Kr) - Kb*112.0/255.0*b/(1-Kr) + 128.0
u = - Kr*112.0/255.0*r/(1-Kb) - Kg*112.0/255.0*g/(1-Kb) + 112.0/255.0*b + 128.0
""") : \
Assert(false, """RGBToYUV: Invalid 'range' value """"+range+""""""")
y = Min(255, Max(Round(y), 0))
u = Min(255, Max(Round(u), 0))
v = Min(255, Max(Round(v), 0))
return(y*65536 + u*256 + v)
}


#-------------------------------------------
# ColourCoefficients 1.0.0
# Generates specified colour matrix coefficient values
#
# Useful when
#
# Doing YUV<->RGB colourspace calculations or conversions
# Doing colour coefficient calculations or conversions
#
# ColourCoefficients(string "matrix")
#
# <matrix> Colour coefficient matrix which to generate coefficients for - "Rec601" / "Rec709" / "FCC", default "Rec601"
#
# Usage
#
# coeffs = ColourCoefficients("Rec709") # ColourCoefficients returns a multi-statement string with matrix coefficient value assignments
# Eval(coeffs) # This defines Kr containing Red channel coefficient, Kg with Green channel coefficient and Kb for Blue channel
# y = Round(Kr*r + Kg*g + Kb*b)
# ...
#
# References
#
# http://avisynth.org/mediawiki/Color1conversions
#
# Version history
#
# 1.0.0 Francois Visagie
#

function ColourCoefficients(string "matrix") {
matrix = Default(matrix, "Rec601")
matrixnum = (matrix == "Rec601") ? 0 : \
(matrix == "Rec709") ? 1 : \
(matrix == "FCC" ) ? 2 : 3
Assert(matrixnum < 3, """'matrix' value """" + matrix + """" is invalid""")
# Channel coefficients Rec.601 Rec.709 FCC
Kr = Select(matrixnum, 0.299, 0.2125, 0.3 )
Kg = Select(matrixnum, 0.587, 0.7154, 0.59)
Kb = Select(matrixnum, 0.114, 0.0721, 0.11)
return( \
"Kr=" + string(Kr) + "
Kg=" + string(Kg) + "
Kb=" + string(Kb))
}

Reel.Deel
5th October 2015, 22:04
@ StainlessS

How can I add PC.709/601 to the script in post #8. I tried modifying the script but when I tried loading I get this error:
RT_DBaseAppend: Error, DB(0) : Incorrect number of field variables(6) Expecting 4
Took a look at the RT_Stats docs but I'm not sure how to fix it.

StainlessS
5th October 2015, 23:03
Try this (not much testing, but think should be ok).
Have commented where made changes. You just needed to add two more 'i' fields to RT_DBaseAlloc() so s field moved to field 5.


#ColorPickerClip.avs

ColorsRGB = "colors_rgb.avsi"
DB = "Colors.DB"

MakeDB(DB,ColorsRGB)
MakeClip(DB).AssumeFPS(1.0)
Frames = (Height/48-10)+1
Loop(Frames,0,0)
Animate(0,Frames-1,"Spline36Resize",640,480,0,0,-0,480,640,480,0,Height-480,-0,480)
#ConvertToYV12() # To make the mp4
RT_FileDelete(DB) # EDIT: Added
Return last

Function RGB_2_YUV(Int RGB_Color,String Matrix) {
RGB_Color=RT_BitAnd(RGB_Color,$FFFFFF)
BlankClip(Width=16,Height=16,Length=1,Color=RGB_Color)
c=ConvertToYV12(matrix=matrix)
current_frame=0
Y=c.YPlaneMin() U=c.UPlaneMin() V=c.VPlaneMin()
Col = ((Y*256+U)*256)+V
return Col
}

Function MakeDB(String DB,String ColorsRGB) {
myName="MakeDB: "
Assert(Exist(ColorsRGB),RT_String("%s %s Does not exist",myName,ColorsRGB))
Assert(DB!="",RT_String("%s DBase Name Cannot be null",myName))
Exist(DB) ? RT_FileDelete(DB) : NOP
GScript("""
RT_DBaseAlloc(DB,0,"iiiiis64") # Inserted two i fields BEFORE s field, so s field (Name) is now field 5
TEXT=RT_ReadTxtFromFile(ColorsRGB)
LINES=RT_TxtQueryLines(TEXT)
for(i=0,LINES-1) {
S=RT_TxtGetLine(TEXT,i)
S=(S!="")?RT_StrReplaceDeep(RT_StrReplace(S,Chr(9)," ")," "," "):S
While(RT_Ord(S)==32) {S=MidStr(S,2)}
if(RT_Ord(S)!=RT_Ord("#") && RT_Ord(S)!=0) {
nm = RT_FindStr(S,"color_")
Assert(nm!=0,"Cannot find color name")
S = MidStr(S,nm)
nmend = RT_FindStr(S," ")
Assert(nm!=0,"Cannot find color name end")
Name = LeftStr(S,nmend)
S = MidStr(S,nmend)
Hx = RT_FindStr(S,"= $")
Assert(Hx!=0,"Cannot find Dollar")
RGB=RT_HexValue(S,pos=Hx+3)
YUV601=RGB_2_YUV(RGB,"Rec601")
YUV709=RGB_2_YUV(RGB,"Rec709")
YUVPC601=RGB_2_YUV(RGB,"Pc601") # Added
YUVPC709=RGB_2_YUV(RGB,"Pc709") # Added
RT_DBaseAppend(DB,RGB,YUV601,YUV709,YUVPC601,YUVPC709,Name) # Inserted pc yuv before Name string field
}
}
""")
Return 0
}

Function MakeClip(String DB) {
H = 48
records = RT_DBaseRecords(DB)
nmtmpt = BlankClip(length=1,width=316,height=H,pixel_type="RGB32").KillAudio
hxtmpt = BlankClip(length=1,width=108,height=H,pixel_type="RGB32").KillAudio
NC = nmtmpt.BlankClip(color=$FFFFFF).Subtitle("Color Name",Align=5).LetterBox(2,2,2,2)
RGBC = hxtmpt.BlankClip(color=$FFFFFF).Subtitle("RGB",Align=5).LetterBox(2,2,2,2)
Y601C = hxtmpt.BlankClip(color=$FFFFFF).Subtitle("YUV rec601",Align=5).LetterBox(2,2,2,2)
Y709C = hxtmpt.BlankClip(color=$FFFFFF).Subtitle("YUV rec709",Align=5).LetterBox(2,2,2,2)
PCY601C = hxtmpt.BlankClip(color=$FFFFFF).Subtitle("YUV pc601",Align=5).LetterBox(2,2,2,2) # Added
PCY709C = hxtmpt.BlankClip(color=$FFFFFF).Subtitle("YUV pc709",Align=5).LetterBox(2,2,2,2) # Added
C = StackHorizontal(NC,RGBC,Y601C,Y709C,PCY601C,PCY709C) # Added PC clips
GScript("""
for(i=0,records-1) {
RGB = RT_DBaseGetField(DB,i,0)
YUV601 = RT_DBaseGetField(DB,i,1)
YUV709 = RT_DBaseGetField(DB,i,2)
PCYUV601= RT_DBaseGetField(DB,i,3) # Inserted field
PCYUV709= RT_DBaseGetField(DB,i,4) # Inserted field
Name = RT_DBaseGetField(DB,i,5) # Move from field 3 to field 5
NC = nmtmpt.BlankClip(color=RGB).Subtitle(Name,Align=5).LetterBox(2,2,2,2)
RGBC = hxtmpt.BlankClip(color=$FFFFFF).Subtitle(RT_String("$%0.6X",RGB),Align=5).LetterBox(2,2,2,2)
Y601C = hxtmpt.BlankClip(color=$FFFFFF).Subtitle(RT_String("$%0.6X",YUV601),Align=5).LetterBox(2,2,2,2)
Y709C = hxtmpt.BlankClip(color=$FFFFFF).Subtitle(RT_String("$%0.6X",YUV709),Align=5).LetterBox(2,2,2,2)
PCY601C= hxtmpt.BlankClip(color=$FFFFFF).Subtitle(RT_String("$%0.6X",PCYUV601),Align=5).LetterBox(2,2,2,2) # Added
PCY709C= hxtmpt.BlankClip(color=$FFFFFF).Subtitle(RT_String("$%0.6X",PCYUV709),Align=5).LetterBox(2,2,2,2) # Added
TMPC = StackHorizontal(NC,RGBC,Y601C,Y709C,PCY601C,PCY709C) # Added PC clips
C=StackVertical(C,TMPC)
}
""")
Return C
}

Reel.Deel
5th October 2015, 23:23
Try this (not much testing, but think should be ok).
Have commented where made changes. You just needed to add two more 'i' fields to RT_DBaseAlloc() so s field moved to field 5.


Thanks StainlessS! I was close but missed adding the 'i' fileds. One more thing I wanted to ask, is there an easy way to keep the color name row be stationary? Eventually I want to make a gif out of this and add to the the wiki.


#Edit: some colors look similar due to the gif color limitations but overall looks nice :)

https://dl.dropboxusercontent.com/s/akrph1tq1tszmsi/hexyuv.gif

StainlessS
6th October 2015, 00:39
OK, Here you are.


# ColorPicker_Rec_PC.avs

ColorsRGB = "colors_rgb.avsi"
DB = "Colors.DB"

ColorsPerFrame = 10 # Max 16
PageJump = True

MakeClip(DB,ColorsRGB,ColorsPerFrame,PageJump).AssumeFPS(1.0)
#ConvertToYV12() # To make the mp4
RT_FileDelete(DB) # EDIT: Added
Return last

Function RGB_2_YUV(Int RGB_Color,String Matrix) {
RGB_Color=RT_BitAnd(RGB_Color,$FFFFFF)
BlankClip(Width=16,Height=16,Length=1,Color=RGB_Color)
c=ConvertToYV12(matrix=matrix)
current_frame=0
Y=c.YPlaneMin() U=c.UPlaneMin() V=c.VPlaneMin()
Col = ((Y*256+U)*256)+V
return Col
}

Function MakeDB(String DB,String ColorsRGB) {
myName="MakeDB: "
Assert(Exist(ColorsRGB),RT_String("%s %s Does not exist",myName,ColorsRGB))
Assert(DB!="",RT_String("%s DBase Name Cannot be null",myName))
Exist(DB) ? RT_FileDelete(DB) : NOP
GScript("""
RT_DBaseAlloc(DB,0,"iiiiis64") # Inserted two i fields BEFORE s field, so s field (Name) is now field 5
TEXT=RT_ReadTxtFromFile(ColorsRGB)
LINES=RT_TxtQueryLines(TEXT)
for(i=0,LINES-1) {
S=RT_TxtGetLine(TEXT,i)
S=(S!="")?RT_StrReplaceDeep(RT_StrReplace(S,Chr(9)," ")," "," "):S
While(RT_Ord(S)==32) {S=MidStr(S,2)}
if(RT_Ord(S)!=RT_Ord("#") && RT_Ord(S)!=0) {
nm = RT_FindStr(S,"color_")
Assert(nm!=0,"Cannot find color name")
S = MidStr(S,nm)
nmend = RT_FindStr(S," ")
Assert(nm!=0,"Cannot find color name end")
Name = LeftStr(S,nmend)
S = MidStr(S,nmend)
Hx = RT_FindStr(S,"= $")
Assert(Hx!=0,"Cannot find Dollar")
RGB=RT_HexValue(S,pos=Hx+3)
YUV601=RGB_2_YUV(RGB,"Rec601")
YUV709=RGB_2_YUV(RGB,"Rec709")
YUVPC601=RGB_2_YUV(RGB,"Pc601") # Added
YUVPC709=RGB_2_YUV(RGB,"Pc709") # Added
RT_DBaseAppend(DB,RGB,YUV601,YUV709,YUVPC601,YUVPC709,Name) # Inserted pc yuv before Name string field
}
}
""")
Return 0
}

Function MakeClip(String DB,String ColorsRGB,Int "ColorsPerFrame",Bool "PageJump") {
myName="MakeClip: "
ColorsPerFrame = Default(ColorsPerFrame,10)
PageJump = Default(PageJump,False)
Assert(ColorsPerFrame>=1&&ColorsPerFrame<=16,RT_String("%s 1 <= ColorsPerFrame <=16 (%d)",myName,ColorsPerFrame))
H = 48
MakeDB(DB,ColorsRGB) records = RT_DBaseRecords(DB)
nmtmpt = BlankClip(length=1,width=316,height=H,pixel_type="RGB32").KillAudio
hxtmpt = BlankClip(length=1,width=108,height=H,pixel_type="RGB32").KillAudio
NC = nmtmpt.BlankClip(color=$FFFFFF).Subtitle("Color Name",Align=5).LetterBox(2,2,2,2)
RGBC = hxtmpt.BlankClip(color=$FFFFFF).Subtitle("RGB",Align=5).LetterBox(2,2,2,2)
Y601C = hxtmpt.BlankClip(color=$FFFFFF).Subtitle("YUV rec601",Align=5).LetterBox(2,2,2,2)
Y709C = hxtmpt.BlankClip(color=$FFFFFF).Subtitle("YUV rec709",Align=5).LetterBox(2,2,2,2)
PCY601C = hxtmpt.BlankClip(color=$FFFFFF).Subtitle("YUV pc601",Align=5).LetterBox(2,2,2,2) # Added
PCY709C = hxtmpt.BlankClip(color=$FFFFFF).Subtitle("YUV pc709",Align=5).LetterBox(2,2,2,2) # Added
HEAD = StackHorizontal(NC,RGBC,Y601C,Y709C,PCY601C,PCY709C) # Added PC clips
C = 0
GScript("""
for(i=0,records-1) {
RGB = RT_DBaseGetField(DB,i,0)
YUV601 = RT_DBaseGetField(DB,i,1)
YUV709 = RT_DBaseGetField(DB,i,2)
PCYUV601= RT_DBaseGetField(DB,i,3) # Inserted field
PCYUV709= RT_DBaseGetField(DB,i,4) # Inserted field
Name = RT_DBaseGetField(DB,i,5) # Move from field 3 to field 5
NC = nmtmpt.BlankClip(color=RGB).Subtitle(Name,Align=5).LetterBox(2,2,2,2)
RGBC = hxtmpt.BlankClip(color=$FFFFFF).Subtitle(RT_String("$%0.6X",RGB),Align=5).LetterBox(2,2,2,2)
Y601C = hxtmpt.BlankClip(color=$FFFFFF).Subtitle(RT_String("$%0.6X",YUV601),Align=5).LetterBox(2,2,2,2)
Y709C = hxtmpt.BlankClip(color=$FFFFFF).Subtitle(RT_String("$%0.6X",YUV709),Align=5).LetterBox(2,2,2,2)
PCY601C= hxtmpt.BlankClip(color=$FFFFFF).Subtitle(RT_String("$%0.6X",PCYUV601),Align=5).LetterBox(2,2,2,2) # Added
PCY709C= hxtmpt.BlankClip(color=$FFFFFF).Subtitle(RT_String("$%0.6X",PCYUV709),Align=5).LetterBox(2,2,2,2) # Added
TMPC = StackHorizontal(NC,RGBC,Y601C,Y709C,PCY601C,PCY709C) # Added PC clips
C = (C.IsClip()) ? StackVertical(C,TMPC) : TMPC
}
OUT_H=H*ColorsPerFrame OUT_W=HEAD.Width Bot = 0
if(PageJump) {
if(C.Height % OUT_H != 0) {Bot = C.Crop(0,C.Height-OUT_H,-0,-0)}
C = C.Crop(0,0,-0,C.Height / OUT_H * OUT_H)
Frames = (C.Height/OUT_H)
} else {Frames = (C.Height/H-ColorsPerFrame) + 1 }
C.Loop(Frames,0,0)
Animate(0,Frames-1,"Spline36Resize",OUT_W,OUT_H,0,0,-0,OUT_H, OUT_W,OUT_H,0,Height-OUT_H,-0,OUT_H)
Last = (Bot.IsClip()) ? Last++Bot : Last
HEAD=HEAD.AddBorders(0,0,0,8) # With spacer between HEAD and Colors
StackVertical(HEAD,Last)
""")
Return Last
}


MP4 Here (5MB):- http://www.mediafire.com/download/572ojetpwqbkl0x/ColorPicker_Rec_PC.mp4
EDIT: VLC (old versions at least) still dont like the MP4 (low Bitrate/FrameRate).

EDIT: I kept it full size, was resizing narrower despite extra PC entries, number of colors per frame optional.

StainlessS
6th October 2015, 02:59
Previous post #21 updated.
Added PageJump.

Reel.Deel
6th October 2015, 03:35
Thanks, the ColorsPerFrame and PageJump parameters are a nice addition. The only thing lacking now it's being able to output values to a text file, but that's definitely pushing my luck :p.

Here's with ColorsPerFrame=10, PageJump=True:
https://dl.dropboxusercontent.com/s/akrph1tq1tszmsi/hexyuv.gif


ColorsPerFrame=1, PageJump=False:
https://dl.dropboxusercontent.com/s/ahtoxo2jncdjoh0/hexyuv2.gif

StainlessS
6th October 2015, 03:42
RD, will output of post #5 not do, all you need to is change matrix to eg Matrix = "PC601" # "Rec601", "Rec709", "PC601", "PC709"

and you get this

colors_yuv_PC601.avsi

# list of common colors (yuv values [Matrix='PC601'])

# source:
# http://en.wikipedia.org/wiki/List_of_colors
# http://en.wikipedia.org/wiki/X11_color_names
# http://www.cryer.co.uk/resources/javascript/html2.htm

global PC601_aliceblue = $F6857B # RGB = $F0F8FF
global PC601_antiquewhite = $ED7489 # RGB = $FAEBD7
global PC601_aqua = $B3AB01 # RGB = $00FFFF
global PC601_aquamarine = $D48044 # RGB = $7FFFD4
global PC601_azure = $FB8379 # RGB = $F0FFFF
global PC601_beige = $F27482 # RGB = $F5F5DC
global PC601_bisque = $E86C90 # RGB = $FFE4C4
global PC601_black = $008080 # RGB = $000000
global PC601_blanchedalmond = $EE6E8C # RGB = $FFEBCD
global PC601_blue = $1DFF6B # RGB = $0000FF
global PC601_blueviolet = $5CCBA1 # RGB = $8A2BE2
global PC601_brown = $4F6BBD # RGB = $A52A2A
global PC601_burlywood = $BE6197 # RGB = $DEB887
global PC601_cadetblue = $8B8C60 # RGB = $5F9EA0
global PC601_chartreuse = $BC1755 # RGB = $7FFF00
global PC601_chocolate = $8049BA # RGB = $D2691E
global PC601_coral = $A053C4 # RGB = $FF7F50
global PC601_cornflowerblue = $90B460 # RGB = $6495ED
global PC601_cornsilk = $F77186 # RGB = $FFF8DC
global PC601_crimson = $5472E0 # RGB = $DC143C
global PC601_cyan = $B3AB01 # RGB = $00FFFF
global PC601_darkblue = $10C575 # RGB = $00008B
global PC601_darkcyan = $61973B # RGB = $008B8B
global PC601_darkgoldenrod = $873AA3 # RGB = $B8860B
global PC601_darkgray = $A98080 # RGB = $A9A9A9
global PC601_darkgreen = $3B5F56 # RGB = $006400
global PC601_darkkhaki = $B05989 # RGB = $BDB76B
global PC601_darkmagenta = $39AEBA # RGB = $8B008B
global PC601_darkoliveGreen = $5E667A # RGB = $556B2F
global PC601_darkorange = $9E27C5 # RGB = $FF8C00
global PC601_darkorchid = $62BBA7 # RGB = $9932CC
global PC601_darkred = $2A69C5 # RGB = $8B0000
global PC601_darksalmon = $AC64AC # RGB = $E9967A
global PC601_darkseaGreen = $A9716D # RGB = $8FBC8F
global PC601_darkslateBlue = $49A57F # RGB = $483D8B
global PC601_darkslateGray = $458570 # RGB = $2F4F4F
global PC601_darkturquoise = $91A419 # RGB = $00CED1
global PC601_darkviolet = $44D0B9 # RGB = $9400D3
global PC601_deeppink = $6998EB # RGB = $FF1493
global PC601_deepskyblue = $8DC01C # RGB = $00BFFF
global PC601_dimgray = $698080 # RGB = $696969
global PC601_dodgerblue = $7BCA3E # RGB = $1E90FF
global PC601_firebrick = $4D68C8 # RGB = $B22222
global PC601_floralwhite = $FA7A83 # RGB = $FFFAF0
global PC601_forestgreen = $605D54 # RGB = $228B22
global PC601_fuchsia = $69D4EA # RGB = $FF00FF
global PC601_gainsboro = $DC8080 # RGB = $DCDCDC
global PC601_ghostwhite = $F9847F # RGB = $F8F8FF
global PC601_gold = $CA0EA5 # RGB = $FFD700
global PC601_goldenrod = $A635A5 # RGB = $DAA520
global PC601_gray = $808080 # RGB = $808080
global PC601_green = $4B564B # RGB = $008000
global PC601_greenyellow = $CF2668 # RGB = $ADFF2F
global PC601_honeydew = $F97B7A # RGB = $F0FFF0
global PC601_hotpink = $9E8CC5 # RGB = $FF69B4
global PC601_indianred = $7E6DB8 # RGB = $CD5C5C
global PC601_indigo = $25B49B # RGB = $4B0082
global PC601_ivory = $FD7981 # RGB = $FFFFF0
global PC601_khaki = $DF528C # RGB = $F0E68C
global PC601_lavender = $E88A7E # RGB = $E6E6FA
global PC601_lavenderblush = $F58087 # RGB = $FFF0F5
global PC601_lawngreen = $B91855 # RGB = $7CFC00
global PC601_lemonchiffon = $F66986 # RGB = $FFFACD
global PC601_lightblue = $CD8E69 # RGB = $ADD8E6
global PC601_lightcoral = $A16DB8 # RGB = $F08080
global PC601_lightcyan = $F68571 # RGB = $E0FFFF
global PC601_lightgoldenrodyellow = $F56C83 # RGB = $FAFAD2
global PC601_lightgreen = $C76159 # RGB = $90EE90
global PC601_lightgrey = $D38080 # RGB = $D3D3D3
global PC601_lightpink = $CD79A3 # RGB = $FFB6C1
global PC601_lightsalmon = $B85DB2 # RGB = $FFA07A
global PC601_lightseagreen = $859538 # RGB = $20B2AA
global PC601_lightskyblue = $BEA259 # RGB = $87CEFA
global PC601_lightslategray = $858B76 # RGB = $778899
global PC601_lightsteelblue = $C19074 # RGB = $B0C4DE
global PC601_lightyellow = $FB7183 # RGB = $FFFFE0
global PC601_lime = $962C16 # RGB = $00FF00
global PC601_limegreen = $8D4D3F # RGB = $32CD32
global PC601_linen = $F27986 # RGB = $FAF0E6
global PC601_magenta = $69D4EA # RGB = $FF00FF
global PC601_maroon = $266AC0 # RGB = $800000
global PC601_mediumaquamarine = $AA8050 # RGB = $66CDAA
global PC601_mediumblue = $17E66F # RGB = $0000CD
global PC601_mediumorchid = $82AEA8 # RGB = $BA55D3
global PC601_mediumpurple = $87AF89 # RGB = $9370DB
global PC601_mediumseagreen = $88734A # RGB = $3CB371
global PC601_mediumslatenlue = $7DC07F # RGB = $7B68EE
global PC601_mediumspringgreen = $A47A0B # RGB = $00FA9A
global PC601_mediumturquoise = $A7953C # RGB = $48D1CC
global PC601_mediumvioletred = $579AD0 # RGB = $C71585
global PC601_midnightblue = $23AB79 # RGB = $191970
global PC601_mintcream = $FB7F7B # RGB = $F5FFFA
global PC601_mistyrose = $EC7A8E # RGB = $FFE4E1
global PC601_moccasin = $E76491 # RGB = $FFE4B5
global PC601_navajowhite = $E26294 # RGB = $FFDEAD
global PC601_navy = $0FC076 # RGB = $000080
global PC601_oldlace = $F67785 # RGB = $FDF5E6
global PC601_olive = $71408A # RGB = $808000
global PC601_olivedrab = $775177 # RGB = $6B8E23
global PC601_orange = $AD1FBA # RGB = $FFA500
global PC601_orangered = $753EE2 # RGB = $FF4500
global PC601_orchid = $9BA1AD # RGB = $DA70D6
global PC601_palegoldenrod = $E36088 # RGB = $EEE8AA
global PC601_palegreen = $D25F57 # RGB = $98FB98
global PC601_paleturquoise = $DB8B61 # RGB = $AFEEEE
global PC601_palevioletred = $947FB2 # RGB = $DB7093
global PC601_papayawhip = $F1708A # RGB = $FFEFD5
global PC601_peachpuff = $E16995 # RGB = $FFDAB9
global PC601_peru = $9351AA # RGB = $CD853F
global PC601_pink = $D47B9E # RGB = $FFC0CB
global PC601_plum = $B99499 # RGB = $DDA0DD
global PC601_powderblue = $D28B68 # RGB = $B0E0E6
global PC601_purple = $35AAB5 # RGB = $800080
global PC601_red = $4C55FF # RGB = $FF0000
global PC601_rosybrown = $9C7896 # RGB = $BC8F8F
global PC601_royalblue = $6BC262 # RGB = $4169E1
global PC601_saddlebrown = $545BA7 # RGB = $8B4513
global PC601_salmon = $A365BE # RGB = $FA8072
global PC601_sandybrown = $B451AD # RGB = $F4A460
global PC601_seagreen = $697656 # RGB = $2E8B57
global PC601_seashell = $F77B86 # RGB = $FFF5EE
global PC601_sienna = $6560AA # RGB = $A0522D
global PC601_silver = $C08080 # RGB = $C0C0C0
global PC601_skyblue = $BC9A5A # RGB = $87CEEB
global PC601_slateblue = $6CB77F # RGB = $6A5ACD
global PC601_slategray = $7D8B77 # RGB = $708090
global PC601_snow = $FC7F83 # RGB = $FFFAFA
global PC601_springgreen = $A46B0B # RGB = $00FF7F
global PC601_steelblue = $76A35E # RGB = $4682B4
global PC601_tan = $B86792 # RGB = $D2B48C
global PC601_teal = $5A9640 # RGB = $008080
global PC601_thistle = $C9888A # RGB = $D8BFD8
global PC601_tomato = $8E58D0 # RGB = $FF6347
global PC601_turquoise = $AE9332 # RGB = $40E0D0
global PC601_violet = $AFA4AD # RGB = $EE82EE
global PC601_wheat = $E0678F # RGB = $F5DEB3
global PC601_white = $FF8080 # RGB = $FFFFFF
global PC601_whitesmoke = $F58080 # RGB = $F5F5F5
global PC601_yellow = $E20195 # RGB = $FFFF00
global PC601_yellowgreen = $AC3B73 # RGB = $9ACD32

#Gray colors
global PC601_gray10 = $198080 # RGB = $191919
global PC601_gray20 = $328080 # RGB = $323232
global PC601_gray30 = $4B8080 # RGB = $4B4B4B
global PC601_gray40 = $658080 # RGB = $656565
global PC601_gray50 = $7F8080 # RGB = $7F7F7F
global PC601_gray60 = $988080 # RGB = $989898
global PC601_gray70 = $B18080 # RGB = $B1B1B1
global PC601_gray80 = $CA8080 # RGB = $CACACA
global PC601_gray90 = $E48080 # RGB = $E4E4E4


Or do you want RGB + the 4 YUV colors in text.

Reel.Deel
6th October 2015, 03:47
Oops I forgot about that, it's been a while. RGB + 4 YUV colors in text is desirable (might make it easier to add to the wiki) but I think post #5 will suffice.

StainlessS
6th October 2015, 05:17
OK, here you go.

# ColorsTextMaker_Rec_PC.avs

ColorsRGB="colors_rgb.avsi"
ColorsYUV="ColorsYUV.Txt"
LineSep = False
RightBar = False
Write_Colors_Text(ColorsRGB,ColorsYUV,LineSep,RightBar)
#
Txt = RT_ReadTxtFromFile(ColorsYUV)
Lines = RT_TxtQueryLines(Txt)
# config
DELAY = 10
SCROLL= 0 # 0 = Up : 1 = Down
COLOR = 0 # 0 (Default=White) or 1 to 32 : 17=BLACK(not much use)->32 Lighter shades of Gray.
#
Assert(COLOR>=0&&COLOR<=32,RT_String("BAD COLOR selected 0 -> 32 only (%d)",Color))
Fmt = (COLOR==0) ? "" : "\a" + MidStr("0123456789ABCDEFGHIJKLMNOPQRSTUV",COLOR,1)
Fmt = Fmt + "%s"
Width=1024 Height=768 BlankClip(Width=Width,Height=Height,Length=Delay+Lines*20+Height)
CMD_0 = """RT_Subtitle(Fmt,Txt,align=7,y=height+DELAY-current_frame,expx=true,expy=true)"""
CMD_1 = """RT_Subtitle(Fmt,Txt,align=7,y=-(Lines*20+DELAY) + current_frame,expx=true,expy=true)"""
CMD_2 = """RT_Subtitle("BAD SCROLL COMMAND (0->1)")"""
CMD = (SCROLL<0 || SCROLL>1) ? CMD_2 : Select(Scroll,CMD_0,CMD_1,CMD_2)
Return ScriptClip(CMD)

Function Write_Colors_Text(String "ColorsRGB",String "ColorsYUV",Bool "LineSep",Bool "RightBar") {
ColorsRGB = Default(ColorsRGB,"colors_rgb.avsi") ColorsYUV = Default(ColorsYUV,"ColorsYUV.Txt")
LineSep=Default(LineSep,False) RightBar=Default(RightBar,False)
Assert(Exist(ColorsRGB),ColorsRGB+" Does not exist") Exist(ColorsYUV) ? RT_FileDelete(ColorsYUV) : NOP
DB = RT_LocaltimeString(File=True) + ".DB" MakeDB(DB,ColorsRGB)
GSCript("""
Records=RT_DBaseRecords(DB) NAMEPAD=28 HEXPAD=11 USCOREPAD=NAMEPAD+5*(HEXPAD+1) RS=RightBar?"|":""
USCORE=RT_StrPad("",USCOREPAD,"_") RT_WriteFile(ColorsYUV,"%s",USCORE,Append=True)
Name = RT_StrPad("ColorName" ,NAMEPAD) RGB = TextCenterPad("RGB" ,HEXPAD)
R601 = TextCenterPad("Rec601",HEXPAD) R709 = TextCenterPad("Rec709",HEXPAD)
P601 = TextCenterPad("Pc601" ,HEXPAD) P709 = TextCenterPad("Pc709" ,HEXPAD)
RT_WriteFile(ColorsYUV,"%s|%s|%s|%s|%s|%s%s",Name,RGB,R601,R709,P601,P709,RS,Append=True)
RT_WriteFile(ColorsYUV,"%s%s",USCORE,RS,Append=True)
for(i=0,Records-1) {
Name = RT_StrPad(RT_DBaseGetField(DB,i,5),NAMEPAD)
RGB = TextCenterPad(RT_String("$%06X",RT_DBaseGetField(DB,i,0)),HEXPAD)
R601 = TextCenterPad(RT_String("$%06X",RT_DBaseGetField(DB,i,1)),HEXPAD)
R709 = TextCenterPad(RT_String("$%06X",RT_DBaseGetField(DB,i,2)),HEXPAD)
P601 = TextCenterPad(RT_String("$%06X",RT_DBaseGetField(DB,i,3)),HEXPAD)
P709 = TextCenterPad(RT_String("$%06X",RT_DBaseGetField(DB,i,4)),HEXPAD)
RT_WriteFile(ColorsYUV,"%s|%s|%s|%s|%s|%s%s",Name,RGB,R601,R709,P601,P709,RS,Append=True)
(LineSep||i==Records-1) ? RT_WriteFile(ColorsYUV,"%s%s",USCORE,RS,Append=True) : NOP
}
""")
RT_FileDelete(DB)
}

Function TextCenterPad(String S,int PadLen) {S=RT_StrPad("",(PadLen-StrLen(S))/2) + S Return RT_StrPad(S,PadLen)}

Function RGB_2_YUV(Int RGB_Color,String Matrix) {
RGB_Color=RT_BitAnd(RGB_Color,$FFFFFF) BlankClip(Width=16,Height=16,Length=1,Color=RGB_Color) c=ConvertToYV12(matrix=matrix)
current_frame=0 Y=c.YPlaneMin() U=c.UPlaneMin() V=c.VPlaneMin()
Return ((Y*256+U)*256)+V
}

Function MakeDB(String DB,String ColorsRGB) {
myName="MakeDB: " Assert(Exist(ColorsRGB),RT_String("%s %s Does not exist",myName,ColorsRGB))
Assert(DB!="",RT_String("%s DBase Name Cannot be null",myName)) Exist(DB) ? RT_FileDelete(DB) : NOP
GScript("""
RT_DBaseAlloc(DB,0,"iiiiis64") # Inserted two i fields BEFORE s field, so s field (Name) is now field 5
TEXT=RT_ReadTxtFromFile(ColorsRGB) LINES=RT_TxtQueryLines(TEXT)
for(i=0,LINES-1) {
S=RT_TxtGetLine(TEXT,i) S=(S!="")?RT_StrReplaceDeep(RT_StrReplace(S,Chr(9)," ")," "," "):S
While(RT_Ord(S)==32) {S=MidStr(S,2)}
if(RT_Ord(S)!=RT_Ord("#") && RT_Ord(S)!=0) {
nm = RT_FindStr(S,"color_")
Assert(nm!=0,"Cannot find color name")
S = MidStr(S,nm)
nmend = RT_FindStr(S," ")
Assert(nm!=0,"Cannot find color name end")
Name = LeftStr(S,nmend)
S = MidStr(S,nmend)
Hx = RT_FindStr(S,"= $")
Assert(Hx!=0,"Cannot find Dollar")
RGB=RT_HexValue(S,pos=Hx+3)
YUV601=RGB_2_YUV(RGB,"Rec601")
YUV709=RGB_2_YUV(RGB,"Rec709")
YUVPC601=RGB_2_YUV(RGB,"Pc601") # Added
YUVPC709=RGB_2_YUV(RGB,"Pc709") # Added
RT_DBaseAppend(DB,RGB,YUV601,YUV709,YUVPC601,YUVPC709,Name) # Inserted pc yuv before Name string field
}
}
""")
Return 0
}


EDIT: Note, post #21, ColorsPerFrame=1, PageJump=False, should have at least ColorsPerFrame=2 to demo that
as with 1 colour PageJump=False or PageJump=True == same result. (I'm sure that you already realise that).

EDIT: I dont mind you 'pushing your luck' for the Wiki, I dont like doing docs of any kind but dont mind a bit of scripting.

Reel.Deel
7th October 2015, 01:42
Excellent, this should make adding it to the wiki much easier. As always I really appreciate your help. :thanks:

For someone who doesn't like writing docs some of your plugins are definitely much better documented than some other AviSynth plugins. Either they dislike writing docs more than you or you're good at doing something you don't like :D.

raffriff42
7th October 2015, 13:16
See also, my old page that used Rec601 conversions...
avisynth.nl/Color_presets&oldid=3718 (http://avisynth.nl/index.php?title=Color_presets&oldid=3718)

StainlessS
8th October 2015, 13:40
Raff, Nice touch being able to sort colors in your Wiki Link, lovely job :)

EDIT: RD, docs are a necessary evil that I accept have to be done by the author (or someone else that knows how item works).
I cannot understand how some authors can give as only docs a link to forum thread, where you have to read the entire thread
to extract necessary info (same for each and every user).
Having done (perhaps flimsy) docs, that's where my job ends, guides etc I'd prefer to be done by someone else.

Don't think I've ever met a developer that likes doing docs (they, like I, think their time could be better spent).

raffriff42
8th October 2015, 15:44
Write the docs first, so you get your intended functionality clear in your mind before you start, and a gauge of of your progress as you tick off each feature as it's implemented. That's what an old-time IBM mainframe guy told me. Of course, I rarely do it. :)

StainlessS
8th October 2015, 20:56
Raff, I admire your perspective (EDIT or rather what your perspective should be), but whatever I do, is never done by design, more whatever kind of occurs as and when it pops into my head.
My stuff kind if 'grows', as needed, and I bet given a spec mine is done tested and working, well before the other guys have finished their
flow charts. everyone to their own, I guess.

EDIT: You can design to your hearts content, only when you actually start coding do you find the floors in design,
software engineering is a little bit of a fallacy, and does little more than delay delivery.
(At least on a small project, I guess on large projects there is more need to clarify what one [in this case somewhat more than one] is trying to do).

EDIT: A few years back, local government had some new computer system installed, and just from the 'effects' of said
system, I informed an official of a problem within their new system which would incur costs in minimum region of about
6 Million UK pounds over about 4 or 5 years. (could have gone un-detected for some years longer than that).
That is one of the problems of having software where they 'tick off the boxes' without anybody knowing or understanding
what they are doing, and the recipients of said software trusting too much in what it can do.
(Problem due to Leap year having one more day that non leap year, effect ... very expensive).
Whether done by a single or multiple persons, each project should have a single person that understands the entire
project and is not just interested in ticking boxes. They should also take blame for above like problems and not
hide behind agreed specs where the problem arises from problems that should have been picked up by the developers,
customer can be forgiven for not anticipating leap year, developer cannot (in my opinion).
EDIT: Actually problem was in change of the number of days in a year, so problem arose both in a leap year, and also in the year following a leap year.

StainlessS
7th July 2020, 12:55
Update to several scripts previously posted, Added Rec2020


# ColorPicker.avs # Create equivalent YUV version of Colors_rgb.avsi script
/* Example output file:- "colors_yuv_Rec2020.avsi",
# list of common colors (yuv values [Matrix='Rec2020'])

# source:
# http://en.wikipedia.org/wiki/List_of_colors
# http://en.wikipedia.org/wiki/X11_color_names
# http://www.cryer.co.uk/resources/javascript/html2.htm

global Rec2020_aliceblue = $E4847C # RGB = $F0F8FF
global Rec2020_antiquewhite = $DC7587 # RGB = $FAEBD7
global Rec2020_aqua = $B19F10 # RGB = $00FFFF
global Rec2020_aquamarine = $CC7D49 # RGB = $7FFFD4
global Rec2020_azure = $E88279 # RGB = $F0FFFF
*/

#Matrix = "Rec601" # "Rec601", "Rec709", "PC601", "PC709", "Rec2020"
#Matrix = "Rec709"
#Matrix = "PC601"
#Matrix = "PC709"
Matrix = "Rec2020"

ColorsRGB = "colors_rgb.avsi"
ColorsYUV = "colors_yuv_"+Matrix+".avsi"

Assert(Exist(ColorsRGB),ColorsRGB+" Does not exist")

Exist(ColorsYUV) ? RT_FileDelete(ColorsYUV) : NOP

PAD = 40
INSERT=RT_String("(yuv values [Matrix='%s'])",Matrix)

#GSCript("""
TEXT=RT_ReadTxtFromFile(ColorsRGB)
LINES=RT_TxtQueryLines(TEXT)

for(i=0,LINES-1) {
S=RT_TxtGetLine(TEXT,i)
S=(S!="")?RT_StrReplaceDeep(RT_StrReplace(S,Chr(9)," ")," "," "):S
S=(S!="")?RT_StrReplace(S,"(rgb values)",INSERT):S
While(RT_Ord(S)==32) {S=MidStr(S,2)}
if(RT_Ord(S)==RT_Ord("#") || RT_Ord(S)==0) {
S=(RT_Ord(S)==0)?Chr(10):S
RT_WriteFile(ColorsYUV,"%s",S,Append=True)
} Else {
Hx = RT_FindStr(S,"= $")
Assert(Hx!=0,"Cannot find Dollar")
SOUT=RT_StrReplace(LeftStr(S,Hx-1),"color_",Matrix+"_",sig=false)
SOUT=RT_StrPad(SOUT,40)
RGB=RT_HexValue(S,pos=Hx+3)
YUV=RGB_2_YUV(RGB,Matrix)
RT_Writefile(ColorsYUV,"%s= $%0.6X # RGB = $%0.6X",SOUT,YUV,RGB,Append=True)
}
}
#""")
return MessageClip("Done")


Function RGB_2_YUV(Int RGB_Color,String Matrix) {
c=BlankClip(Width=8,Height=8,Length=1,Color=RGB_Color).ConvertToYV12(matrix=matrix)
current_frame=0 Y=c.YPlaneMin() U=c.UPlaneMin() V=c.VPlaneMin()
return (Y*256+U)*256+V
}



# ColorsTextMaker_Rec_PC.avs # Added rec2020, GSCript(""" ... """) commented out, add back for non Avs+

/* Example Output file "ColorsYUV.Txt"
____________________________________________________________________________________________________
ColorName | RGB | Rec601 | Rec709 | Pc601 | Pc709 | Rec2020 |
____________________________________________________________________________________________________|
color_aliceblue | $F0F8FF | $E4847C | $E4847C | $F6857B | $F7847C | $E4847C |
____________________________________________________________________________________________________|
color_antiquewhite | $FAEBD7 | $DC7588 | $DB7687 | $ED7489 | $ED7488 | $DC7587 |
____________________________________________________________________________________________________|
color_aqua | $00FFFF | $AAA610 | $BC9A10 | $B3AB01 | $C99D01 | $B19F10 |
____________________________________________________________________________________________________|
color_aquamarine | $7FFFD4 | $C6804B | $D17A4A | $D48044 | $E17942 | $CC7D49 |
____________________________________________________________________________________________________|
*/


ColorsRGB="colors_rgb.avsi"
ColorsYUV="ColorsYUV.Txt"
LineSep = true
RightBar = True
Write_Colors_Text(ColorsRGB,ColorsYUV,LineSep,RightBar)
#
Txt = RT_ReadTxtFromFile(ColorsYUV)
Lines = RT_TxtQueryLines(Txt)
# config
DELAY = 10
SCROLL= 0 # 0 = Up : 1 = Down
COLOR = 6 # 0 (Default=White) or 1 to 32 : 17=BLACK(not much use)->32 Lighter shades of Gray.
#
Assert(COLOR>=0&&COLOR<=32,RT_String("BAD COLOR selected 0 -> 32 only (%d)",Color))
Fmt = (COLOR==0) ? "" : "\a" + MidStr("0123456789ABCDEFGHIJKLMNOPQRSTUV",COLOR,1)
Fmt = Fmt + "%s"
Width=1024 Height=768 BlankClip(Width=Width,Height=Height,Length=Delay+Lines*20+Height)
CMD_0 = """RT_Subtitle(Fmt,Txt,align=7,y=height+DELAY-current_frame,expx=true,expy=true)"""
CMD_1 = """RT_Subtitle(Fmt,Txt,align=7,y=-(Lines*20+DELAY) + current_frame,expx=true,expy=true)"""
CMD_2 = """RT_Subtitle("BAD SCROLL COMMAND (0->1)")"""
CMD = (SCROLL<0 || SCROLL>1) ? CMD_2 : Select(Scroll,CMD_0,CMD_1,CMD_2)
Return ScriptClip(CMD)

Function Write_Colors_Text(String "ColorsRGB",String "ColorsYUV",Bool "LineSep",Bool "RightBar") {
ColorsRGB = Default(ColorsRGB,"colors_rgb.avsi") ColorsYUV = Default(ColorsYUV,"ColorsYUV.Txt")
LineSep=Default(LineSep,False) RightBar=Default(RightBar,False)
Assert(Exist(ColorsRGB),ColorsRGB+" Does not exist") Exist(ColorsYUV) ? RT_FileDelete(ColorsYUV) : NOP
DB = RT_LocaltimeString(File=True) + ".DB" MakeDB(DB,ColorsRGB)
# GSCript("""
Records=RT_DBaseRecords(DB) NAMEPAD=28 HEXPAD=11 USCOREPAD=NAMEPAD+6*(HEXPAD+1) RS=RightBar?"|":""
USCORE=RT_StrPad("",USCOREPAD,"_") RT_WriteFile(ColorsYUV,"%s",USCORE,Append=True)
Name = RT_StrPad("ColorName" ,NAMEPAD) RGB = TextCenterPad("RGB" ,HEXPAD)
R601 = TextCenterPad("Rec601",HEXPAD) R709 = TextCenterPad("Rec709",HEXPAD)
P601 = TextCenterPad("Pc601" ,HEXPAD) P709 = TextCenterPad("Pc709" ,HEXPAD)
R2020 = TextCenterPad("Rec2020" ,HEXPAD)
RT_WriteFile(ColorsYUV,"%s|%s|%s|%s|%s|%s|%s%s",Name,RGB,R601,R709,P601,P709,R2020,RS,Append=True)
RT_WriteFile(ColorsYUV,"%s%s",USCORE,RS,Append=True)
for(i=0,Records-1) {
Name = RT_StrPad(RT_DBaseGetField(DB,i,6),NAMEPAD)
RGB = TextCenterPad(RT_String("$%06X",RT_DBaseGetField(DB,i,0)),HEXPAD)
R601 = TextCenterPad(RT_String("$%06X",RT_DBaseGetField(DB,i,1)),HEXPAD)
R709 = TextCenterPad(RT_String("$%06X",RT_DBaseGetField(DB,i,2)),HEXPAD)
P601 = TextCenterPad(RT_String("$%06X",RT_DBaseGetField(DB,i,3)),HEXPAD)
P709 = TextCenterPad(RT_String("$%06X",RT_DBaseGetField(DB,i,4)),HEXPAD)
R2020 = TextCenterPad(RT_String("$%06X",RT_DBaseGetField(DB,i,5)),HEXPAD)
RT_WriteFile(ColorsYUV,"%s|%s|%s|%s|%s|%s|%s%s",Name,RGB,R601,R709,P601,P709,R2020,RS,Append=True)
(LineSep||i==Records-1) ? RT_WriteFile(ColorsYUV,"%s%s",USCORE,RS,Append=True) : NOP
}
# """)
RT_FileDelete(DB)
}

Function TextCenterPad(String S,int PadLen) {S=RT_StrPad("",(PadLen-StrLen(S))/2) + S Return RT_StrPad(S,PadLen)}

Function RGB_2_YUV(Int RGB_Color,String Matrix) {
c=BlankClip(Width=8,Height=8,Length=1,Color=RGB_Color).ConvertToYV12(matrix=matrix)
current_frame=0 Y=c.YPlaneMin() U=c.UPlaneMin() V=c.VPlaneMin()
return (Y*256+U)*256+V
}

Function MakeDB(String DB,String ColorsRGB) {
myName="MakeDB: " Assert(Exist(ColorsRGB),RT_String("%s %s Does not exist",myName,ColorsRGB))
Assert(DB!="",RT_String("%s DBase Name Cannot be null",myName)) Exist(DB) ? RT_FileDelete(DB) : NOP
# GScript("""
RT_DBaseAlloc(DB,0,"iiiiiis64") # Inserted three i fields BEFORE s field, so s field (Name) is now field 6
TEXT=RT_ReadTxtFromFile(ColorsRGB) LINES=RT_TxtQueryLines(TEXT)
for(i=0,LINES-1) {
S=RT_TxtGetLine(TEXT,i) S=(S!="")?RT_StrReplaceDeep(RT_StrReplace(S,Chr(9)," ")," "," "):S
While(RT_Ord(S)==32) {S=MidStr(S,2)}
if(RT_Ord(S)!=RT_Ord("#") && RT_Ord(S)!=0) {
nm = RT_FindStr(S,"color_")
Assert(nm!=0,"Cannot find color name")
S = MidStr(S,nm)
nmend = RT_FindStr(S," ")
Assert(nm!=0,"Cannot find color name end")
Name = LeftStr(S,nmend)
S = MidStr(S,nmend)
Hx = RT_FindStr(S,"= $")
Assert(Hx!=0,"Cannot find Dollar")
RGB=RT_HexValue(S,pos=Hx+3)
YUV601 = RGB_2_YUV(RGB,"Rec601")
YUV709 = RGB_2_YUV(RGB,"Rec709")
YUVPC601 = RGB_2_YUV(RGB,"Pc601") # Added
YUVPC709 = RGB_2_YUV(RGB,"Pc709") # Added
YUVREC2020= RGB_2_YUV(RGB,"Rec2020") # Added
RT_DBaseAppend(DB,RGB,YUV601,YUV709,YUVPC601,YUVPC709,YUVREC2020,Name) # Inserted pc yuv and Rec2020 before Name string field
}
}
# """)
Return 0
}



# ColorPicker_Rec_PC.avs # Added Rec2020, Commented out GScript(""" ... """), Restore GScript stuff for non AVS+
/*
Creates animated clip, Page step.
*/


ColorsRGB = "colors_rgb.avsi"
DB = "Colors.DB"

ColorsPerFrame = 10 # Max 16
PageJump = True

MakeClip(DB,ColorsRGB,ColorsPerFrame,PageJump).AssumeFPS(1.0)
#ConvertToYV12() # To make the mp4
RT_FileDelete(DB) # EDIT: Added
Return last

Function RGB_2_YUV(Int RGB_Color,String Matrix) {
c=BlankClip(Width=8,Height=8,Length=1,Color=RGB_Color).ConvertToYV12(matrix=matrix)
current_frame=0 Y=c.YPlaneMin() U=c.UPlaneMin() V=c.VPlaneMin()
return (Y*256+U)*256+V
}

Function MakeDB(String DB,String ColorsRGB) {
myName="MakeDB: "
Assert(Exist(ColorsRGB),RT_String("%s %s Does not exist",myName,ColorsRGB))
Assert(DB!="",RT_String("%s DBase Name Cannot be null",myName))
Exist(DB) ? RT_FileDelete(DB) : NOP
# GScript("""
RT_DBaseAlloc(DB,0,"iiiiiis64") # Inserted three i fields BEFORE s field, so s field (Name) is now field 6
TEXT=RT_ReadTxtFromFile(ColorsRGB)
LINES=RT_TxtQueryLines(TEXT)
for(i=0,LINES-1) {
S=RT_TxtGetLine(TEXT,i)
S=(S!="")?RT_StrReplaceDeep(RT_StrReplace(S,Chr(9)," ")," "," "):S
While(RT_Ord(S)==32) {S=MidStr(S,2)}
if(RT_Ord(S)!=RT_Ord("#") && RT_Ord(S)!=0) {
nm = RT_FindStr(S,"color_")
Assert(nm!=0,"Cannot find color name")
S = MidStr(S,nm)
nmend = RT_FindStr(S," ")
Assert(nm!=0,"Cannot find color name end")
Name = LeftStr(S,nmend)
S = MidStr(S,nmend)
Hx = RT_FindStr(S,"= $")
Assert(Hx!=0,"Cannot find Dollar")
RGB=RT_HexValue(S,pos=Hx+3)
YUV601 =RGB_2_YUV(RGB,"Rec601")
YUV709 =RGB_2_YUV(RGB,"Rec709")
YUVPC601=RGB_2_YUV(RGB,"Pc601") # Added
YUVPC709=RGB_2_YUV(RGB,"Pc709") # Added
YUV2020 =RGB_2_YUV(RGB,"Rec2020") # Added
RT_DBaseAppend(DB,RGB,YUV601,YUV709,YUVPC601,YUVPC709,YUV2020,Name) # Inserted pc yuv before Name string field
}
}
# """)
Return 0
}

Function MakeClip(String DB,String ColorsRGB,Int "ColorsPerFrame",Bool "PageJump") {
myName="MakeClip: "
ColorsPerFrame = Default(ColorsPerFrame,10)
PageJump = Default(PageJump,False)
Assert(ColorsPerFrame>=1&&ColorsPerFrame<=16,RT_String("%s 1 <= ColorsPerFrame <=16 (%d)",myName,ColorsPerFrame))
H = 48
MakeDB(DB,ColorsRGB) records = RT_DBaseRecords(DB)
nmtmpt = BlankClip(length=1,width=316,height=H,pixel_type="RGB32").KillAudio
hxtmpt = BlankClip(length=1,width=108,height=H,pixel_type="RGB32").KillAudio
NC = nmtmpt.BlankClip(color=$FFFFFF).Subtitle("Color Name",Align=5).LetterBox(2,2,2,2)
RGBC = hxtmpt.BlankClip(color=$FFFFFF).Subtitle("RGB",Align=5).LetterBox(2,2,2,2)
Y601C = hxtmpt.BlankClip(color=$FFFFFF).Subtitle("YUV rec601",Align=5).LetterBox(2,2,2,2)
Y709C = hxtmpt.BlankClip(color=$FFFFFF).Subtitle("YUV rec709",Align=5).LetterBox(2,2,2,2)
PCY601C = hxtmpt.BlankClip(color=$FFFFFF).Subtitle("YUV pc601",Align=5).LetterBox(2,2,2,2) # Added
PCY709C = hxtmpt.BlankClip(color=$FFFFFF).Subtitle("YUV pc709",Align=5).LetterBox(2,2,2,2) # Added
Y2020C = hxtmpt.BlankClip(color=$FFFFFF).Subtitle("YUV Rec2020",Align=5).LetterBox(2,2,2,2) # Added
HEAD = StackHorizontal(NC,RGBC,Y601C,Y709C,PCY601C,PCY709C,Y2020C) # Added PC clips + Rec2020
C = 0
# GScript("""
for(i=0,records-1) {
RGB = RT_DBaseGetField(DB,i,0)
YUV601 = RT_DBaseGetField(DB,i,1)
YUV709 = RT_DBaseGetField(DB,i,2)
PCYUV601= RT_DBaseGetField(DB,i,3) # Inserted field
PCYUV709= RT_DBaseGetField(DB,i,4) # Inserted field
RecYUV2020= RT_DBaseGetField(DB,i,5) # Inserted field
Name = RT_DBaseGetField(DB,i,6) # Move from field 5 to field 6
NC = nmtmpt.BlankClip(color=RGB).Subtitle(Name,Align=5).LetterBox(2,2,2,2)
RGBC = hxtmpt.BlankClip(color=$FFFFFF).Subtitle(RT_String("$%0.6X",RGB),Align=5).LetterBox(2,2,2,2)
Y601C = hxtmpt.BlankClip(color=$FFFFFF).Subtitle(RT_String("$%0.6X",YUV601),Align=5).LetterBox(2,2,2,2)
Y709C = hxtmpt.BlankClip(color=$FFFFFF).Subtitle(RT_String("$%0.6X",YUV709),Align=5).LetterBox(2,2,2,2)
PCY601C= hxtmpt.BlankClip(color=$FFFFFF).Subtitle(RT_String("$%0.6X",PCYUV601),Align=5).LetterBox(2,2,2,2) # Added
PCY709C= hxtmpt.BlankClip(color=$FFFFFF).Subtitle(RT_String("$%0.6X",PCYUV709),Align=5).LetterBox(2,2,2,2) # Added
Y2020C = hxtmpt.BlankClip(color=$FFFFFF).Subtitle(RT_String("$%0.6X",RecYUV2020),Align=5).LetterBox(2,2,2,2) # Added
TMPC = StackHorizontal(NC,RGBC,Y601C,Y709C,PCY601C,PCY709C,Y2020C) # Added PC clips + Rec2020
C = (C.IsClip()) ? StackVertical(C,TMPC) : TMPC
}
OUT_H=H*ColorsPerFrame OUT_W=HEAD.Width Bot = 0
if(PageJump) {
if(C.Height % OUT_H != 0) {Bot = C.Crop(0,C.Height-OUT_H,-0,-0)}
C = C.Crop(0,0,-0,C.Height / OUT_H * OUT_H)
Frames = (C.Height/OUT_H)
} else {Frames = (C.Height/H-ColorsPerFrame) + 1 }
C.Loop(Frames,0,0)
Animate(0,Frames-1,"Spline36Resize",OUT_W,OUT_H,0,0,-0,OUT_H, OUT_W,OUT_H,0,Height-OUT_H,-0,OUT_H)
Last = (Bot.IsClip()) ? Last++Bot : Last
HEAD=HEAD.AddBorders(0,0,0,8) # With spacer between HEAD and Colors
StackVertical(HEAD,Last)
# """)
Return Last
}

EDIT: Above script creates an animated clip showing colors in RGB and 5 different matrix versions of YUV,
see a previous post of Reel.Deel for similar result without Rec2020, might be on previous page of thread.
EDIT: Post #23:- https://forum.doom9.org/showthread.php?p=1741775#post1741775

EDIT: Also take a peek at RaffRiff42 Color Presets page on Wiki, its excellent[click on column to sort]:- http://avisynth.nl/index.php?title=Color_presets&oldid=3718

StainlessS
22nd December 2021, 06:40
Post #1 of 3.

@Reel.Deel,
I've updated the previously given scripts that play with colors.rgb.avsi,
If any other valid Matrix strings are added to eg ConvertToYV12(Matrix=matrix), then will be quite simple to edit the script to also cater for those.
Basically, the only change needs to be made to this function in each of the 3 scripts to follow.

Function MatrixNames() { # Returns for Avs 2.60 std = 4 N/L separated matrix names : for AVS+, 6 matrix names.
return RT_string("Rec601\nPC601\nRec709\nPC709\n") + ((Colors_IsPlus) ? RT_String("Rec2020\nPC2020\n") : "")
}

Just eg add in BLUE eg RT_String("Rec2020\nPC2020\nRec2030\nPC2030\n")
and two new Matrix's added. [Of course they have to exist in AVS/+].

Script 1, (Matrix = "ALL" # Will batch create all {currently 6} YUV Matrix Files eg "colors_yuv_PC709.avsi" [Excluding 2020 if not AVS+] )
Colors_YUV_AVSI_Maker.avs

# Colors_YUV_AVSI_Maker.avs # Create equivalent YUV version of Colors_rgb.avsi script
# ####
# ####
# Requires:
# RT_Stats,
# AVS+ (or GScript if not AVS+)
# "colors_rgb.avsi" in current directory
#
# @ Reel.Deel, To Add a NEW Matrix for "ALL" opion, only need edit the MatrixNames() function at end of file.
#
###########################################

/* Example output file:- "colors_yuv_Rec2020.avsi",
# list of common colors (yuv values [Matrix='Rec2020'])

# source:
# http://en.wikipedia.org/wiki/List_of_colors
# http://en.wikipedia.org/wiki/X11_color_names
# http://www.cryer.co.uk/resources/javascript/html2.htm

global Rec2020_aliceblue = $E4847C # RGB = $F0F8FF
global Rec2020_antiquewhite = $DC7587 # RGB = $FAEBD7
global Rec2020_aqua = $B19F10 # RGB = $00FFFF
global Rec2020_aquamarine = $CC7D49 # RGB = $7FFFD4
global Rec2020_azure = $E88279 # RGB = $F0FFFF
*/

### Config ###
#ColorsRGB_FN = "SkinTones_rgb.avsi" # Some other Global Constants file in similar format to colors_rgb.avsi, name = "*****_rgb.avsi".

ColorsRGB_FN = "colors_rgb.avsi"

# Un-Comment ONLY one of below
#Matrix = "Rec601" # "Rec601", "PC601", "Rec709", "PC709", "Rec2020", "PC2020"
#Matrix = "PC601"
#Matrix = "Rec709"
#Matrix = "PC709"
#Matrix = "Rec2020" # AVS+ ONLY
#Matrix = "PC2020" # AVS+ ONLY
Matrix = "ALL" # Will batch create all YUV Matrix Files eg "colors_yuv_PC709.avsi" [Excluding 2020 if not AVS+]
### End Config ###

Assert(Exist(ColorsRGB_FN),ColorsRGB_FN+" Does not exist")
RGB_TEXT=RT_ReadTxtFromFile(ColorsRGB_FN)

GString="""
Function Write_AVSI(String ColorsRGB_FN,String RGB_TEXT,Matrix) {
Path = RT_FileNameSplit(ColorsRGB_FN,3)
NameNode = RT_FileNameSplit(ColorsRGB_FN,4)
Ext = RT_FileNameSplit(ColorsRGB_FN,8)
if(NameNode.revStr.RT_FindStr("bgr_",sig=false)==1) {
NameNode=NameNode.LeftStr(NameNode.StrLen-4) # remove "_rgb" from end of name node
}
NameNode = NameNode + "_yuv_" + Matrix
ColorsYUV_FN = Path + nameNode + Ext
Exist(ColorsYUV_FN) ? RT_FileDelete(ColorsYUV_FN) : NOP
Insert=RT_String("(yuv values [Matrix='%s'])",Matrix)
LINES=RT_TxtQueryLines(RGB_TEXT)
for(i=0,LINES-1) {
S=RT_TxtGetLine(RGB_TEXT,i)
S=(S!="")?RT_StrReplaceDeep(RT_StrReplace(S,Chr(9)," ")," "," "):S
S=(S!="")?RT_StrReplace(S,"(rgb values)",Insert):S
While(RT_Ord(S)==32) {S=MidStr(S,2)}
if(RT_Ord(S)==RT_Ord("#") || RT_Ord(S)==0) {
S=(RT_Ord(S)==0)?Chr(10):S
RT_WriteFile(ColorsYUV_FN,"%s",S,Append=True)
} Else {
Hx = RT_FindStr(S,"= $",sig=false)
Assert(Hx!=0,"Cannot find Dollar")
SOUT=RT_StrReplace(LeftStr(S,Hx-1),"color_",Matrix+"_",sig=false)
SOUT=RT_StrPad(SOUT,40)
RGB=RT_HexValue(S,pos=Hx+3)
YUV=RGB_2_YUV(RGB,Matrix)
RT_Writefile(ColorsYUV_FN,"%s= $%0.6X # RGB = $%0.6X",SOUT,YUV,RGB,Append=True)
}
}
return true
}
if(Matrix == "ALL") {
MAT = MatrixNames()
LINES=RT_TxtQueryLines(MAT)
for(i=0,LINES-1) {
Matrix=RT_TxtGetLine(MAT,i)
Write_AVSI(ColorsRGB_FN,RGB_TEXT,Matrix)
}
} Else { Write_AVSI(ColorsRGB_FN,RGB_TEXT,Matrix) }
"""

(Colors_IsPlus()) ? Eval(GString) : GScript(GString)
return MessageClip("Done")

##################################
Function Colors_IsPlus() { FindStr(LCase(VersionString),"avisynth+")!=0 }

Function RGB_2_YUV(Int RGB_Color,String Matrix) {
c=BlankClip(Width=8,Height=8,Length=1,Color=RGB_Color).ConvertToYV12(matrix=matrix)
current_frame=0 Y=c.YPlaneMin() U=c.UPlaneMin() V=c.VPlaneMin()
return (Y*256+U)*256+V
}

Function MatrixNames() { # Returns for Avs 2.60 std = 4 N/L separated matrix names : for AVS+, 6 matrix names.
return RT_string("Rec601\nPC601\nRec709\nPC709\n") + ((Colors_IsPlus) ? RT_String("Rec2020\nPC2020\n") : "")
}


First few lines of one of the files, "colors_yuv_PC2020.avsi".

# list of common colors (yuv values [Matrix='PC2020'])

# source:
# http://en.wikipedia.org/wiki/List_of_colors
# http://en.wikipedia.org/wiki/X11_color_names
# http://www.cryer.co.uk/resources/javascript/html2.htm

global PC2020_aliceblue = $F6857C # RGB = $F0F8FF
global PC2020_antiquewhite = $EE7488 # RGB = $FAEBD7
global PC2020_aqua = $BCA301 # RGB = $00FFFF
global PC2020_aquamarine = $DB7C42 # RGB = $7FFFD4
global PC2020_azure = $FB8279 # RGB = $F0FFFF
global PC2020_beige = $F47481 # RGB = $F5F5DC
global PC2020_bisque = $E96C8F # RGB = $FFE4C4
global PC2020_black = $008080 # RGB = $000000
global PC2020_blanchedalmond = $EE6E8B # RGB = $FFEBCD
global PC2020_blue = $0FFF76 # RGB = $0000FF
global PC2020_blueviolet = $4FCEA8 # RGB = $8A2BE2
global PC2020_brown = $4A6FBD # RGB = $A52A2A
global PC2020_burlywood = $BF6295 # RGB = $DEB887
global PC2020_cadetblue = $8E8A61 # RGB = $5F9EA0
global PC2020_chartreuse = $CE134A # RGB = $7FFF00
global PC2020_chocolate = $804CB7 # RGB = $D2691E
global PC2020_coral = $9E57C2 # RGB = $FF7F50
global PC2020_cornflowerblue = $8DB364 # RGB = $6495ED
global PC2020_cornsilk = $F87185 # RGB = $FFF8DC
global PC2020_crimson = $4B78E2 # RGB = $DC143C
global PC2020_cyan = $BCA301 # RGB = $00FFFF
global PC2020_darkblue = $08C57A # RGB = $00008B
global PC2020_darkcyan = $66933B # RGB = $008B8B
global PC2020_darkgoldenrod = $8C3C9E # RGB = $B8860B
global PC2020_darkgray = $A98080 # RGB = $A9A9A9
global PC2020_darkgreen = $445C52 # RGB = $006400
global PC2020_darkkhaki = $B45986 # RGB = $BDB76B

StainlessS
22nd December 2021, 06:52
Post #2 of 3

ColorsTextMaker_RGB_YUV.avs

# ColorsTextMaker_RGB_YUV.avs
# ####
# Requires:
# RT_Stats,
# AVS+ (or GScript if not AVS+)
# "colors_rgb.avsi" in current directory
#
# @ Reel.Deel, To Add a NEW Matrix, only need edit the MatrixNames() function at end of file.
#
###########################################

/* Example Output file "Colors_RGBYUV.Txt"
# list of common colors (rgb values)

# source:
# http://en.wikipedia.org/wiki/List_of_colors
# http://en.wikipedia.org/wiki/X11_color_names
# http://www.cryer.co.uk/resources/javascript/html2.htm
________________________________________________________________________________________
ColorName | RGB | Rec601 | PC601 | Rec709 | PC709 | Rec2020 | PC2020 |
________________________________________________________________________________________________________________|
color_aliceblue | $F0F8FF | $E4847C | $F6857B | $E4847C | $F7847C | $E4847C | $F6857C |
________________________________________________________________________________________________________________|
color_antiquewhite | $FAEBD7 | $DC7588 | $ED7489 | $DB7687 | $ED7488 | $DC7587 | $EE7488 |
________________________________________________________________________________________________________________|
color_aqua | $00FFFF | $AAA610 | $B3AB01 | $BC9A10 | $C99D01 | $B19F10 | $BCA301 |
________________________________________________________________________________________________________________|
color_aquamarine | $7FFFD4 | $C6804B | $D48044 | $D17A4A | $E17942 | $CC7D49 | $DB7C42 |
________________________________________________________________________________________________________________|
*/


### config ###
#ColorsRGB_FN = "SkinTones_rgb.avsi" # Some other Global Constants file in similar format to colors_rgb.avsi, name = "*****_rgb.avsi".

ColorsRGB_FN = "colors_rgb.avsi"
Header = True # Copy Colors_rgb.avsi header into output
LineSep = True # Separator line betten rows
RightBar = True # '|' at end of each line
### end config ###

#################

Assert(Exist(ColorsRGB_FN),ColorsRGB_FN+" Does not exist")
RGB_TEXT=RT_ReadTxtFromFile(ColorsRGB_FN)

Path = RT_FileNameSplit(ColorsRGB_FN,3)
NameNode = RT_FileNameSplit(ColorsRGB_FN,4)
if(NameNode.revStr.RT_FindStr("bgr_",sig=false)==1) {
NameNode=NameNode.LeftStr(NameNode.StrLen-4) # remove "_rgb" from end of name node
}
ColorsYUV_FN = Path + nameNode + "_RGBYUV.txt"

GString="""
Function Write_Colors_Text(String RGB_TEXT,String "ColorsYUV_FN",Bool "Header",Bool "LineSep",Bool "RightBar") {
Header=Default(Header,True) LineSep=Default(LineSep,False) RightBar=Default(RightBar,False)
Exist(ColorsYUV_FN) ? RT_FileDelete(ColorsYUV_FN) : NOP
DB = RT_LocaltimeString(File=True) + ".DB" MakeDB(DB,RGB_TEXT)
if(Header) {
LINES=RT_TxtQueryLines(RGB_TEXT)
for(i=0,LINES-1) {
S=RT_TxtGetLine(RGB_TEXT,i)
S=(S!="")?RT_StrReplaceDeep(RT_StrReplace(S,Chr(9)," ")," "," "):S
While(RT_Ord(S)==32) {S=MidStr(S,2)}
if(RT_Ord(S)!=RT_Ord("#") && RT_Ord(S)!=0) {
i = LINES # Break
} else { # Write the Colors_rgb.avsi header
RT_WriteFile(ColorsYUV_FN,"%s\n",S,Append=True)
}
}
}
Records=RT_DBaseRecords(DB)
MAT = MatrixNames()
MatrixCount = RT_TxtQueryLines(MAT)
NAMEPAD=28
HEXPAD=11
ValuesCount = 1 + MatrixCount # Number of values, (RGB + number of YUV values)
USCOREPAD=NAMEPAD+(ValuesCount)*(HEXPAD+1)
RS=RightBar?"|":""
USCORE=RT_StrPad("",USCOREPAD,"_") RT_WriteFile(ColorsYUV_FN,"%s",USCORE,Append=True)
Name = RT_StrPad("ColorName" ,NAMEPAD) RGB = TextCenterPad("RGB" ,HEXPAD)
WriteS = Name + "|" + RGB
for(j=0,MatrixCount-1) {
WriteS = RT_String("%s|%s",WriteS,TextCenterPad(RT_TxtGetLine(MAT,j),HEXPAD))
}
RT_WriteFile(ColorsYUV_FN,"%s%s",WriteS,RS,Append=True)
RT_WriteFile(ColorsYUV_FN,"%s%s",USCORE,RS,Append=True)
for(i=0,Records-1) {
WriteS = RT_string("%s",RT_StrPad(RT_DBaseGetField(DB,i,0),NAMEPAD)) # Name
WriteS = RT_string("%s|%s",WriteS,TextCenterPad(RT_String("$%06X",RT_DBaseGetField(DB,i,1)),HEXPAD)) # Append RGB Hex
for(j=0,MatrixCount-1) {
WriteS = RT_string("%s|%s",WriteS,TextCenterPad(RT_String("$%06X",RT_DBaseGetField(DB,i,2+j)),HEXPAD)) # Maxtrix conversion YUV Hex
}
RT_WriteFile(ColorsYUV_FN,"%s%s",WriteS,RS,Append=True)
(LineSep||i==Records-1) ? RT_WriteFile(ColorsYUV_FN,"%s%s",USCORE,RS,Append=True) : NOP
}
RT_FileDelete(DB)
}


Function MakeDB(String DB,String RGB_TEXT) {
myName="MakeDB: "
Assert(DB!="",RT_String("%s DBase Name Cannot be null",myName))
MAT = MatrixNames()
MatrixCount = RT_TxtQueryLines(MAT)
TypeString = "s64i" + RT_StrPad("",MatrixCount,"i") # We MOVED the name to the first [0] field. RGB=Field 1. + Add an 'i' int field for each valid Matrix
RT_DBaseAlloc(DB,0,TypeString)
LINES=RT_TxtQueryLines(RGB_TEXT)
for(i=0,LINES-1) {
S=RT_TxtGetLine(RGB_TEXT,i)
S=(S!="")?RT_StrReplaceDeep(RT_StrReplace(S,Chr(9)," ")," "," "):S
While(RT_Ord(S)==32) {S=MidStr(S,2)}
if(RT_Ord(S)!=RT_Ord("#") && RT_Ord(S)!=0) {
nm = RT_FindStr(S,"color_",sig=false)
Assert(nm!=0,"Cannot find color name")
S = MidStr(S,nm)
nmend = RT_FindStr(S," ",sig=false)
Assert(nm!=0,"Cannot find color name end")
Name = LeftStr(S,nmend)
S = MidStr(S,nmend)
Hx = RT_FindStr(S,"= $",sig=false)
Assert(Hx!=0,"Cannot find Dollar")
RGB=RT_HexValue(S,pos=Hx+3) # RGB HEX value
RT_DBaseExtend(DB,1) # Add a single Blank record [all fields zeroed]
Record = RT_DBaseRecords(DB) - 1 # End record number
RT_DBaseSetField(DB,Record,0,Name) # Set Color name
RT_DBaseSetField(DB,Record,1,RGB) # Set RGB Value
for(j=0,MatrixCount-1) { # Iterate over Matrix Strings
M = RT_TxtGetLine(MAT,j) # Get the Matrix string name
YUV = RGB_2_YUV(RGB,M) # Convert RGB to YUV via matrix string M
RT_DBaseSetField(DB,Record,2+j,YUV) # Set YUV Value [FIELD 0=colorname, 1=RGB, 2+ = YUV matrix conversions]
}
}
}
Return 0
}
Write_Colors_Text(RGB_TEXT,ColorsYUV_FN,Header,LineSep,RightBar)
"""

(Colors_IsPlus()) ? Eval(GString) : GScript(GString)

return MessageClip("Done")


######################
Function Colors_IsPlus() { FindStr(LCase(VersionString),"avisynth+")!=0 }

Function TextCenterPad(String S,int PadLen) {S=RT_StrPad("",(PadLen-StrLen(S))/2) + S Return RT_StrPad(S,PadLen)}

Function RGB_2_YUV(Int RGB_Color,String Matrix) {
c=BlankClip(Width=8,Height=8,Length=1,Color=RGB_Color).ConvertToYV12(matrix=matrix)
current_frame=0 Y=c.YPlaneMin() U=c.UPlaneMin() V=c.VPlaneMin()
return (Y*256+U)*256+V
}

Function MatrixNames() { # Returns for Avs 2.60 std = 4 N/L separated matrix names : for AVS+, 6 matrix names.
return RT_string("Rec601\nPC601\nRec709\nPC709\n") + ((Colors_IsPlus) ? RT_String("Rec2020\nPC2020\n") : "")
}


First few lines produced [header is optional]

# list of common colors (rgb values)

# source:
# http://en.wikipedia.org/wiki/List_of_colors
# http://en.wikipedia.org/wiki/X11_color_names
# http://www.cryer.co.uk/resources/javascript/html2.htm

________________________________________________________________________________________________________________
ColorName | RGB | Rec601 | PC601 | Rec709 | PC709 | Rec2020 | PC2020 |
________________________________________________________________________________________________________________|
color_aliceblue | $F0F8FF | $E4847C | $F6857B | $E4847C | $F7847C | $E4847C | $F6857C |
________________________________________________________________________________________________________________|
color_antiquewhite | $FAEBD7 | $DC7588 | $ED7489 | $DB7687 | $ED7488 | $DC7587 | $EE7488 |
________________________________________________________________________________________________________________|
color_aqua | $00FFFF | $AAA610 | $B3AB01 | $BC9A10 | $C99D01 | $B19F10 | $BCA301 |
________________________________________________________________________________________________________________|
color_aquamarine | $7FFFD4 | $C6804B | $D48044 | $D17A4A | $E17942 | $CC7D49 | $DB7C42 |
________________________________________________________________________________________________________________|
color_azure | $F0FFFF | $E78279 | $FB8379 | $E88279 | $FC8279 | $E88279 | $FB8279 |
________________________________________________________________________________________________________________|
color_beige | $F5F5DC | $E07582 | $F27482 | $E17581 | $F37481 | $E17581 | $F47481 |
________________________________________________________________________________________________________________|
color_bisque | $FFE4C4 | $D86E8E | $E86C90 | $D76F8D | $E76D8F | $D86F8D | $E96C8F |
________________________________________________________________________________________________________________|
color_black | $000000 | $108080 | $008080 | $108080 | $008080 | $108080 | $008080 |
________________________________________________________________________________________________________________|
color_blanchedalmond | $FFEBCD | $DC708B | $EE6E8C | $DC718A | $ED6F8B | $DD708A | $EE6E8B |
________________________________________________________________________________________________________________|
color_blue | $0000FF | $29F06E | $1DFF6B | $20F076 | $12FF74 | $1DF077 | $0FFF76 |
________________________________________________________________________________________________________________|
color_blueviolet | $8A2BE2 | $5FC29D | $5CCBA1 | $52C7A2 | $4CD0A7 | $54C5A3 | $4FCEA8 |
________________________________________________________________________________________________________________|
color_brown | $A52A2A | $546EB6 | $4F6BBD | $4B74B6 | $4472BD | $5071B6 | $4A6FBD |
________________________________________________________________________________________________________________|
color_burlywood | $DEB887 | $B36594 | $BE6197 | $B26793 | $BD6395 | $B46692 | $BF6295 |
________________________________________________________________________________________________________________|
color_cadetblue | $5F9EA0 | $888A64 | $8B8C60 | $8C8764 | $918861 | $8A8964 | $8E8A61 |
________________________________________________________________________________________________________________|
color_chartreuse | $7FFF00 | $B1235A | $BC1755 | $C41D52 | $D1104C | $C12051 | $CE134A |
________________________________________________________________________________________________________________|
color_chocolate | $D2691E | $7E50B3 | $8049BA | $7955B1 | $7A4FB8 | $7E52B1 | $804CB7 |
________________________________________________________________________________________________________________|
color_coral | $FF7F50 | $9958BC | $A053C4 | $925EBA | $975AC2 | $985CBA | $9E57C2 |
________________________________________________________________________________________________________________|

StainlessS
22nd December 2021, 06:56
Post #3 of 3

ColorPicker.avs [Produces an animated video clip].

# ColorPicker.avs
# ####
# Creates animated clip, Page step.
# Requires:
# RT_Stats,
# AVS+ (or GScript if not AVS+)
# "colors_rgb.avsi" in current directory
#
# @ Reel.Deel, To Add a NEW Matrix, only need edit the MatrixNames() function at end of file.
###########################################

### Config ###
#ColorsRGB_FN = "SkinTones_rgb.avsi" # Some other Global Constants file in similar format to colors_rgb.avsi, name = "*****_rgb.avsi".

ColorsRGB_FN = "colors_rgb.avsi"
ColorsPerFrame = 10 # Max 16
PageJump = True
### End Config ###

GString="""
Function MakeDB(String DB,String RGB_TEXT) {
myName="MakeDB: "
Assert(DB!="",RT_String("%s DBase Name Cannot be null",myName))
MAT = MatrixNames()
MatrixCount = RT_TxtQueryLines(MAT)
TypeString = "s64i" + RT_StrPad("",MatrixCount,"i") # We MOVED the name to the first [0] field. RGB=Field 1. + Add an 'i' int field for each valid Matrix
RT_DBaseAlloc(DB,0,TypeString)
LINES=RT_TxtQueryLines(RGB_TEXT)
for(i=0,LINES-1) {
S=RT_TxtGetLine(RGB_TEXT,i)
S=(S!="")?RT_StrReplaceDeep(RT_StrReplace(S,Chr(9)," ")," "," "):S
While(RT_Ord(S)==32) {S=MidStr(S,2)}
if(RT_Ord(S)!=RT_Ord("#") && RT_Ord(S)!=0) {
nm = RT_FindStr(S,"color_",sig=false)
Assert(nm!=0,"Cannot find color name")
S = MidStr(S,nm)
nmend = RT_FindStr(S," ",sig=false)
Assert(nm!=0,"Cannot find color name end")
Name = LeftStr(S,nmend)
S = MidStr(S,nmend)
Hx = RT_FindStr(S,"= $",sig=false)
Assert(Hx!=0,"Cannot find Dollar")
RGB=RT_HexValue(S,pos=Hx+3) # RGB HEX value
RT_DBaseExtend(DB,1) # Add a single Blank record [all fields zeroed]
Record = RT_DBaseRecords(DB) - 1 # End record number
RT_DBaseSetField(DB,Record,0,Name) # Set Color name
RT_DBaseSetField(DB,Record,1,RGB) # Set RGB Value
for(j=0,MatrixCount-1) { # Iterate over Matrix Strings
M = RT_TxtGetLine(MAT,j) # Get the Matrix string name
YUV = RGB_2_YUV(RGB,M) # Convert RGB to YUV via matrix string M
RT_DBaseSetField(DB,Record,2+j,YUV) # Set YUV Value [FIELD 0=colorname, 1=RGB, 2+ = YUV matrix conversions]
}
}
}
Return 0
}

Function MakeClip(String DB,String RGB_TEXT,Int "ColorsPerFrame",Bool "PageJump") {
myName="MakeClip: "
ColorsPerFrame = Default(ColorsPerFrame,10)
PageJump = Default(PageJump,False)
Assert(ColorsPerFrame>=1&&ColorsPerFrame<=16,RT_String("%s 1 <= ColorsPerFrame <=16 (%d)",myName,ColorsPerFrame))
H = 48
MakeDB(DB,RGB_TEXT) records = RT_DBaseRecords(DB)
MAT = MatrixNames()
MatrixCount = RT_TxtQueryLines(MAT)
nmtmpt = BlankClip(length=1,width=316,height=H,pixel_type="RGB32").KillAudio # Template clip
hxtmpt = BlankClip(length=1,width=108,height=H,pixel_type="RGB32").KillAudio # Template clip
NAMEC = nmtmpt.BlankClip(color=$FFFFFF).Subtitle("Color Name",Align=5).LetterBox(2,2,2,2)
RGBC = hxtmpt.BlankClip(color=$FFFFFF).Subtitle("RGB",Align=5).LetterBox(2,2,2,2)
HEAD = StackHorizontal(NAMEC,RGBC)
for(j=0,MatrixCount-1) { # Add the YUV Matrix name clips to Header clip
M = RT_TxtGetLine(MAT,j)
MATC = hxtmpt.BlankClip(color=$FFFFFF).Subtitle("YUV " + M,Align=5).LetterBox(2,2,2,2) # YUV HEx Value subclip
HEAD = HEAD.StackHorizontal(MATC) # Add to HEADER ROW clip
}
C = 0
for(i=0,records-1) { # Add Color Rows
Name = RT_DBaseGetField(DB,i,0)
RGB = RT_DBaseGetField(DB,i,1)
NAMEC = nmtmpt.BlankClip(color=RGB).Subtitle(Name,Align=5).LetterBox(2,2,2,2) # Name subclip (with background the RGB Color Constant color)
RGBC = hxtmpt.BlankClip(color=$FFFFFF).Subtitle(RT_String("$%0.6X",RGB),Align=5).LetterBox(2,2,2,2) # RGB hex subclip
ROWC = StackHorizontal(NAMEC,RGBC)
for(j=0,MatrixCount-1) { # Add YUV Hex subclip to row so far
YUV = RT_DBaseGetField(DB,i,2+j)
YUVC = hxtmpt.BlankClip(color=$FFFFFF).Subtitle(RT_String("$%0.6X",YUV),Align=5).LetterBox(2,2,2,2) # YUV matrix subclip
ROWC = ROWC.StackHorizontal(YUVC)
}
C = (C.IsClip()) ? StackVertical(C,ROWC) : ROWC
}
OUT_H=H*ColorsPerFrame OUT_W=HEAD.Width Bot = 0
if(PageJump) {
if(C.Height % OUT_H != 0) {Bot = C.Crop(0,C.Height-OUT_H,-0,-0)}
C = C.Crop(0,0,-0,C.Height / OUT_H * OUT_H)
Frames = (C.Height/OUT_H)
} else {Frames = (C.Height/H-ColorsPerFrame) + 1 }
C.Loop(Frames,0,0)
Animate(0,Frames-1,"Spline36Resize",OUT_W,OUT_H,0,0,-0,OUT_H, OUT_W,OUT_H,0,Height-OUT_H,-0,OUT_H)
Last = (Bot.IsClip()) ? Last++Bot : Last
HEAD=HEAD.AddBorders(0,0,0,8) # With spacer between HEAD and Colors
StackVertical(HEAD,Last)
Return Last
}
"""
(Colors_IsPlus()) ? Eval(GString) : GScript(GString)

Assert(Exist(ColorsRGB_FN),ColorsRGB_FN+" Does not exist")
RGB_TEXT=RT_ReadTxtFromFile(ColorsRGB_FN)
DB = "Colors.DB"
MakeClip(DB,RGB_TEXT,ColorsPerFrame,PageJump).AssumeFPS(1.0)
#ConvertToYV12 # (Matrix=???) # Uncomment To make the mp4
RT_FileDelete(DB)
Return last


##############################
Function Colors_IsPlus() { FindStr(LCase(VersionString),"avisynth+")!=0 }

Function RGB_2_YUV(Int RGB_Color,String Matrix) {
c=BlankClip(Width=8,Height=8,Length=1,Color=RGB_Color).ConvertToYV12(matrix=matrix)
current_frame=0 Y=c.YPlaneMin() U=c.UPlaneMin() V=c.VPlaneMin()
return (Y*256+U)*256+V
}

Function MatrixNames() { # Returns for Avs 2.60 std = 4 N/L separated matrix names : for AVS+, 6 matrix names.
return RT_string("Rec601\nPC601\nRec709\nPC709\n") + ((Colors_IsPlus) ? RT_String("Rec2020\nPC2020\n") : "")
}

EDIT: Commented out the ending ConvertToYV12 [was to make mp4 clip]
https://i.postimg.cc/t4xk7vnF/Color-Picker-00.jpg (https://postimages.org/)

ColorPicker.mp4 [about 1MB]
https://www.mediafire.com/file/xd122tkddliuedc/ColorPicker.mp4/file

EDIT: I dont know if you might find any use for this.

Return UV256_YScanClip()

###################

Function UV256_YScanClip(Bool "Cartesian",Bool "ShowY") {
Cartesian = Default(Cartesian,True) # True, Origin @ Bottom Left, False @ Top Left
ShowY = Default(ShowY,True) # Show Y at Origin
CB = YRamp256_H(True) # U : change in Blue
CR = YRamp256_V(TopZero = !Cartesian) # V : change in Red
Q=0
For(i=0,255) {
Y = YFrame256(i)
C = YToUV(CB,CR,Y)
C = (!ShowY) ? C : C.Subtitle("Y="+String(i),Align=(Cartesian) ? 1 : 7)
Q = Q.IsClip ? Q + C : C
}
Return Q
}

Function YRamp256_H(Bool "LeftZero") {
LeftZero = Default(LeftZero,true)
Left = (LeftZero) ? 0 : 255
Right = (LeftZero) ? 255 : 0
LC=BlankClip(length=1,width=1,height=256,pixel_type="Y8",Color_YUV=(Left*256+128)*256+128).KillAudio
RC=LC.BlankClip(Color_YUV=(Right*256+128)*256+128)
StackHorizontal(LC,RC)
Return BilinearResize(512,256).Crop(128,0,-128,-0)
}

Function YRamp256_V(Bool "TopZero") {
TopZero = Default(TopZero,true)
Top = (TopZero) ? 0 : 255
Bot = (TopZero) ? 255 : 0
TC=BlankClip(length=1,width=256,height=1,Pixel_type="Y8",Color_YUV=(Top *256+128)*256+128).KillAudio
BC=TC.BlankClip(Color_YUV=(Bot*256+128)*256+128)
StackVertical(TC,BC)
Return BilinearResize(256,512).Crop(0,128,-0,-128)
}

Function YFrame256(int "Y") { Y=Default(Y,128).Max(0).Min(255) Return BlankClip(length=1,width=256,height=256,Pixel_type="Y8",Color_YUV=(Y *256+128)*256+128).KillAudio }


Makes 256 frame clip, scanning through Y [below @ Y=0, 128 and 255, U,V origin at bottom left]
https://i.postimg.cc/nrpbwt4Y/B-01.jpg (https://postimages.org/) https://i.postimg.cc/XNRyq1VK/B-00.jpg (https://postimages.org/) https://i.postimg.cc/DywRW6BZ/B-02.jpg (https://postimages.org/)

Did in UV Cartesian coords [bot,left origin] to match those used on Wikipedia YUV:- https://en.wikipedia.org/wiki/YUV

EDIT: And UV origin at top left [ UV256_YScanClip(Cartesian=false) ].
https://i.postimg.cc/CM8Bw0W0/UV256-YScan-Clip-00.jpg (https://postimages.org/) https://i.postimg.cc/GhJ4sQLS/UV256-YScan-Clip-01.jpg (https://postimages.org/) https://i.postimg.cc/XvXqm6wT/UV256-YScan-Clip-02.jpg (https://postimages.org/)

EDIT: Although above Y=0, and Y=255 were just exported as jpg from Vdub2 and uploaded to postimage.org,
maybe should have shown Y=16 and Y=235 instead.

StainlessS
23rd December 2021, 02:21
Reel.Deel,
Prev 3 posts updated, mods to enable use with similar-ish format global constant colors, all work the same. [just change input colors_rgb.avsi filename].
Here a test globals file I was playing with.

SkinTones_rgb.avsi

########################################
# A Small selection of skin colors
########################################
# Skin - combinations with color codes :- https://www.schemecolor.com/tag/skin
########################################

# Real Skin Tones Color Scheme :- https://www.schemecolor.com/real-skin-tones-color-palette.php

global color_skin_navajo_white = $FFDBAC
global color_skin_mellow_apricot = $F1C27D
global color_skin_fawn = $E0AC69
global color_skin_peru = $c68642
global color_skin_russet = $8d5524

# Beautiful Fair Skin Color Scheme :- https://www.schemecolor.com/beautiful-fair-skin-color-scheme.php

global color_skin_apricot = $FDC5B1
global color_skin_light_red = $FBD4C5
global color_skin_unbleached_silk = $FBDDCF
global color_skin_misty_rose = $FDE7DD
global color_skin_linen = $FDEFE5

# Asian Skin Color Scheme :- https://www.schemecolor.com/asian-skin.php

global color_skin_pale_pink = $F9DED7
global color_skin_baby_pink = $ECC9BD
global color_skin_pastel_pink = $E8B3A2
global color_skin_desert_sand = $F0C2AA
global color_skin_dutch_white = $F0D3C0

# Black Guy Skin Color Scheme :- https://www.schemecolor.com/black-guy-skin-colors.php

global color_skin_root_beer = $260701
global color_skin_black_bean = $3D0C02
global color_skin_burnt_umber = $843722
global color_skin_brown_sugar = $AF6E51
global color_skin_antique_brass = $C69076


SkinTones_RGBYUV.txt Text file output

########################################
# A Small select of skin colors
########################################
# Skin - combinations with color codes :- https://www.schemecolor.com/tag/skin
########################################

# Real Skin Tones Color Scheme :- https://www.schemecolor.com/real-skin-tones-color-palette.php

________________________________________________________________________________________________________________
ColorName | RGB | Rec601 | PC601 | Rec709 | PC709 | Rec2020 | PC2020 |
________________________________________________________________________________________________________________|
color_skin_navajo_white | $FFDBAC | $D16693 | $E06396 | $D06892 | $DF6494 | $D26791 | $E26494 |
________________________________________________________________________________________________________________|
color_skin_mellow_apricot | $F1C27D | $BC5B9A | $C8569D | $BB5D97 | $C7589B | $BE5C97 | $CA579A |
________________________________________________________________________________________________________________|
color_skin_fawn | $E0AC69 | $AB5B9C | $B4569F | $A95D9A | $B2599D | $AC5C99 | $B6579D |
________________________________________________________________________________________________________________|
color_skin_peru | $C68642 | $8D59A1 | $9153A5 | $8B5C9F | $8F57A3 | $8E5A9F | $9355A3 |
________________________________________________________________________________________________________________|
color_skin_russet | $8D5524 | $63629C | $605EA0 | $60659B | $5D619E | $63649A | $61609E |
________________________________________________________________________________________________________________|
color_skin_apricot | $FDC5B1 | $C66F9A | $D36D9E | $C27299 | $CF709D | $C57099 | $D36E9D |
________________________________________________________________________________________________________________|
color_skin_light_red | $FBD4C5 | $CF7492 | $DE7295 | $CC7692 | $DB7494 | $CE7592 | $DD7394 |
________________________________________________________________________________________________________________|
color_skin_unbleached_silk | $FBDDCF | $D4758E | $E47490 | $D2778E | $E27690 | $D4768E | $E47590 |
________________________________________________________________________________________________________________|
color_skin_misty_rose | $FDE7DD | $DB788A | $EC778C | $DA798A | $EB798B | $DB798A | $EC788B |
________________________________________________________________________________________________________________|
color_skin_linen | $FDEFE5 | $E07A87 | $F27988 | $DF7A87 | $F17987 | $E07A87 | $F27987 |
________________________________________________________________________________________________________________|
color_skin_pale_pink | $F9DED7 | $D5798C | $E5788E | $D37A8C | $E3798E | $D47A8C | $E5798E |
________________________________________________________________________________________________________________|
color_skin_baby_pink | $ECC9BD | $C47690 | $D27492 | $C27790 | $D07692 | $C47690 | $D17592 |
________________________________________________________________________________________________________________|
color_skin_pastel_pink | $E8B3A2 | $B67198 | $C16F9C | $B27398 | $BD719B | $B57298 | $C0709B |
________________________________________________________________________________________________________________|
color_skin_desert_sand | $F0C2AA | $C06F96 | $CD6C99 | $BE7195 | $CA6F98 | $C07095 | $CD6E98 |
________________________________________________________________________________________________________________|
color_skin_dutch_white | $F0D3C0 | $CB738E | $DA7290 | $C9758E | $D8738F | $CB748D | $D9738F |
________________________________________________________________________________________________________________|
color_skin_root_beer | $260701 | $1D798E | $107890 | $1B7A8E | $0D7990 | $1D7A8E | $0F7990 |
________________________________________________________________________________________________________________|
color_skin_black_bean | $3D0C02 | $267496 | $1A7399 | $237796 | $167599 | $257696 | $187499 |
________________________________________________________________________________________________________________|
color_skin_burnt_umber | $843722 | $516BA3 | $4C69A8 | $4C6FA3 | $466DA7 | $506DA3 | $4A6BA7 |
________________________________________________________________________________________________________________|
color_skin_brown_sugar | $AF6E51 | $7C6A9F | $7E67A3 | $796D9E | $7A6AA2 | $7C6B9E | $7D69A2 |
________________________________________________________________________________________________________________|
color_skin_antique_brass | $C69076 | $976D9A | $9D6A9D | $946F99 | $9A6D9C | $976E99 | $9D6C9C |
________________________________________________________________________________________________________________|


And from the colorpicker, one frame (of 2).
https://i.postimg.cc/3rcXBGqZ/Color-Picker-00.jpg (https://postimages.org/)

I have not posted the YUV constants output avsi examples, but it works just fine.

EDIT: Here is 1 of the 6 generated files, SkinTones_yuv_Rec601.avsi

########################################
# A Small select of skin colors
########################################
# Skin - combinations with color codes :- https://www.schemecolor.com/tag/skin
########################################

# Real Skin Tones Color Scheme :- https://www.schemecolor.com/real-skin-tones-color-palette.php

global Rec601_skin_navajo_white = $D16693 # RGB = $FFDBAC
global Rec601_skin_mellow_apricot = $BC5B9A # RGB = $F1C27D
global Rec601_skin_fawn = $AB5B9C # RGB = $E0AC69
global Rec601_skin_peru = $8D59A1 # RGB = $C68642
global Rec601_skin_russet = $63629C # RGB = $8D5524

# Beautiful Fair Skin Color Scheme :- https://www.schemecolor.com/beautiful-fair-skin-color-scheme.php

global Rec601_skin_apricot = $C66F9A # RGB = $FDC5B1
global Rec601_skin_light_red = $CF7492 # RGB = $FBD4C5
global Rec601_skin_unbleached_silk = $D4758E # RGB = $FBDDCF
global Rec601_skin_misty_rose = $DB788A # RGB = $FDE7DD
global Rec601_skin_linen = $E07A87 # RGB = $FDEFE5

# Asian Skin Color Scheme :- https://www.schemecolor.com/asian-skin.php

global Rec601_skin_pale_pink = $D5798C # RGB = $F9DED7
global Rec601_skin_baby_pink = $C47690 # RGB = $ECC9BD
global Rec601_skin_pastel_pink = $B67198 # RGB = $E8B3A2
global Rec601_skin_desert_sand = $C06F96 # RGB = $F0C2AA
global Rec601_skin_dutch_white = $CB738E # RGB = $F0D3C0

# Black Guy Skin Color Scheme :- https://www.schemecolor.com/black-guy-skin-colors.php

global Rec601_skin_root_beer = $1D798E # RGB = $260701
global Rec601_skin_black_bean = $267496 # RGB = $3D0C02
global Rec601_skin_burnt_umber = $516BA3 # RGB = $843722
global Rec601_skin_brown_sugar = $7C6A9F # RGB = $AF6E51
global Rec601_skin_antique_brass = $976D9A # RGB = $C69076


EDIT: We wanna get some skin color info to try avoid disappearing arms and legs and stuff in eg SpotlessS.

Reel.Deel
29th December 2021, 06:41
Hi there StainlessS. Thank you for the update. I will try it out soon and get back to you :)

Reel.Deel
5th January 2022, 12:53
Kudos StainlessS! Just tried ColorPicker.avs and ColorsTextMaker_RGB_YUV.avs. I'm actually slowly working on offline docs for AVS+, I think the colors_rgb table with all of the different matrices might make it on there. Thanks for being so thorough :).

I made an animated png out of the color picker script, it's in RGB and almost the same size as your video.

https://i.ibb.co/bbJgQ07/colors-in-yuv.png

Edit:

The table format from the script made is easy to make it into an RST table:

https://i.ibb.co/xmL45Th/avsdocs.png

:thanks:

StainlessS
5th January 2022, 18:48
And thanking you RD, you're such a lil sweetie :)

EDIT:

colors_rgb = (r*65536) + (g * 256) + b
colors_yuv = (y*65536) + (u * 256) + v


alternative,

(r*256+g)*256+b
(y*256+u)*256+v