Advertisement
torchlight

Funi hardsub mask

Apr 22nd, 2015
866
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # for use with 1080p full-range Funi sources; would probably also work well with 720p if you upscale it first, but no guarantees.
  2. # should be fast enough to not be a bottleneck (this runs at ~30 fps on my laptop).
  3. # the "yv12" parameter sets whether the output should be y8 or yv12.
  4.  
  5. # edit (2015-10-19): made the mask wider to catch the corners of some letters that were being missed before.
  6.  
  7. function funimask(clip src,bool "yv12")
  8. {
  9. yv12 = default(yv12,false)
  10. l = src.mt_binarize(250).removegrain(4).mt_expand()
  11. c = mt_lutxy(src.utoy8(),src.vtoy8(),"255 x 128 - abs y 128 - abs max 3 - 50 * -").mt_inpand(mode="both").bilinearresize(src.width(),src.height())
  12. e = src.mt_lut("x 2 /").mt_edge("hprewitt",244,255).removegrain(4).mt_expand()
  13. sm = mt_logic(l,e,"min").mt_logic(c,"min").removegrain(3)
  14. sm = sm.converttoy8().dither_convert_8_to_16().dither_box_filter16(8,u=1,v=1).dither_box_filter16(8,u=1,v=1).ditherpost(mode=-1).mt_binarize(3).mt_inflate().mt_inflate().mt_inflate().removegrain(12).removegrain(12)
  15. # note: dither_box_filter16 is actually considerably faster than averageblur
  16. yv12 ? sm.converttoyv12() : sm
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement