Advertisement
Guest User

AntiAliasRG (Oldie)

a guest
Oct 7th, 2011
574
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function AntiAliasRG(clip orig,float "sx", float "sy",string "mode",int "thrl",int "thrc",float "sharpness") {
  2.  
  3. # Fast, dull antialiasing using RemoveGrain.
  4.  
  5. # > Requirements: MaskTools, RemoveGrain(SSE3).dll
  6. # By Bloax, based on the "Antialiasing" script (stealing parts of ;)), authors of which are; SpikeSpiegel, Didée, mf, scharfis_brain and Soulhunter.
  7.  
  8. # Note: This script is pretty weak, so tough edges (huge, curved ones) end up looking plain blurred.
  9. # Though if said source is downscaled, everything looks alright. (More or less better than just downsized.)
  10.  
  11. # It is to be noted that this script loses to the SangNom ones in slightly aliased cases. (Eg. Warcraft 3: The Frozen Throne title screen.)
  12. # Though for eliminating tons of aliasing in a noisy game (Eg. Doom), this is certainly better than the usual SangNom ones.
  13. # Due to the fact that it doesn't smoothen out the noise to abstract shapes, and instead eliminates it. (RemoveGrain. :))
  14.  
  15. # Update: sx And sy are actually the main factors in terms of clarity. (Overall sharpness of the image.)
  16. # The higher they are, the less intrusive the antialiasing becomes. Speed goes down by a bit though.
  17.  
  18. thrl = Default(thrl, 10) # Luma threshold for the masks.
  19. thrc = Default(thrc, 10) # Chroma threshold for the masks. (Color)
  20. ox = orig.width
  21. oy = orig.height
  22. sx = Default(sx, 1.3) # Update: Don't set these on 1, it'll eliminate the antialiasing.
  23. sy = Default(sx, 0.8) # Settings them too low will result in both artifacts and major loss of detail. Too high and the filter is going to be (pretty) slow.
  24. #sharpness = Default(sharpness,(31.25*((sx+sy)/2))) # The sharpness for upscaling of the downscaled clip. Keep low, or else we're going to see some edgy artifacts!
  25. #Gaussresize replaced with BilinearResize. (Speed!)
  26. mode = Default(mode, "laplace") # Kernel for detecting edges, I prefer this one.
  27. clp = orig.IsYV12() ? orig : orig.ConvertToYV12() # Is the source in YV12? If not, convert to it. (Shameless ripoff!)
  28.  
  29. ##############
  30.  
  31. a=clp
  32. b=clp.BilinearResize(m4(ox*sx),m4(oy*sy))
  33. c=b.RemoveGrain(mode=19).RemoveGrain(mode=9).RemoveGrain(mode=19).BilinearResize(ox,oy).RemoveGrain(mode=19)
  34. e=clp.EdgeMask(round(thrl/6),thrl,round(thrc/5),thrc,mode).Inflate().RemoveGrain(mode=4).Deflate()
  35. f=MaskedMerge(a,c,e) # I'll probably be messing around with those.
  36. MaskedMerge(a,f,e)
  37. # The stuff below ended up as a bad experiment.
  38. #h=e.Invert() # This seems to clarify things outside the edges a bit. At the prize of about 3.8% worth of FPS. Worth it though.
  39. #MaskedMerge(g,a,h) # Uses the above mask to do it's dirty business.
  40. }
  41.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement