Advertisement
Guest User

Untitled

a guest
Jul 28th, 2024
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.13 KB | None | 0 0
  1. # proToon v0.75.1
  2. # used to be known as vmToon and before that mftoon
  3. # v0.75.1 fixed bug in thinning call (Selur) + code indention
  4. # v0.75 made by TheProfileth mainly optimizations and code restructuring
  5.  
  6. function mf_min(string a, string b) {
  7. return a + " " + b + " < " + a + " " + b + " ?"
  8. }
  9.  
  10. function mf_max(string a, string b) {
  11. return a + " " + b + " > " + a + " " + b + " ?"
  12. }
  13.  
  14. function mf_str_level(string x, int in_low, int in_high, int out_low, int out_high) {
  15. return mf_max(mf_min(x + " 16 - 255 * 219 / " + string(in_low) + " - " + string(in_high - in_low) + " / " + string(out_high - out_low) + " * " + string(out_low) + " + 219 * 255 / 16 +", "235"), "16")
  16. }
  17.  
  18. function proToon(clip input, int "strength", int "luma_cap", int "threshold", int "thinning", bool "sharpen", bool "mask", bool "show", string "showclip", int "ssw", int "ssh", int "xstren", int "xthresh") {
  19.  
  20. # vectrangle's stuff
  21.  
  22. str = String(Default(strength, 48) / 128.0) # line darkening amount, 0-255
  23. lum = String(Default(luma_cap, 191)) # bright limit for line detection, 0-255 (255 = no limit)
  24. thr = String(Default(threshold, 4)) # threshold to disable slight darkening (of noise) 0-255
  25. thinning = Default(thinning, 0) # line thinning amount, 0-255
  26. thn = String(Default(thinning, 0) / 16.0) # Line thinning value as a float
  27.  
  28. # mf's stuff
  29.  
  30. sharpen = Default(sharpen, true) # sharpening on/off
  31. mask = Default(mask, true) # masking on/off
  32. show = Default(show, false) # show the mask if true
  33. ssw = Default(ssw, 4) # supersample factor horizontally, 0-inf
  34. ssh = Default(ssh, 4) # supersample factor vertically, 0-inf
  35. xstren = Default(xstren, 255) # xsharpening strength, 0-255
  36. xthresh = Default(xthresh, 255) # xsharpening threshold, 0-255
  37.  
  38. width = input.width()
  39. height = input.height()
  40. edgemask = mt_lutxy(input, input.removegrain(12, -1), mf_str_level("x y - abs 128 +", 132, 145, 0, 255), y=3, u=1, v=1).removegrain(12, -1).mt_lut(mf_str_level("x", 0, 64, 0, 255), y=3)
  41.  
  42. exin = input.mt_Expand().mt_Inpand()
  43. diff = mt_lutxy(input, exin, "y " + lum + " < y " + lum + " ? x " + thr + " + > x y " + lum + " < y " + lum + " ? - 0 ? 127 +")
  44. thick = mt_lutxy(input, exin, "y " + lum + " < y " + lum + " ? x " + thr + " + > x y " + lum + " < y " + lum + " ? - 0 ? " + str + " * x +")
  45.  
  46. darkened = (thinning == 0) ? thick : mt_merge(mt_lutxy(input.mt_Expand(), diff, "x y 127 - " + str + " 1 + * +"), thick, mt_lutxy(diff.mt_Inpand(), input, "x 127 - " + thn + " * 255 +").mt_Convolution("1 1 1", "1 1 1", Y=3), Y=3, U=1, V=1)
  47.  
  48. masked = (mask == true) ? mt_merge(input, darkened, edgemask, Y=3, U=2, V=2) : mergechroma(darkened, input)
  49.  
  50. sharpened = (sharpen == true) ? masked.LanczosResize(width * ssw, height * ssh).XSharpen(xstren, xthresh).LanczosResize(width, height) : masked
  51.  
  52. output = sharpened
  53. final = (show == true) ? MergeChroma(Overlay(input, BlankClip(input, color=$00FF00), mask=edgemask)) : output
  54. return(final)
  55. }
  56.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement