Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # for use with 1080p full-range Funi sources; would probably also work well with 720p if you upscale it first, but no guarantees.
- # should be fast enough to not be a bottleneck (this runs at ~30 fps on my laptop).
- # the "yv12" parameter sets whether the output should be y8 or yv12.
- # edit (2015-10-19): made the mask wider to catch the corners of some letters that were being missed before.
- function funimask(clip src,bool "yv12")
- {
- yv12 = default(yv12,false)
- l = src.mt_binarize(250).removegrain(4).mt_expand()
- 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())
- e = src.mt_lut("x 2 /").mt_edge("hprewitt",244,255).removegrain(4).mt_expand()
- sm = mt_logic(l,e,"min").mt_logic(c,"min").removegrain(3)
- 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)
- # note: dither_box_filter16 is actually considerably faster than averageblur
- yv12 ? sm.converttoyv12() : sm
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement