Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # 2017.03.04 1st release
- # DeHalo_alpha with high bit support, need masktools 2.2.4 or up in avs26 and avs+
- function DeHalo_alpha_mt(clip input, float "rx", float "ry", float "darkstr", float "brightstr", float "lowsens", float "highsens", float "ss", bool "cs", int "search_rade", int "search_radi")
- {
- sre = default( search_rade, 1 )
- sri = default( search_radi, sre )
- input
- DeHalo_alpha_2BD(rx, ry, darkstr, brightstr, lowsens, highsens, ss, cs, sre, sri)
- }
- function DeHalo_alpha(clip input, float "rx", float "ry", float "darkstr", float "brightstr", float "lowsens", float "highsens", float "ss", bool "cs", int "search_rade", int "search_radi")
- {
- input
- DeHalo_alpha_mt(rx, ry, darkstr, brightstr, lowsens, highsens, ss, cs, search_rade, search_radi)
- }
- function m4_dham(float x) {
- nx=VersionNumber() < 2.6 ? x<16?16:int(round(x/4.0)*4) : round(x)
- return(nx)
- }
- # modified dehalo_alpha: here with increased search-radius for validation
- function DeHalo_alpha_2BD(clip input, float "rx", float "ry", float "darkstr", float "brightstr", float "lowsens", float "highsens", float "ss", bool "cs", int "search_rade", int "search_radi")
- {
- rx = default( rx, 2.0 )
- ry = default( ry, 2.0 )
- darkstr = default( darkstr, 1.0 )
- brightstr = default( brightstr, 1.0 )
- lowsens = default( lowsens, 50 )
- highsens = default( highsens, 50 )
- ss = default( ss, 1.5 )
- cs = default( cs, false )
- sre = default( search_rade, max(m4_dham(max(rx,ry)),3) )
- sri = default( search_radi, sre )
- ssispmt = Findstr(VersionString(), "AviSynth+") != 0 && Findstr(VersionString(), "r1576") == 0
- sislumaonly = ssispmt ? input.isy() : VersionNumber() < 2.6 ? true : input.isy8()
- clp = sislumaonly ? input : ssispmt ? input.converttoy() : input.converttoy8()
- LOS = string(lowsens)
- HIS = string(highsens/100.0)
- DRK = string(darkstr)
- BRT = string(brightstr)
- ox = clp.width()
- oy = clp.height()
- halos = clp.bicubicresize(m4_dham(ox/rx),m4_dham(oy/ry)).bicubicresize(ox,oy,1,0)
- are = mt_lutxy(clp .srdha2e(sre,1),clp .srdha2i(sri,1),"x y -","x y -","x y -",U=1,V=1)
- ugly = mt_lutxy(halos.srdha2e(sre,1),halos.srdha2i(sri,1),"x y -","x y -","x y -",U=1,V=1)
- so = VersionNumber() < 2.6 ? mt_lutxy( ugly, are, "y x - y 0.001 + / 255 * "+LOS+" - y 256 + 512 / "+HIS+" + *" )
- \ : mt_lutxy( ugly, are, "clamp_f_i8 y x - y 0.001 + / range_max * "+LOS+" #F - y range_size + 512 #F / "+HIS+" + *" )
- lets = mt_merge(halos,clp,so,U=1,V=1)
- remove = (ss==1.0) ? clp.repair(lets,1,0)
- \ : clp.lanczosresize(m4_dham(ox*ss),m4_dham(oy*ss))
- \ .mt_logic(lets.mt_expand(U=1,V=1).bicubicresize(m4_dham(ox*ss),m4_dham(oy*ss)),"min",U=2,V=2)
- \ .mt_logic(lets.mt_inpand(U=1,V=1).bicubicresize(m4_dham(ox*ss),m4_dham(oy*ss)),"max",U=2,V=2)
- \ .lanczosresize(ox,oy)
- them = VersionNumber() < 2.6 ? mt_lutxy(clp,remove,"x y < x x y - "+DRK+" * - x x y - "+BRT+" * - ?",U=2,V=2)
- \ : mt_lutxy(clp,remove,"clamp_f_i8 x y < x x y - "+DRK+" * - x x y - "+BRT+" * - ?",U=2,V=2)
- bb = cs ? them.removegrain(11) : nop()
- xD = cs ? mt_makediff(bb,bb.repair(bb.repair(bb.medianblur(2,-333,-333),1),1)) : nop()
- xD = cs ? VersionNumber() < 2.6 ? xD.mt_lut("x 128 - 2.49 * 128 +") : xD.mt_lut("x range_half - 2.49 #F * range_half +") : xD
- xDD = cs ? VersionNumber() < 2.6 ? mt_lutxy(xD,mt_makediff(clp,them),"x 128 - y 128 - * 0 < 128 x 128 - abs y 128 - abs < x y ? ?")
- \ : mt_lutxy(xD,mt_makediff(clp,them),"x range_half - y range_half - * 0 < range_half x range_half - abs y range_half - abs < x y ? ?") : nop()
- them = cs ? them.mt_adddiff(xDD,U=2,V=2) : them
- them = sislumaonly ? them : ssispmt ? CombinePlanes(them,input,planes="YUV",sample_clip=input) : ytouv(input.utoy8(),input.vtoy8(),them)
- return( them )
- }
- Function srdha2e(clip i, int dr_rad, int count)
- {
- return count > dr_rad ? i : srdha2e(i.mt_expand(), dr_rad, count+1)
- }
- Function srdha2i(clip i, int dr_rad, int count)
- {
- return count > dr_rad ? i : srdha2i(i.mt_inpand(), dr_rad, count+1)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement