Advertisement
tophf

t_colormask

May 8th, 2012
1,061
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Avisynth 29.87 KB | None | 0 0
  1. function t_colormask( clip c, int color, int "tolerance", int "expandblur", bool "BT601", int "blur")
  2. {
  3.     c.t_24colormask( color, \
  4.         tolerance=tolerance, expandblur=expandblur, BT601=BT601, blur=blur )
  5. }
  6.  
  7. function t_2colormask( clip c, int color1, int "color2", int "tolerance", int "expandblur", bool "BT601", int "blur")
  8. {
  9.     c.t_24colormask( color1, color2, \
  10.         tolerance=tolerance, expandblur=expandblur, BT601=BT601, blur=blur )
  11. }
  12.  
  13. function t_3colormask( clip c, int color1, int "color2", int "color3", int "tolerance", int "expandblur", bool "BT601", int "blur")
  14. {
  15.     c.t_24colormask( color1, color2, color3, \
  16.         tolerance=tolerance, expandblur=expandblur, BT601=BT601, blur=blur )
  17. }
  18.  
  19. function t_6colormask( clip c, int color1, int "color2", int "color3", int "color4", int "color5", int "color6", int "tolerance", int "expandblur", bool "BT601", int "blur")
  20. {
  21.     c.t_24colormask( color1, color2, color3, color4, color5, color6, \
  22.         tolerance=tolerance, expandblur=expandblur, BT601=BT601, blur=blur )
  23. }
  24.  
  25. function t_9colormask( clip c, int color1, int "color2", int "color3", int "color4", int "color5", int "color6", int "color7", int "color8", int "color9", int "tolerance", int "expandblur", bool "BT601", int "blur")
  26. {
  27.     c.t_24colormask( color1, color2, color3, color4, color5, color6, color7, color8, color9, \
  28.         tolerance=tolerance, expandblur=expandblur, BT601=BT601, blur=blur )
  29. }
  30.  
  31. function t_24colormask( clip c, int color1, int "color2", int "color3", int "color4", int "color5", int "color6", int "color7", int "color8", int "color9", int "color10", int "color11", int "color12", int "tolerance", int "expandblur", bool "BT601", int "blur")
  32. {
  33.     c.t_24colormask( color1, color2, color3, color4, color5, color6, \
  34.         color7, color8, color9, color10, color11, color12, \
  35.         tolerance=tolerance, expandblur=expandblur, BT601=BT601, blur=blur )
  36. }
  37.  
  38. function t_24colormask(clip c, int color1, int "color2", int "color3", int "color4", int "color5", int "color6", int "color7", int "color8", int "color9", int "color10", int "color11", int "color12", int "color12", int "color13", int "color14", int "color15", int "color16", int "color17", int "color18", int "color19", int "color20", int "color21", int "color22", int "color23", int "color24", int "tolerance", int "expandblur", bool "BT601", int "blur")
  39. {
  40.     color2 = default(color2,-1)
  41.     color3 = default(color3,-1)
  42.     color4 = default(color4,-1)
  43.     color5 = default(color5,-1)
  44.     color6 = default(color6,-1)
  45.     color7 = default(color7,-1)
  46.     color8 = default(color8,-1)
  47.     color9 = default(color9,-1)
  48.     color10 = default(color10,-1)
  49.     color11 = default(color11,-1)
  50.     color12 = default(color12,-1)
  51.     color13 = default(color13,-1)
  52.     color14 = default(color14,-1)
  53.     color15 = default(color15,-1)
  54.     color16 = default(color16,-1)
  55.     color17 = default(color17,-1)
  56.     color18 = default(color18,-1)
  57.     color19 = default(color19,-1)
  58.     color20 = default(color20,-1)
  59.     color21 = default(color21,-1)
  60.     color22 = default(color22,-1)
  61.     color23 = default(color23,-1)
  62.     color24 = default(color24,-1)
  63.  
  64.     tolerance = default(tolerance,10)
  65.     expandblur = default(expandblur,0)
  66.     BT601 = default(BT601, c.height <= 576 && c.width <= 1024)
  67.     blur = default(blur,0)
  68.  
  69.     kR = BT601 ? 0.299 : 0.2126
  70.     kB = BT601 ? 0.114 : 0.0722
  71.  
  72.     B1 = float(color1 % 256)/255
  73.     G1 = float((color1/256) % 256)/255
  74.     R1 = float((color1/65536) % 256)/255
  75.  
  76.     B2 = float(color2 % 256)/255
  77.     G2 = float((color2/256) % 256)/255
  78.     R2 = float((color2/65536) % 256)/255
  79.  
  80.     B3 = float(color3 % 256)/255
  81.     G3 = float((color3/256) % 256)/255
  82.     R3 = float((color3/65536) % 256)/255
  83.  
  84.     B4 = float(color4 % 256)/255
  85.     G4 = float((color4/256) % 256)/255
  86.     R4 = float((color4/65536) % 256)/255
  87.  
  88.     B5 = float(color5 % 256)/255
  89.     G5 = float((color5/256) % 256)/255
  90.     R5 = float((color5/65536) % 256)/255
  91.  
  92.     B6 = float(color6 % 256)/255
  93.     G6 = float((color6/256) % 256)/255
  94.     R6 = float((color6/65536) % 256)/255
  95.  
  96.     B7 = float(color7 % 256)/255
  97.     G7 = float((color7/256) % 256)/255
  98.     R7 = float((color7/65536) % 256)/255
  99.  
  100.     B8 = float(color8 % 256)/255
  101.     G8 = float((color8/256) % 256)/255
  102.     R8 = float((color8/65536) % 256)/255
  103.  
  104.     B9 = float(color9 % 256)/255
  105.     G9 = float((color9/256) % 256)/255
  106.     R9 = float((color9/65536) % 256)/255
  107.  
  108.     B10 = float(color10 % 256)/255
  109.     G10 = float((color10/256) % 256)/255
  110.     R10 = float((color10/65536) % 256)/255
  111.  
  112.     B11 = float(color11 % 256)/255
  113.     G11 = float((color11/256) % 256)/255
  114.     R11 = float((color11/65536) % 256)/255
  115.  
  116.     B12 = float(color12 % 256)/255
  117.     G12 = float((color12/256) % 256)/255
  118.     R12 = float((color12/65536) % 256)/255
  119.  
  120.     B13 = float(color13 % 256)/255
  121.     G13 = float((color13/256) % 256)/255
  122.     R13 = float((color13/65536) % 256)/255
  123.  
  124.     B14 = float(color14 % 256)/255
  125.     G14 = float((color14/256) % 256)/255
  126.     R14 = float((color14/65536) % 256)/255
  127.  
  128.     B15 = float(color15 % 256)/255
  129.     G15 = float((color15/256) % 256)/255
  130.     R15 = float((color15/65536) % 256)/255
  131.  
  132.     B16 = float(color16 % 256)/255
  133.     G16 = float((color16/256) % 256)/255
  134.     R16 = float((color16/65536) % 256)/255
  135.  
  136.     B17 = float(color17 % 256)/255
  137.     G17 = float((color17/256) % 256)/255
  138.     R17 = float((color17/65536) % 256)/255
  139.  
  140.     B18 = float(color18 % 256)/255
  141.     G18 = float((color18/256) % 256)/255
  142.     R18 = float((color18/65536) % 256)/255
  143.  
  144.     B19 = float(color19 % 256)/255
  145.     G19 = float((color19/256) % 256)/255
  146.     R19 = float((color19/65536) % 256)/255
  147.  
  148.     B20 = float(color20 % 256)/255
  149.     G20 = float((color20/256) % 256)/255
  150.     R20 = float((color20/65536) % 256)/255
  151.  
  152.     B21 = float(color21 % 256)/255
  153.     G21 = float((color21/256) % 256)/255
  154.     R21 = float((color21/65536) % 256)/255
  155.  
  156.     B22 = float(color22 % 256)/255
  157.     G22 = float((color22/256) % 256)/255
  158.     R22 = float((color22/65536) % 256)/255
  159.  
  160.     B23 = float(color23 % 256)/255
  161.     G23 = float((color23/256) % 256)/255
  162.     R23 = float((color23/65536) % 256)/255
  163.  
  164.     B24 = float(color24 % 256)/255
  165.     G24 = float((color24/256) % 256)/255
  166.     R24 = float((color24/65536) % 256)/255
  167.  
  168.     y1 = kR*R1+(1-kR-kB)*G1+kB*B1
  169.     u1 = 128+round(112.0*(B1-y1)/(1-kB))
  170.     v1 = 128+round(112.0*(R1-y1)/(1-kR))
  171.     y1 = 16+round(219.0*y1)
  172.  
  173.     y2 = kR*R2+(1-kR-kB)*G2+kB*B2
  174.     u2 = 128+round(112.0*(B2-y2)/(1-kB))
  175.     v2 = 128+round(112.0*(R2-y2)/(1-kR))
  176.     y2 = 16+round(219.0*y2)
  177.  
  178.     y3 = kR*R3+(1-kR-kB)*G3+kB*B3
  179.     u3 = 128+round(112.0*(B3-y3)/(1-kB))
  180.     v3 = 128+round(112.0*(R3-y3)/(1-kR))
  181.     y3 = 16+round(219.0*y3)
  182.  
  183.     y4 = kR*R4+(1-kR-kB)*G4+kB*B4
  184.     u4 = 128+round(112.0*(B4-y4)/(1-kB))
  185.     v4 = 128+round(112.0*(R4-y4)/(1-kR))
  186.     y4 = 16+round(219.0*y4)
  187.  
  188.     y5 = kR*R5+(1-kR-kB)*G5+kB*B5
  189.     u5 = 128+round(112.0*(B5-y5)/(1-kB))
  190.     v5 = 128+round(112.0*(R5-y5)/(1-kR))
  191.     y5 = 16+round(219.0*y5)
  192.  
  193.     y6 = kR*R6+(1-kR-kB)*G6+kB*B6
  194.     u6 = 128+round(112.0*(B6-y6)/(1-kB))
  195.     v6 = 128+round(112.0*(R6-y6)/(1-kR))
  196.     y6 = 16+round(219.0*y6)
  197.  
  198.     y7 = kR*R7+(1-kR-kB)*G7+kB*B7
  199.     u7 = 128+round(112.0*(B7-y7)/(1-kB))
  200.     v7 = 128+round(112.0*(R7-y7)/(1-kR))
  201.     y7 = 16+round(219.0*y7)
  202.  
  203.     y8 = kR*R8+(1-kR-kB)*G8+kB*B8
  204.     u8 = 128+round(112.0*(B8-y8)/(1-kB))
  205.     v8 = 128+round(112.0*(R8-y8)/(1-kR))
  206.     y8 = 16+round(219.0*y8)
  207.  
  208.     y9 = kR*R9+(1-kR-kB)*G9+kB*B9
  209.     u9 = 128+round(112.0*(B9-y9)/(1-kB))
  210.     v9 = 128+round(112.0*(R9-y9)/(1-kR))
  211.     y9 = 16+round(219.0*y9)
  212.  
  213.     y10 = kR*R10+(1-kR-kB)*G10+kB*B10
  214.     u10 = 128+round(112.0*(B10-y10)/(1-kB))
  215.     v10 = 128+round(112.0*(R10-y10)/(1-kR))
  216.     y10 = 16+round(219.0*y10)
  217.  
  218.     y11 = kR*R11+(1-kR-kB)*G11+kB*B11
  219.     u11 = 128+round(112.0*(B11-y11)/(1-kB))
  220.     v11 = 128+round(112.0*(R11-y11)/(1-kR))
  221.     y11 = 16+round(219.0*y11)
  222.  
  223.     y12 = kR*R12+(1-kR-kB)*G12+kB*B12
  224.     u12 = 128+round(112.0*(B12-y12)/(1-kB))
  225.     v12 = 128+round(112.0*(R12-y12)/(1-kR))
  226.     y12 = 16+round(219.0*y12)
  227.  
  228.     y13 = kR*R13+(1-kR-kB)*G13+kB*B13
  229.     u13 = 128+round(112.0*(B13-y13)/(1-kB))
  230.     v13 = 128+round(112.0*(R13-y13)/(1-kR))
  231.     y13 = 16+round(219.0*y13)
  232.  
  233.     y14 = kR*R14+(1-kR-kB)*G14+kB*B14
  234.     u14 = 128+round(112.0*(B14-y14)/(1-kB))
  235.     v14 = 128+round(112.0*(R14-y14)/(1-kR))
  236.     y14 = 16+round(219.0*y14)
  237.  
  238.     y15 = kR*R15+(1-kR-kB)*G15+kB*B15
  239.     u15 = 128+round(112.0*(B15-y15)/(1-kB))
  240.     v15 = 128+round(112.0*(R15-y15)/(1-kR))
  241.     y15 = 16+round(219.0*y15)
  242.  
  243.     y16 = kR*R16+(1-kR-kB)*G16+kB*B16
  244.     u16 = 128+round(112.0*(B16-y16)/(1-kB))
  245.     v16 = 128+round(112.0*(R16-y16)/(1-kR))
  246.     y16 = 16+round(219.0*y16)
  247.  
  248.     y17 = kR*R17+(1-kR-kB)*G17+kB*B17
  249.     u17 = 128+round(112.0*(B17-y17)/(1-kB))
  250.     v17 = 128+round(112.0*(R17-y17)/(1-kR))
  251.     y17 = 16+round(219.0*y17)
  252.  
  253.     y18 = kR*R18+(1-kR-kB)*G18+kB*B18
  254.     u18 = 128+round(112.0*(B18-y18)/(1-kB))
  255.     v18 = 128+round(112.0*(R18-y18)/(1-kR))
  256.     y18 = 16+round(219.0*y18)
  257.  
  258.     y19 = kR*R19+(1-kR-kB)*G19+kB*B19
  259.     u19 = 128+round(112.0*(B19-y19)/(1-kB))
  260.     v19 = 128+round(112.0*(R19-y19)/(1-kR))
  261.     y19 = 16+round(219.0*y19)
  262.  
  263.     y20 = kR*R20+(1-kR-kB)*G20+kB*B20
  264.     u20 = 128+round(112.0*(B20-y20)/(1-kB))
  265.     v20 = 128+round(112.0*(R20-y20)/(1-kR))
  266.     y20 = 16+round(219.0*y20)
  267.  
  268.     y21 = kR*R21+(1-kR-kB)*G21+kB*B21
  269.     u21 = 128+round(112.0*(B21-y21)/(1-kB))
  270.     v21 = 128+round(112.0*(R21-y21)/(1-kR))
  271.     y21 = 16+round(219.0*y21)
  272.  
  273.     y22 = kR*R22+(1-kR-kB)*G22+kB*B22
  274.     u22 = 128+round(112.0*(B22-y22)/(1-kB))
  275.     v22 = 128+round(112.0*(R22-y22)/(1-kR))
  276.     y22 = 16+round(219.0*y22)
  277.  
  278.     y23 = kR*R23+(1-kR-kB)*G23+kB*B23
  279.     u23 = 128+round(112.0*(B23-y23)/(1-kB))
  280.     v23 = 128+round(112.0*(R23-y23)/(1-kR))
  281.     y23 = 16+round(219.0*y23)
  282.  
  283.     y24 = kR*R24+(1-kR-kB)*G24+kB*B24
  284.     u24 = 128+round(112.0*(B24-y24)/(1-kB))
  285.     v24 = 128+round(112.0*(R24-y24)/(1-kR))
  286.     y24 = 16+round(219.0*y24)
  287.  
  288.     c.mt_lut(
  289.         \ yExpr = "x "+string(y1)+" - abs "+string(tolerance)+" < "+
  290.             \(color2!=-1 ? "x "+string(y2)+" - abs "+string(tolerance)+" < | " : "")+
  291.             \(color3!=-1 ? "x "+string(y3)+" - abs "+string(tolerance)+" < | " : "")+
  292.             \(color4!=-1 ? "x "+string(y4)+" - abs "+string(tolerance)+" < | " : "")+
  293.             \(color5!=-1 ? "x "+string(y5)+" - abs "+string(tolerance)+" < | " : "")+
  294.             \(color6!=-1 ? "x "+string(y6)+" - abs "+string(tolerance)+" < | " : "")+
  295.             \(color7!=-1 ? "x "+string(y7)+" - abs "+string(tolerance)+" < | " : "")+
  296.             \(color8!=-1 ? "x "+string(y8)+" - abs "+string(tolerance)+" < | " : "")+
  297.             \(color9!=-1 ? "x "+string(y9)+" - abs "+string(tolerance)+" < | " : "")+
  298.             \(color10!=-1 ? "x "+string(y10)+" - abs "+string(tolerance)+" < | " : "")+
  299.             \(color11!=-1 ? "x "+string(y11)+" - abs "+string(tolerance)+" < | " : "")+
  300.             \(color12!=-1 ? "x "+string(y12)+" - abs "+string(tolerance)+" < | " : "")+
  301.             \(color13!=-1 ? "x "+string(y13)+" - abs "+string(tolerance)+" < | " : "")+
  302.             \(color14!=-1 ? "x "+string(y14)+" - abs "+string(tolerance)+" < | " : "")+
  303.             \(color15!=-1 ? "x "+string(y15)+" - abs "+string(tolerance)+" < | " : "")+
  304.             \(color16!=-1 ? "x "+string(y16)+" - abs "+string(tolerance)+" < | " : "")+
  305.             \(color17!=-1 ? "x "+string(y17)+" - abs "+string(tolerance)+" < | " : "")+
  306.             \(color18!=-1 ? "x "+string(y18)+" - abs "+string(tolerance)+" < | " : "")+
  307.             \(color19!=-1 ? "x "+string(y19)+" - abs "+string(tolerance)+" < | " : "")+
  308.             \(color20!=-1 ? "x "+string(y20)+" - abs "+string(tolerance)+" < | " : "")+
  309.             \(color21!=-1 ? "x "+string(y21)+" - abs "+string(tolerance)+" < | " : "")+
  310.             \(color22!=-1 ? "x "+string(y22)+" - abs "+string(tolerance)+" < | " : "")+
  311.             \(color23!=-1 ? "x "+string(y23)+" - abs "+string(tolerance)+" < | " : "")+
  312.             \(color24!=-1 ? "x "+string(y24)+" - abs "+string(tolerance)+" < | " : "")+"255 0 ?",
  313.         \ uExpr = "x "+string(u1)+" - abs "+string(tolerance/2)+" < "+
  314.             \(color2!=-1 ? "x "+string(u2)+" - abs "+string(tolerance/2)+" < | " : "")+
  315.             \(color3!=-1 ? "x "+string(u3)+" - abs "+string(tolerance/2)+" < | " : "")+
  316.             \(color4!=-1 ? "x "+string(u4)+" - abs "+string(tolerance/2)+" < | " : "")+
  317.             \(color5!=-1 ? "x "+string(u5)+" - abs "+string(tolerance/2)+" < | " : "")+
  318.             \(color6!=-1 ? "x "+string(u6)+" - abs "+string(tolerance/2)+" < | " : "")+
  319.             \(color7!=-1 ? "x "+string(u7)+" - abs "+string(tolerance/2)+" < | " : "")+
  320.             \(color8!=-1 ? "x "+string(u8)+" - abs "+string(tolerance/2)+" < | " : "")+
  321.             \(color9!=-1 ? "x "+string(u9)+" - abs "+string(tolerance/2)+" < | " : "")+
  322.             \(color10!=-1 ? "x "+string(u10)+" - abs "+string(tolerance/2)+" < | " : "")+
  323.             \(color11!=-1 ? "x "+string(u11)+" - abs "+string(tolerance/2)+" < | " : "")+
  324.             \(color12!=-1 ? "x "+string(u12)+" - abs "+string(tolerance/2)+" < | " : "")+
  325.             \(color13!=-1 ? "x "+string(u13)+" - abs "+string(tolerance/2)+" < | " : "")+
  326.             \(color14!=-1 ? "x "+string(u14)+" - abs "+string(tolerance/2)+" < | " : "")+
  327.             \(color15!=-1 ? "x "+string(u15)+" - abs "+string(tolerance/2)+" < | " : "")+
  328.             \(color16!=-1 ? "x "+string(u16)+" - abs "+string(tolerance/2)+" < | " : "")+
  329.             \(color17!=-1 ? "x "+string(u17)+" - abs "+string(tolerance/2)+" < | " : "")+
  330.             \(color18!=-1 ? "x "+string(u18)+" - abs "+string(tolerance/2)+" < | " : "")+
  331.             \(color19!=-1 ? "x "+string(u19)+" - abs "+string(tolerance/2)+" < | " : "")+
  332.             \(color20!=-1 ? "x "+string(u20)+" - abs "+string(tolerance/2)+" < | " : "")+
  333.             \(color21!=-1 ? "x "+string(u21)+" - abs "+string(tolerance/2)+" < | " : "")+
  334.             \(color22!=-1 ? "x "+string(u22)+" - abs "+string(tolerance/2)+" < | " : "")+
  335.             \(color23!=-1 ? "x "+string(u23)+" - abs "+string(tolerance/2)+" < | " : "")+
  336.             \(color24!=-1 ? "x "+string(u24)+" - abs "+string(tolerance/2)+" < | " : "")+"255 0 ?",
  337.         \ vExpr = "x "+string(v1)+" - abs "+string(tolerance/2)+" < "+
  338.             \(color2!=-1 ? "x "+string(v2)+" - abs "+string(tolerance/2)+" < | " : "")+
  339.             \(color3!=-1 ? "x "+string(v3)+" - abs "+string(tolerance/2)+" < | " : "")+
  340.             \(color4!=-1 ? "x "+string(v4)+" - abs "+string(tolerance/2)+" < | " : "")+
  341.             \(color5!=-1 ? "x "+string(v5)+" - abs "+string(tolerance/2)+" < | " : "")+
  342.             \(color6!=-1 ? "x "+string(v6)+" - abs "+string(tolerance/2)+" < | " : "")+
  343.             \(color7!=-1 ? "x "+string(v7)+" - abs "+string(tolerance/2)+" < | " : "")+
  344.             \(color8!=-1 ? "x "+string(v8)+" - abs "+string(tolerance/2)+" < | " : "")+
  345.             \(color9!=-1 ? "x "+string(v9)+" - abs "+string(tolerance/2)+" < | " : "")+
  346.             \(color10!=-1 ? "x "+string(v10)+" - abs "+string(tolerance/2)+" < | " : "")+
  347.             \(color11!=-1 ? "x "+string(v11)+" - abs "+string(tolerance/2)+" < | " : "")+
  348.             \(color12!=-1 ? "x "+string(v12)+" - abs "+string(tolerance/2)+" < | " : "")+
  349.             \(color13!=-1 ? "x "+string(v13)+" - abs "+string(tolerance/2)+" < | " : "")+
  350.             \(color14!=-1 ? "x "+string(v14)+" - abs "+string(tolerance/2)+" < | " : "")+
  351.             \(color15!=-1 ? "x "+string(v15)+" - abs "+string(tolerance/2)+" < | " : "")+
  352.             \(color16!=-1 ? "x "+string(v16)+" - abs "+string(tolerance/2)+" < | " : "")+
  353.             \(color17!=-1 ? "x "+string(v17)+" - abs "+string(tolerance/2)+" < | " : "")+
  354.             \(color18!=-1 ? "x "+string(v18)+" - abs "+string(tolerance/2)+" < | " : "")+
  355.             \(color19!=-1 ? "x "+string(v19)+" - abs "+string(tolerance/2)+" < | " : "")+
  356.             \(color20!=-1 ? "x "+string(v20)+" - abs "+string(tolerance/2)+" < | " : "")+
  357.             \(color21!=-1 ? "x "+string(v21)+" - abs "+string(tolerance/2)+" < | " : "")+
  358.             \(color22!=-1 ? "x "+string(v22)+" - abs "+string(tolerance/2)+" < | " : "")+
  359.             \(color23!=-1 ? "x "+string(v23)+" - abs "+string(tolerance/2)+" < | " : "")+
  360.             \(color24!=-1 ? "x "+string(v24)+" - abs "+string(tolerance/2)+" < | " : "")+"255 0 ?",u=3,v=3)
  361.     mt_logic(mt_logic(utoy,vtoy,"min").bicubicresize(width,height),"min")
  362.     expandblur>0 ? binomialblur(expandblur,u=1,v=1).mt_lut("x 5 *") : last
  363.     blur>0 ? binomialblur(blur,u=1,v=1) : last
  364. }
  365.  
  366. function t_24colormask2( clip c, \
  367.     int color1, int "tolerance1", int "color2", int "tolerance2", int "color3", int "tolerance3", int "color4", int "tolerance4", int "color5", int "tolerance5", int "color6", int "tolerance6", int "color7", int "tolerance7", int "color8", int "tolerance8", int "color9", int "tolerance9", int "color10", int "tolerance10", int "color11", int "tolerance11", int "color12", int "tolerance12", int "color12", int "tolerance12", int "color13", int "tolerance13", int "color14", int "tolerance14", int "color15", int "tolerance15", int "color16", int "tolerance16", int "color17", int "tolerance17", int "color18", int "tolerance18", int "color19", int "tolerance19", int "color20", int "tolerance20", int "color21", int "tolerance21", int "color22", int "tolerance22", int "color23", int "tolerance23", int "color24", int "tolerance24", \
  368.     int "expandblur", bool "BT601", int "blur" )
  369. {
  370.     color2 = default(color2,-1)
  371.     color3 = default(color3,-1)
  372.     color4 = default(color4,-1)
  373.     color5 = default(color5,-1)
  374.     color6 = default(color6,-1)
  375.     color7 = default(color7,-1)
  376.     color8 = default(color8,-1)
  377.     color9 = default(color9,-1)
  378.     color10 = default(color10,-1)
  379.     color11 = default(color11,-1)
  380.     color12 = default(color12,-1)
  381.     color13 = default(color13,-1)
  382.     color14 = default(color14,-1)
  383.     color15 = default(color15,-1)
  384.     color16 = default(color16,-1)
  385.     color17 = default(color17,-1)
  386.     color18 = default(color18,-1)
  387.     color19 = default(color19,-1)
  388.     color20 = default(color20,-1)
  389.     color21 = default(color21,-1)
  390.     color22 = default(color22,-1)
  391.     color23 = default(color23,-1)
  392.     color24 = default(color24,-1)
  393.  
  394.     tolerance1 = default(tolerance1,10)
  395.     tolerance2 = default(tolerance2,10)
  396.     tolerance3 = default(tolerance3,10)
  397.     tolerance4 = default(tolerance4,10)
  398.     tolerance5 = default(tolerance5,10)
  399.     tolerance6 = default(tolerance6,10)
  400.     tolerance7 = default(tolerance7,10)
  401.     tolerance8 = default(tolerance8,10)
  402.     tolerance9 = default(tolerance9,10)
  403.     tolerance10 = default(tolerance10,10)
  404.     tolerance11 = default(tolerance11,10)
  405.     tolerance12 = default(tolerance12,10)
  406.     tolerance13 = default(tolerance13,10)
  407.     tolerance14 = default(tolerance14,10)
  408.     tolerance15 = default(tolerance15,10)
  409.     tolerance16 = default(tolerance16,10)
  410.     tolerance17 = default(tolerance17,10)
  411.     tolerance18 = default(tolerance18,10)
  412.     tolerance19 = default(tolerance19,10)
  413.     tolerance20 = default(tolerance20,10)
  414.     tolerance21 = default(tolerance21,10)
  415.     tolerance22 = default(tolerance22,10)
  416.     tolerance23 = default(tolerance23,10)
  417.     tolerance24 = default(tolerance24,10)
  418.  
  419.     expandblur = default(expandblur,0)
  420.     BT601 = default(BT601, c.height <= 576 && c.width <= 1024)
  421.     blur = default(blur,0)
  422.  
  423.     kR = BT601 ? 0.299 : 0.2126
  424.     kB = BT601 ? 0.114 : 0.0722
  425.  
  426.     B1 = float(color1 % 256)/255
  427.     G1 = float((color1/256) % 256)/255
  428.     R1 = float((color1/65536) % 256)/255
  429.  
  430.     B2 = float(color2 % 256)/255
  431.     G2 = float((color2/256) % 256)/255
  432.     R2 = float((color2/65536) % 256)/255
  433.  
  434.     B3 = float(color3 % 256)/255
  435.     G3 = float((color3/256) % 256)/255
  436.     R3 = float((color3/65536) % 256)/255
  437.  
  438.     B4 = float(color4 % 256)/255
  439.     G4 = float((color4/256) % 256)/255
  440.     R4 = float((color4/65536) % 256)/255
  441.  
  442.     B5 = float(color5 % 256)/255
  443.     G5 = float((color5/256) % 256)/255
  444.     R5 = float((color5/65536) % 256)/255
  445.  
  446.     B6 = float(color6 % 256)/255
  447.     G6 = float((color6/256) % 256)/255
  448.     R6 = float((color6/65536) % 256)/255
  449.  
  450.     B7 = float(color7 % 256)/255
  451.     G7 = float((color7/256) % 256)/255
  452.     R7 = float((color7/65536) % 256)/255
  453.  
  454.     B8 = float(color8 % 256)/255
  455.     G8 = float((color8/256) % 256)/255
  456.     R8 = float((color8/65536) % 256)/255
  457.  
  458.     B9 = float(color9 % 256)/255
  459.     G9 = float((color9/256) % 256)/255
  460.     R9 = float((color9/65536) % 256)/255
  461.  
  462.     B10 = float(color10 % 256)/255
  463.     G10 = float((color10/256) % 256)/255
  464.     R10 = float((color10/65536) % 256)/255
  465.  
  466.     B11 = float(color11 % 256)/255
  467.     G11 = float((color11/256) % 256)/255
  468.     R11 = float((color11/65536) % 256)/255
  469.  
  470.     B12 = float(color12 % 256)/255
  471.     G12 = float((color12/256) % 256)/255
  472.     R12 = float((color12/65536) % 256)/255
  473.  
  474.     B13 = float(color13 % 256)/255
  475.     G13 = float((color13/256) % 256)/255
  476.     R13 = float((color13/65536) % 256)/255
  477.  
  478.     B14 = float(color14 % 256)/255
  479.     G14 = float((color14/256) % 256)/255
  480.     R14 = float((color14/65536) % 256)/255
  481.  
  482.     B15 = float(color15 % 256)/255
  483.     G15 = float((color15/256) % 256)/255
  484.     R15 = float((color15/65536) % 256)/255
  485.  
  486.     B16 = float(color16 % 256)/255
  487.     G16 = float((color16/256) % 256)/255
  488.     R16 = float((color16/65536) % 256)/255
  489.  
  490.     B17 = float(color17 % 256)/255
  491.     G17 = float((color17/256) % 256)/255
  492.     R17 = float((color17/65536) % 256)/255
  493.  
  494.     B18 = float(color18 % 256)/255
  495.     G18 = float((color18/256) % 256)/255
  496.     R18 = float((color18/65536) % 256)/255
  497.  
  498.     B19 = float(color19 % 256)/255
  499.     G19 = float((color19/256) % 256)/255
  500.     R19 = float((color19/65536) % 256)/255
  501.  
  502.     B20 = float(color20 % 256)/255
  503.     G20 = float((color20/256) % 256)/255
  504.     R20 = float((color20/65536) % 256)/255
  505.  
  506.     B21 = float(color21 % 256)/255
  507.     G21 = float((color21/256) % 256)/255
  508.     R21 = float((color21/65536) % 256)/255
  509.  
  510.     B22 = float(color22 % 256)/255
  511.     G22 = float((color22/256) % 256)/255
  512.     R22 = float((color22/65536) % 256)/255
  513.  
  514.     B23 = float(color23 % 256)/255
  515.     G23 = float((color23/256) % 256)/255
  516.     R23 = float((color23/65536) % 256)/255
  517.  
  518.     B24 = float(color24 % 256)/255
  519.     G24 = float((color24/256) % 256)/255
  520.     R24 = float((color24/65536) % 256)/255
  521.  
  522.     y1 = kR*R1+(1-kR-kB)*G1+kB*B1
  523.     u1 = 128+round(112.0*(B1-y1)/(1-kB))
  524.     v1 = 128+round(112.0*(R1-y1)/(1-kR))
  525.     y1 = 16+round(219.0*y1)
  526.  
  527.     y2 = kR*R2+(1-kR-kB)*G2+kB*B2
  528.     u2 = 128+round(112.0*(B2-y2)/(1-kB))
  529.     v2 = 128+round(112.0*(R2-y2)/(1-kR))
  530.     y2 = 16+round(219.0*y2)
  531.  
  532.     y3 = kR*R3+(1-kR-kB)*G3+kB*B3
  533.     u3 = 128+round(112.0*(B3-y3)/(1-kB))
  534.     v3 = 128+round(112.0*(R3-y3)/(1-kR))
  535.     y3 = 16+round(219.0*y3)
  536.  
  537.     y4 = kR*R4+(1-kR-kB)*G4+kB*B4
  538.     u4 = 128+round(112.0*(B4-y4)/(1-kB))
  539.     v4 = 128+round(112.0*(R4-y4)/(1-kR))
  540.     y4 = 16+round(219.0*y4)
  541.  
  542.     y5 = kR*R5+(1-kR-kB)*G5+kB*B5
  543.     u5 = 128+round(112.0*(B5-y5)/(1-kB))
  544.     v5 = 128+round(112.0*(R5-y5)/(1-kR))
  545.     y5 = 16+round(219.0*y5)
  546.  
  547.     y6 = kR*R6+(1-kR-kB)*G6+kB*B6
  548.     u6 = 128+round(112.0*(B6-y6)/(1-kB))
  549.     v6 = 128+round(112.0*(R6-y6)/(1-kR))
  550.     y6 = 16+round(219.0*y6)
  551.  
  552.     y7 = kR*R7+(1-kR-kB)*G7+kB*B7
  553.     u7 = 128+round(112.0*(B7-y7)/(1-kB))
  554.     v7 = 128+round(112.0*(R7-y7)/(1-kR))
  555.     y7 = 16+round(219.0*y7)
  556.  
  557.     y8 = kR*R8+(1-kR-kB)*G8+kB*B8
  558.     u8 = 128+round(112.0*(B8-y8)/(1-kB))
  559.     v8 = 128+round(112.0*(R8-y8)/(1-kR))
  560.     y8 = 16+round(219.0*y8)
  561.  
  562.     y9 = kR*R9+(1-kR-kB)*G9+kB*B9
  563.     u9 = 128+round(112.0*(B9-y9)/(1-kB))
  564.     v9 = 128+round(112.0*(R9-y9)/(1-kR))
  565.     y9 = 16+round(219.0*y9)
  566.  
  567.     y10 = kR*R10+(1-kR-kB)*G10+kB*B10
  568.     u10 = 128+round(112.0*(B10-y10)/(1-kB))
  569.     v10 = 128+round(112.0*(R10-y10)/(1-kR))
  570.     y10 = 16+round(219.0*y10)
  571.  
  572.     y11 = kR*R11+(1-kR-kB)*G11+kB*B11
  573.     u11 = 128+round(112.0*(B11-y11)/(1-kB))
  574.     v11 = 128+round(112.0*(R11-y11)/(1-kR))
  575.     y11 = 16+round(219.0*y11)
  576.  
  577.     y12 = kR*R12+(1-kR-kB)*G12+kB*B12
  578.     u12 = 128+round(112.0*(B12-y12)/(1-kB))
  579.     v12 = 128+round(112.0*(R12-y12)/(1-kR))
  580.     y12 = 16+round(219.0*y12)
  581.  
  582.     y13 = kR*R13+(1-kR-kB)*G13+kB*B13
  583.     u13 = 128+round(112.0*(B13-y13)/(1-kB))
  584.     v13 = 128+round(112.0*(R13-y13)/(1-kR))
  585.     y13 = 16+round(219.0*y13)
  586.  
  587.     y14 = kR*R14+(1-kR-kB)*G14+kB*B14
  588.     u14 = 128+round(112.0*(B14-y14)/(1-kB))
  589.     v14 = 128+round(112.0*(R14-y14)/(1-kR))
  590.     y14 = 16+round(219.0*y14)
  591.  
  592.     y15 = kR*R15+(1-kR-kB)*G15+kB*B15
  593.     u15 = 128+round(112.0*(B15-y15)/(1-kB))
  594.     v15 = 128+round(112.0*(R15-y15)/(1-kR))
  595.     y15 = 16+round(219.0*y15)
  596.  
  597.     y16 = kR*R16+(1-kR-kB)*G16+kB*B16
  598.     u16 = 128+round(112.0*(B16-y16)/(1-kB))
  599.     v16 = 128+round(112.0*(R16-y16)/(1-kR))
  600.     y16 = 16+round(219.0*y16)
  601.  
  602.     y17 = kR*R17+(1-kR-kB)*G17+kB*B17
  603.     u17 = 128+round(112.0*(B17-y17)/(1-kB))
  604.     v17 = 128+round(112.0*(R17-y17)/(1-kR))
  605.     y17 = 16+round(219.0*y17)
  606.  
  607.     y18 = kR*R18+(1-kR-kB)*G18+kB*B18
  608.     u18 = 128+round(112.0*(B18-y18)/(1-kB))
  609.     v18 = 128+round(112.0*(R18-y18)/(1-kR))
  610.     y18 = 16+round(219.0*y18)
  611.  
  612.     y19 = kR*R19+(1-kR-kB)*G19+kB*B19
  613.     u19 = 128+round(112.0*(B19-y19)/(1-kB))
  614.     v19 = 128+round(112.0*(R19-y19)/(1-kR))
  615.     y19 = 16+round(219.0*y19)
  616.  
  617.     y20 = kR*R20+(1-kR-kB)*G20+kB*B20
  618.     u20 = 128+round(112.0*(B20-y20)/(1-kB))
  619.     v20 = 128+round(112.0*(R20-y20)/(1-kR))
  620.     y20 = 16+round(219.0*y20)
  621.  
  622.     y21 = kR*R21+(1-kR-kB)*G21+kB*B21
  623.     u21 = 128+round(112.0*(B21-y21)/(1-kB))
  624.     v21 = 128+round(112.0*(R21-y21)/(1-kR))
  625.     y21 = 16+round(219.0*y21)
  626.  
  627.     y22 = kR*R22+(1-kR-kB)*G22+kB*B22
  628.     u22 = 128+round(112.0*(B22-y22)/(1-kB))
  629.     v22 = 128+round(112.0*(R22-y22)/(1-kR))
  630.     y22 = 16+round(219.0*y22)
  631.  
  632.     y23 = kR*R23+(1-kR-kB)*G23+kB*B23
  633.     u23 = 128+round(112.0*(B23-y23)/(1-kB))
  634.     v23 = 128+round(112.0*(R23-y23)/(1-kR))
  635.     y23 = 16+round(219.0*y23)
  636.  
  637.     y24 = kR*R24+(1-kR-kB)*G24+kB*B24
  638.     u24 = 128+round(112.0*(B24-y24)/(1-kB))
  639.     v24 = 128+round(112.0*(R24-y24)/(1-kR))
  640.     y24 = 16+round(219.0*y24)
  641.  
  642.     c.mt_lut(
  643.         \ yExpr = "x "+string(y1)+" - abs "+string(tolerance1)+" < "+
  644.             \(color2!=-1 ? "x "+string(y2)+" - abs "+string(tolerance2)+" < | " : "")+
  645.             \(color3!=-1 ? "x "+string(y3)+" - abs "+string(tolerance3)+" < | " : "")+
  646.             \(color4!=-1 ? "x "+string(y4)+" - abs "+string(tolerance4)+" < | " : "")+
  647.             \(color5!=-1 ? "x "+string(y5)+" - abs "+string(tolerance5)+" < | " : "")+
  648.             \(color6!=-1 ? "x "+string(y6)+" - abs "+string(tolerance6)+" < | " : "")+
  649.             \(color7!=-1 ? "x "+string(y7)+" - abs "+string(tolerance7)+" < | " : "")+
  650.             \(color8!=-1 ? "x "+string(y8)+" - abs "+string(tolerance8)+" < | " : "")+
  651.             \(color9!=-1 ? "x "+string(y9)+" - abs "+string(tolerance9)+" < | " : "")+
  652.             \(color10!=-1 ? "x "+string(y10)+" - abs "+string(tolerance10)+" < | " : "")+
  653.             \(color11!=-1 ? "x "+string(y11)+" - abs "+string(tolerance11)+" < | " : "")+
  654.             \(color12!=-1 ? "x "+string(y12)+" - abs "+string(tolerance12)+" < | " : "")+
  655.             \(color13!=-1 ? "x "+string(y13)+" - abs "+string(tolerance13)+" < | " : "")+
  656.             \(color14!=-1 ? "x "+string(y14)+" - abs "+string(tolerance14)+" < | " : "")+
  657.             \(color15!=-1 ? "x "+string(y15)+" - abs "+string(tolerance15)+" < | " : "")+
  658.             \(color16!=-1 ? "x "+string(y16)+" - abs "+string(tolerance16)+" < | " : "")+
  659.             \(color17!=-1 ? "x "+string(y17)+" - abs "+string(tolerance17)+" < | " : "")+
  660.             \(color18!=-1 ? "x "+string(y18)+" - abs "+string(tolerance18)+" < | " : "")+
  661.             \(color19!=-1 ? "x "+string(y19)+" - abs "+string(tolerance19)+" < | " : "")+
  662.             \(color20!=-1 ? "x "+string(y20)+" - abs "+string(tolerance20)+" < | " : "")+
  663.             \(color21!=-1 ? "x "+string(y21)+" - abs "+string(tolerance21)+" < | " : "")+
  664.             \(color22!=-1 ? "x "+string(y22)+" - abs "+string(tolerance22)+" < | " : "")+
  665.             \(color23!=-1 ? "x "+string(y23)+" - abs "+string(tolerance23)+" < | " : "")+
  666.             \(color24!=-1 ? "x "+string(y24)+" - abs "+string(tolerance24)+" < | " : "")+"255 0 ?",
  667.         \ uExpr = "x "+string(u1)+" - abs "+string(tolerance1/2)+" < "+
  668.             \(color2!=-1 ? "x "+string(u2)+" - abs "+string(tolerance2/2)+" < | " : "")+
  669.             \(color3!=-1 ? "x "+string(u3)+" - abs "+string(tolerance3/2)+" < | " : "")+
  670.             \(color4!=-1 ? "x "+string(u4)+" - abs "+string(tolerance4/2)+" < | " : "")+
  671.             \(color5!=-1 ? "x "+string(u5)+" - abs "+string(tolerance5/2)+" < | " : "")+
  672.             \(color6!=-1 ? "x "+string(u6)+" - abs "+string(tolerance6/2)+" < | " : "")+
  673.             \(color7!=-1 ? "x "+string(u7)+" - abs "+string(tolerance7/2)+" < | " : "")+
  674.             \(color8!=-1 ? "x "+string(u8)+" - abs "+string(tolerance8/2)+" < | " : "")+
  675.             \(color9!=-1 ? "x "+string(u9)+" - abs "+string(tolerance9/2)+" < | " : "")+
  676.             \(color10!=-1 ? "x "+string(u10)+" - abs "+string(tolerance10/2)+" < | " : "")+
  677.             \(color11!=-1 ? "x "+string(u11)+" - abs "+string(tolerance11/2)+" < | " : "")+
  678.             \(color12!=-1 ? "x "+string(u12)+" - abs "+string(tolerance12/2)+" < | " : "")+
  679.             \(color13!=-1 ? "x "+string(u13)+" - abs "+string(tolerance13/2)+" < | " : "")+
  680.             \(color14!=-1 ? "x "+string(u14)+" - abs "+string(tolerance14/2)+" < | " : "")+
  681.             \(color15!=-1 ? "x "+string(u15)+" - abs "+string(tolerance15/2)+" < | " : "")+
  682.             \(color16!=-1 ? "x "+string(u16)+" - abs "+string(tolerance16/2)+" < | " : "")+
  683.             \(color17!=-1 ? "x "+string(u17)+" - abs "+string(tolerance17/2)+" < | " : "")+
  684.             \(color18!=-1 ? "x "+string(u18)+" - abs "+string(tolerance18/2)+" < | " : "")+
  685.             \(color19!=-1 ? "x "+string(u19)+" - abs "+string(tolerance19/2)+" < | " : "")+
  686.             \(color20!=-1 ? "x "+string(u20)+" - abs "+string(tolerance20/2)+" < | " : "")+
  687.             \(color21!=-1 ? "x "+string(u21)+" - abs "+string(tolerance21/2)+" < | " : "")+
  688.             \(color22!=-1 ? "x "+string(u22)+" - abs "+string(tolerance22/2)+" < | " : "")+
  689.             \(color23!=-1 ? "x "+string(u23)+" - abs "+string(tolerance23/2)+" < | " : "")+
  690.             \(color24!=-1 ? "x "+string(u24)+" - abs "+string(tolerance24/2)+" < | " : "")+"255 0 ?",
  691.         \ vExpr = "x "+string(v1)+" - abs "+string(tolerance1/2)+" < "+
  692.             \(color2!=-1 ? "x "+string(v2)+" - abs "+string(tolerance2/2)+" < | " : "")+
  693.             \(color3!=-1 ? "x "+string(v3)+" - abs "+string(tolerance3/2)+" < | " : "")+
  694.             \(color4!=-1 ? "x "+string(v4)+" - abs "+string(tolerance4/2)+" < | " : "")+
  695.             \(color5!=-1 ? "x "+string(v5)+" - abs "+string(tolerance5/2)+" < | " : "")+
  696.             \(color6!=-1 ? "x "+string(v6)+" - abs "+string(tolerance6/2)+" < | " : "")+
  697.             \(color7!=-1 ? "x "+string(v7)+" - abs "+string(tolerance7/2)+" < | " : "")+
  698.             \(color8!=-1 ? "x "+string(v8)+" - abs "+string(tolerance8/2)+" < | " : "")+
  699.             \(color9!=-1 ? "x "+string(v9)+" - abs "+string(tolerance9/2)+" < | " : "")+
  700.             \(color10!=-1 ? "x "+string(v10)+" - abs "+string(tolerance10/2)+" < | " : "")+
  701.             \(color11!=-1 ? "x "+string(v11)+" - abs "+string(tolerance11/2)+" < | " : "")+
  702.             \(color12!=-1 ? "x "+string(v12)+" - abs "+string(tolerance12/2)+" < | " : "")+
  703.             \(color13!=-1 ? "x "+string(v13)+" - abs "+string(tolerance13/2)+" < | " : "")+
  704.             \(color14!=-1 ? "x "+string(v14)+" - abs "+string(tolerance14/2)+" < | " : "")+
  705.             \(color15!=-1 ? "x "+string(v15)+" - abs "+string(tolerance15/2)+" < | " : "")+
  706.             \(color16!=-1 ? "x "+string(v16)+" - abs "+string(tolerance16/2)+" < | " : "")+
  707.             \(color17!=-1 ? "x "+string(v17)+" - abs "+string(tolerance17/2)+" < | " : "")+
  708.             \(color18!=-1 ? "x "+string(v18)+" - abs "+string(tolerance18/2)+" < | " : "")+
  709.             \(color19!=-1 ? "x "+string(v19)+" - abs "+string(tolerance19/2)+" < | " : "")+
  710.             \(color20!=-1 ? "x "+string(v20)+" - abs "+string(tolerance20/2)+" < | " : "")+
  711.             \(color21!=-1 ? "x "+string(v21)+" - abs "+string(tolerance21/2)+" < | " : "")+
  712.             \(color22!=-1 ? "x "+string(v22)+" - abs "+string(tolerance22/2)+" < | " : "")+
  713.             \(color23!=-1 ? "x "+string(v23)+" - abs "+string(tolerance23/2)+" < | " : "")+
  714.             \(color24!=-1 ? "x "+string(v24)+" - abs "+string(tolerance24/2)+" < | " : "")+"255 0 ?",u=3,v=3)
  715.     mt_logic(mt_logic(utoy,vtoy,"min").bicubicresize(width,height),"min")
  716.     expandblur>0 ? binomialblur(expandblur,u=1,v=1).mt_lut("x 5 *") : last
  717.     blur>0 ? binomialblur(blur,u=1,v=1) : last
  718. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement