Boulder
25th February 2006, 09:12
It's this one, use it to replace the LPprotect part :
function LPprotect( clip NR, clip orig, float rad, int low, int high )
{
ox = NR.width()
oy = NR.height()
HI = string(256.0/high)
LO = string(256.0/high*low)
ML = string(float(high)/(float(high)-low))
diff = mt_lutxy(orig,NR,yexpr="x y - 128 +",uexpr="y",vexpr="y",Y=3,U=3,V=3)
diffLP = repair(diff,diff.removegrain(4,-1).bicubicresize(m4(ox/rad),m4(oy/rad)).bicubicresize(ox,oy,1,0),1,0)
diff = mt_lutxy(diff,diffLP,yexpr="x 128 - y 128 - * 0 < 128 x y 128 - - ?",uexpr="x",vexpr="x",Y=3,U=2,V=2)
MyMoMask = mt_logic( mt_lutxy(NR,NR.deleteframe(0), "x y - abs "+HI+" * "+LO+" - "+ML+" *"),
\ mt_lutxy(NR,NR.duplicateframe(0),"x y - abs "+HI+" * "+LO+" - "+ML+" *"), "max",Y=3,U=1,V=1)
mt_merge(NR,mt_lutxy(orig,diff,yexpr="x y 128 - -",uexpr="y",vexpr="y",Y=3,U=3,V=3),MyMoMask.fity2uv(),Y=3,U=3,V=3)
#MyMoMask.greyscale
return( last )
}
Unfortunately the script hasn't been updated yet. AFAIK Didée's still working on the whole MCNR concept.
frednerk
25th February 2006, 10:36
Thankyou Boulder, :goodpost: been following the usage forum for a while; let's say that you feature prominently along with a number of other very clever and helpful people :)
Just out of interest, given RemoveDirt no longer appears to be a supported DLL... the author seems to have made it a script per http://www.removedirt.de.tf/ and http://forum.doom9.org/showthread.php?p=761036#post761036 . However the new RemoveDirt script function appears to still need the old DLL for the SCSelect call (unless there's another way to do it). Hence would it be a valid thing to do, to replace in MCNR_simple2 the call to the old DLL
removdirt ? RemoveDirt() : last
with a call to the a scipt function
removdirt ? fRemoveDirt() : last
and include in the bottom of MCNR_simple2, the slightly renamed function as written by the author
function fRemoveDirt(clip input, bool "_grey", int "repmode")
{
# fRemoveDirt requires RemoveDirtSSE2 (if you have SSE2, otherwise the slower one) for SCSelect as at 25-Feb-2006
# http://www.removedirt.de.tf/
# http://forum.doom9.org/showthread.php?p=761036#post761036
_grey=default(_grey, false)
repmode=default(repmode, 16)
clmode=17
clensed=Clense(input, grey=_grey, cache=4)
sbegin = ForwardClense(input, grey=_grey, cache=-1)
send = BackwardClense(input, grey=_grey, cache=-1)
alt=Repair(SCSelect(input, sbegin, send, clensed, debug=true), input, mode=repmode, modeU = _grey ? -1 : repmode )
restore=Repair(clensed, input, mode=repmode, modeU = _grey ? -1 : repmode)
corrected=RestoreMotionBlocks(clensed, restore, neighbour=input, alternative=alt, gmthreshold=70, dist=1, dmode=2,
\ debug=false, noise=10, noisy=12, grey=_grey)
return RemoveGrain(corrected, mode=clmode, modeU = _grey ? -1 : clmode )
}
(remembering to still include the old DLL to so it can access SCSelect). Would that be right ? In the interests of viewing a complete script, does the MCNR_simple2 include file then become this ? (apologies to the original authors if it's incorrect, I'll edit it out if someone says so)
global idx_counter = 10
function MCNR_simple2( clip clp, int "frames", int "thY", int "thC", int "thY2", int "thC2",
\ int "blocksize", bool "chroME", bool "repairME", bool "removdirt",
\ float "LPrad", int "LPlosens", int "LPhisens")
{
frames = default( frames, 2 ) # number of temporal neighbors to use for motion compensation & temporal filtering
thY = default( thY, 8 ) # upper thresh for pixel differences to include into temporal filtering
thC = default( thC, 6 ) # ditto, for chroma
thY2 = default( thY2, -1 ) # lower diff. thresh, for TTempSmooth (= -1 --> use TemporalSoften, not TTempSmooth)
thC2 = default( thC2, -1 ) # ditto, for chroma
blocksize = default( blocksize, 16 ) # blocksize for motion search & compensation
removdirt = default( removdirt,false) # additionally use RemoveDirt? (tip: for strong noise - true, else false. Requires frames>1)
chroME = default( chroME, false) # include chroma planes into motion search?
repairME = default( repairME, true ) # simple repairing of MC/ME errors (good when using bigger thresh's).
LPrad = default( LPrad, 0.0 ) # Lowpass protection: radius for gaussian blur
LPlosens = default( LPlosens, 1 ) # LP protection: lower thresh for motion recognition
LPhisens = default( LPhisens, 5 ) # LP protection: upper thresh for motion recognition
frames = (frames<1) ? 1 : (frames>4) ? 4 : frames
removdirt = (frames==1) ? false : removdirt
LPhisens = (LPhisens>LPlosens) ? LPhisens : LPlosens+1
dummy = blankclip(clp,width=64,height=32)
global idx_counter = idx_counter + 1
bw4 = (frames<4) ? dummy : clp.SrchCmpRp(blocksize,true, 4,chroME,repairME)
bw3 = (frames<3) ? dummy : clp.SrchCmpRp(blocksize,true, 3,chroME,repairME)
bw2 = (frames<2) ? dummy : clp.SrchCmpRp(blocksize,true, 2,chroME,repairME)
bw1 = clp.SrchCmpRp(blocksize,true, 1,chroME,repairME)
fw1 = clp.SrchCmpRp(blocksize,false,1,chroME,repairME)
fw2 = (frames<2) ? dummy : clp.SrchCmpRp(blocksize,false,2,chroME,repairME)
fw3 = (frames<3) ? dummy : clp.SrchCmpRp(blocksize,false,3,chroME,repairME)
fw4 = (frames<4) ? dummy : clp.SrchCmpRp(blocksize,false,4,chroME,repairME)
frames == 1 ? interleave( bw1,clp,fw1 ) : \
frames == 2 ? interleave( bw2,bw1,clp,fw1,fw2 ) : \
frames == 3 ? interleave( bw3,bw2,bw1,clp,fw1,fw2,fw3 ) : \
interleave( bw4,bw3,bw2,bw1,clp,fw1,fw2,fw3,fw4 )
removdirt ? fRemoveDirt() : last # dcw - changed RemoveDirt() to fRemoveDirt()
(thY2 < 0) || (thC2 < 0) ? temporalsoften(frames,thY,thC,32,2)
\ : ttempsmooth(frames,thY,thC,thY2,thC2,5,24)
selectevery(frames*2+1,frames)
LPrad < 1.01 ? last : LPprotect(last,clp,LPrad,LPlosens,LPhisens)
return( last )
}
# --------------------------------
function SrchCmpRp( clip clp, int _blksize, bool _isb, int _delta, bool _chroME, bool _repair)
{
vec = clp.mvanalyse(truemotion=true,pel=2,blksize=_blksize,chroma=_chroME,isb=_isb,delta=_delta,idx=idx_counter)
comp = clp.mvflow(vec,idx=idx_counter)
# vec = clp.mvanalyse(pel=2,blksize=_blksize,chroma=_chroME,isb=_isb,delta=_delta,idx=idx_counter)
# comp = clp.mvcompensate(vec,idx=idx_counter)
_repair ? repair(comp,clp,1,3) : comp
return( last )
}
# --------------------------------
function LPprotect( clip NR, clip orig, float rad, int low, int high )
{
# by Boulder - replacement for inside MCNR_simple2, to use MaskTools v2 instead of the pre-V2 Masktools, 26-Feb-2006
# http://forum.doom9.org/showthread.php?p=790633#post790633
ox = NR.width()
oy = NR.height()
HI = string(256.0/high)
LO = string(256.0/high*low)
ML = string(float(high)/(float(high)-low))
diff = mt_lutxy(orig,NR,yexpr="x y - 128 +",uexpr="y",vexpr="y",Y=3,U=3,V=3)
diffLP = repair(diff,diff.removegrain(4,-1).bicubicresize(m4(ox/rad),m4(oy/rad)).bicubicresize(ox,oy,1,0),1,0)
diff = mt_lutxy(diff,diffLP,yexpr="x 128 - y 128 - * 0 < 128 x y 128 - - ?",uexpr="x",vexpr="x",Y=3,U=2,V=2)
MyMoMask = mt_logic( mt_lutxy(NR,NR.deleteframe(0), "x y - abs "+HI+" * "+LO+" - "+ML+" *"),
\ mt_lutxy(NR,NR.duplicateframe(0),"x y - abs "+HI+" * "+LO+" - "+ML+" *"), "max",Y=3,U=1,V=1)
mt_merge(NR,mt_lutxy(orig,diff,yexpr="x y 128 - -",uexpr="y",vexpr="y",Y=3,U=3,V=3),MyMoMask.fity2uv(),Y=3,U=3,V=3)
#MyMoMask.greyscale
return( last )
}
# --------------------------------
function m4(float x) {return( x<16?16:int(round(x/4.0)*4)) }
# --------------------------------
function fRemoveDirt(clip input, bool "_grey", int "repmode")
{
# fRemoveDirt requires RemoveDirtSSE2 (if you have SSE2, otherwise the slower one) for SCSelect as at 25-Feb-2006
# http://www.removedirt.de.tf/
# http://forum.doom9.org/showthread.php?p=761036#post761036
_grey=default(_grey, false)
repmode=default(repmode, 16)
clmode=17
clensed=Clense(input, grey=_grey, cache=4)
sbegin = ForwardClense(input, grey=_grey, cache=-1)
send = BackwardClense(input, grey=_grey, cache=-1)
alt=Repair(SCSelect(input, sbegin, send, clensed, debug=true), input, mode=repmode, modeU = _grey ? -1 : repmode )
restore=Repair(clensed, input, mode=repmode, modeU = _grey ? -1 : repmode)
corrected=RestoreMotionBlocks(clensed, restore, neighbour=input, alternative=alt, gmthreshold=70, dist=1, dmode=2,
\ debug=false, noise=10, noisy=12, grey=_grey)
return RemoveGrain(corrected, mode=clmode, modeU = _grey ? -1 : clmode )
}
PS I'm in total awe of Didée. And scharfis_brain.
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.