last是clip a,dfttest是clip byabbay 写了:刚开始读第二遍 又有一个小白问题
当原文中这样调用merge的时候貌似只写了2个clip,mt_merge(dfttest,g_mask,luma=true)
函数怎么自动判断哪个是clip a 哪个是clip b 哪个是clip mask?
last是clip a,dfttest是clip byabbay 写了:刚开始读第二遍 又有一个小白问题
当原文中这样调用merge的时候貌似只写了2个clip,mt_merge(dfttest,g_mask,luma=true)
函数怎么自动判断哪个是clip a 哪个是clip b 哪个是clip mask?
早就寫好了,放在NRDB裡的,NRDB沒放出來結果這個也一直懶得貼出來:zhongpang 写了: 感谢指点,请问有没有在16bit下做差的工具呢?
目前只有对msb和lsb分别做差再相加
這是avs最基本的語法問題,不屬於masktools的範疇了。任何第一個參數為clip型變量的濾鏡,第一個clip變量是可以省略的,用last代替,所以上面這個相當於mt_merge(last, dfttest, g_mask, luma=true)。yabbay 写了:刚开始读第二遍 又有一个小白问题
当原文中这样调用merge的时候貌似只写了2个clip,mt_merge(dfttest,g_mask,luma=true)
函数怎么自动判断哪个是clip a 哪个是clip b 哪个是clip mask?
举例来说如果偶想将上面这个dehalo_alpha的脚本改成luma自适应mask的dehalo的话(暗处弱dehalo 明处强dehalo) 是不是可以这样改function DeHalo_alpha(clip clp, float "rx", float "ry", float "darkstr", float "brightstr", float "lowsens", float "highsens", float "ss")
{
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 )
LOS = string(lowsens)
HIS = string(highsens/100.0)
DRK = string(darkstr)
BRT = string(brightstr)
ox = clp.width()
oy = clp.height()
uv = 1
uv2 = (uv==3) ? 3 : 2
halos = clp.bicubicresize(m4(ox/rx),m4(oy/ry)).bicubicresize(ox,oy,1,0)
are = mt_lutxy(clp.mt_expand(U=uv,V=uv),clp.mt_inpand(U=uv,V=uv),"x y -","x y -","x y -",U=uv,V=uv)
ugly = mt_lutxy(halos.mt_expand(U=uv,V=uv),halos.mt_inpand(U=uv,V=uv),"x y -","x y -","x y -",U=uv,V=uv)
so = mt_lutxy( ugly, are, "y x - y 0.001 + / 255 * "+LOS+" - y 256 + 512 / "+HIS+" + *" )
lets = mt_merge(halos,clp,so,U=uv,V=uv)
remove = (ss==1.0) ? clp.repair(lets,1,0)
\ : clp.lanczosresize(m4(ox*ss),m4(oy*ss))
\ .mt_logic(lets.mt_expand(U=uv,V=uv).bicubicresize(m4(ox*ss),m4(oy*ss)),"min",U=uv2,V=uv2)
\ .mt_logic(lets.mt_inpand(U=uv,V=uv).bicubicresize(m4(ox*ss),m4(oy*ss)),"max",U=uv2,V=uv2)
\ .lanczosresize(ox,oy)
them = mt_lutxy(clp,remove,"x y < x x y - "+DRK+" * - x x y - "+BRT+" * - ?",U=2,V=2)
return( them )
}
function m4(float x) {return(x<16?16:int(round(x/4.0)*4))}
function DeHalo_alpha(clip clp, float "rx", float "ry", float "darkstr", float "brightstr", float "lowsens", float "highsens", float "ss")
{
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 )
LOS = string(lowsens)
HIS = string(highsens/100.0)
DRK = string(darkstr)
BRT = string(brightstr)
ox = clp.width()
oy = clp.height()
uv = 1
uv2 = (uv==3) ? 3 : 2
halos = clp.bicubicresize(m4(ox/rx),m4(oy/ry)).bicubicresize(ox,oy,1,0)
are = mt_lutxy(clp.mt_expand(U=uv,V=uv),clp.mt_inpand(U=uv,V=uv),"x y -","x y -","x y -",U=uv,V=uv)
ugly = mt_lutxy(halos.mt_expand(U=uv,V=uv),halos.mt_inpand(U=uv,V=uv),"x y -","x y -","x y -",U=uv,V=uv)
so = mt_lutxy( ugly, are, "y x - y 0.001 + / 255 * "+LOS+" - y 256 + 512 / "+HIS+" + *" )
lets = mt_merge(halos,clp,so,U=uv,V=uv)
remove = (ss==1.0) ? clp.repair(lets,1,0)
\ : clp.lanczosresize(m4(ox*ss),m4(oy*ss))
\ .mt_logic(lets.mt_expand(U=uv,V=uv).bicubicresize(m4(ox*ss),m4(oy*ss)),"min",U=uv2,V=uv2)
\ .mt_logic(lets.mt_inpand(U=uv,V=uv).bicubicresize(m4(ox*ss),m4(oy*ss)),"max",U=uv2,V=uv2)
\ .lanczosresize(ox,oy)
them = mt_lutxy(clp,remove,"x y < x x y - "+DRK+" * - x x y - "+BRT+" * - ?",U=2,V=2)
now = mt_merge(clp,them,so,luma=true,chroma=process)
return(now)
}
function m4(float x) {return(x<16?16:int(round(x/4.0)*4))}
代码: 全选
XXXSource
up = last.nnedi3_rpow2(rfactor=2, qual=2)
emask = up.tcanny(sigma=0.8, mode=1, plane=1)
edgeclean = up.YAHR().Dehalo_Alpha_mt(darkstr=1.0,brightstr=1.4,rx=2.4,ry=2.4,highsens=100,lowsens=30)
ecmask = emask.mt_expand(mode=mt_square(2)).mt_lutxy(emask.mt_inpand(mode=mt_square(1)), "x y -").mt_lut("x 16 < x x 2 << ?")
eced = mt_merge(up, edgeclean, ecmask, luma=true, Y=3, U=3, V=3)
eced.LSFmod(defaults="fast",Smode=3,Smethod=3,Lmode=1,strength=50,preblur="ON",secure=true,edgemode=0,soft=0,soothe=true,ss_x=1.00,ss_y=1.00,source=up)
感谢指点,现在可以实现根据dither分布局部加噪了06_taro 写了:早就寫好了,放在NRDB裡的,NRDB沒放出來結果這個也一直懶得貼出來:zhongpang 写了: 感谢指点,请问有没有在16bit下做差的工具呢?
目前只有对msb和lsb分别做差再相加
[syntax lang="avisynth" lines="f" filename="makediff16.avsi"]FUNCTION makediff16(clip a, clip b, int "Y", int "U", int "V", bool "safe"){
Y = Default(Y, 3)
U = Default(U, 1)
V = Default(V, 1)
Y31 = Y == 3 ? 3 : 1
U31 = U == 3 ? 3 : 1
V31 = V == 3 ? 3 : 1
/* the expression for [makediff16(x, y)] is:
* x - y + 32768 = x + (65536 - y) - 32768,
* and it can be transferred to [adddiff16(x, lut16(y, "65536-y"))]
*/
addend = b.Dither_lut16("65536 x -", Y=Y31, U=U31, V=V31)
wrap = b.Dither_lut16("x 0 == 1 0 ?", Y=Y31, U=U31, V=V31)
diff = Dither_add16(a, addend, Y=Y31, U=U31, V=V31, dif=true)
/* only needed for pixels with value==0 (65536-0>65535),
* which should not appear in strict TV level clips,
* so it is usually safe enough to skip this wrapping.
*/
diff = Default(safe, false) ? diff.Dither_add16(wrap, Y=Y31, U=U31, V=V31, dif=false)
\ : diff
/* copy plane or not
*/
diff = ( Y==2 || U==2 || V==2 ) ? mt_lutxy( diff, a, Y=(Y==2?4:2), U=(U==2?4:2), V=(V==2?4:2) ) : diff
diff = ( Y==4 || U==4 || V==4 ) ? mt_lutxy( diff, b, Y=(Y==4?4:2), U=(U==4?4:2), V=(V==4?4:2) ) : diff
/* set plane value or not
*/
return ( Y<=0 || U<=0 || V<=0 ) ? diff.Dither_lut16( Y=(Y<=0?Y:2), U=(U<=0?U:2), V=(V<=0?V:2) )
\ : diff
}[/syntax]