Guest User

VHSHaloremover

a guest
Feb 21st, 2019
348
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # 2019.02.19
  2. # VHSHaloremover with high bit support, need masktools 2.2.17 or up in avs26 and avs+
  3. Function VHSHaloremover(clip input, int "xradius", int "yradius", int "darkthr", int "brightthr", float "blurmix")
  4. {
  5. sisphbd = AvsPlusVersionNumber > 2294
  6. sislumaonly = sisphbd ? input.isy() : VersionNumber() < 2.6 ? true : input.isy8()
  7. sislumaonly ? input : sisphbd ? input.converttoy() : input.converttoy8()
  8. h   = Height ()
  9. w   = Width ()
  10. xradius = Default(xradius, 8)
  11. yradius = Default(yradius, 1)
  12. darkthr = Default(darkthr, 122)
  13. brightthr = Default(brightthr, 134)
  14. blurmix = Default(blurmix, 0.8)
  15. cy  = BicubicResize (w / xradius, h / yradius, 1, 0).BicubicResize (w, h, 1, 0)
  16. cmd = mt_makediff (cy)
  17. cm  = VersionNumber() < 2.6 ? cmd.mt_lut ("x "+String(brightthr)+" > 255 x "+String(darkthr)+" < 255 0 ? ?")
  18.       \             : cmd.mt_lut ("x "+String(brightthr)+" scalef > range_max x "+String(darkthr)+" scalef < range_max 0 ? ?", use_expr=2)
  19. cr  = last.Merge (cy, blurmix)
  20. mt_merge (last, cr, cm, y=3, u=2, v=2)
  21. sislumaonly ? last : sisphbd ? CombinePlanes(last,input,planes="YUV",sample_clip=input) : ytouv(input.utoy8(),input.vtoy8(),last)
  22. }
RAW Paste Data