Advertisement
junh1024

HQDRing

Apr 14th, 2013
465
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Nagios 1.74 KB | None | 0 0
  1. function HQDering(clip input, int "strength", int "overall", int "supersampling", string "smoother", string "params") {
  2.  
  3.  strength = Default(strength, 255)  # strength, 0-255
  4.  overall  = Default(overall, 0)     # overall smoothing, 0-255
  5.  supersampling  = Default(supersampling, 5)     # overall smoothing, 1-5,was5
  6.  smoother = Default(smoother, "Deen")   # filter that smooths
  7. #params   = default defined below   # filter parameters - use Chr(34) for quotes
  8.  
  9. defaultnull = Default(params, "")
  10. defaultdeen = Default(params, Chr(34)+"a3d"+Chr(34)+", 2, 12, 15, 20")
  11.  
  12. params = (smoother=="Deen") ? defaultdeen : defaultnull
  13.  
  14. try {
  15. smoothedwparams = Eval(smoother + "(input, " + params + ")")
  16. }
  17. catch(err_msg) {
  18. smoothedwoparams = Eval(smoother + "(input)")
  19. }
  20.  
  21. smoothed = (params=="") ? smoothedwoparams : smoothedwparams
  22.  
  23. input.EdgeMask(0, 255, 255, 255, "line", Y=3, V=1, U=1)
  24. normalmask = last
  25.  
  26. normalmask.Levels(0, 3.3, 90, 0, 255).Blur(1.0)
  27. amplifiedmask = last.Levels(0, 3.3, 90, 0, 255).deflate.deflate
  28.  
  29. normalmask.inflate.inflate.inflate.Levels(0, 3.3, 90, 0, 255).Blur(1.0).inflate.inflate.inflate.Levels(0, 3.3, 255, 0, 255).inflate.inflate.mt_expand
  30. thickmask = last
  31.  
  32. overlay(amplifiedmask.invert, thickmask, mode="multiply")
  33.  
  34. Levels(60, 3.0, 140, overall, strength)
  35.  
  36. # maskedmerge causes aliasing, so supersample
  37. # spline36 causes slight ringing, so don’t do that
  38. ringingmask = last.spline16resize(last.width*supersampling,last.height*supersampling)
  39. input = input.spline16resize(last.width*supersampling,last.height*supersampling)
  40. smoothed = smoothed.spline16resize(last.width*supersampling,last.height*supersampling)
  41.  
  42. MaskedMerge(input, smoothed, ringingmask)
  43.  
  44. spline16resize(input.width/supersampling,input.height/supersampling)
  45.  
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement