papcom
31st October 2015, 11:53
I use a Despot Function based on RemovedirtMC, originally provided by johnmeyer. The result is good. Now I would like to have the Option to adjust the Degraining of my films.
I tried around but I could not get the desired result. The filmgrain remains. Can anyone give me a hint, which Parameter I have to adjust in order the grain is affected?
( a problem for me is to understand the section with the "RemoveDirt" - function... how is this called and is the code correct as it is? )
Here is the script:
function RemoveDirtMC(clip,int limit, bool "_grey")
{
_grey=default(_grey, false)
limit=default(limit,6)
prefiltered = fft3dfilter(clip,sigma=1,sigma2=2,sigma3=3,sigma4=5,bw=64,bh=64)
prefiltered = RemoveGrain(clip,2)
superfilt = MSuper(prefiltered, hpad=32, vpad=32,pel=2)
super=MSuper(clip, hpad=32, vpad=32,pel=2)
bvec = MAnalyse(superfilt,isb=true, blksize=16, overlap=2,delta=1, truemotion=true)
fvec = MAnalyse(superfilt,isb=false, blksize=16, overlap=2,delta=1, truemotion=true)
# Increase thSAD if moving objects are being removed!! default is 100
bvec_re = Mrecalculate(super,bvec,blksize=4, overlap=0,thSAD=160)
fvec_re = Mrecalculate(super,fvec,blksize=4, overlap=0,thSAD=160)
backw = MFlow(clip,super,bvec_re)
forw = MFlow(clip,super,fvec_re)
clp=interleave(backw,clip,forw)
clp=clp.RemoveDirt(limit,_grey)
clp=clp.SelectEvery(3,1)
return clp
}
function RemoveDirt(clip input, int limit, bool _grey)
{
clensed=input.Clense(grey=_grey, cache=4)
alt=input.RemoveGrain(2)
return RestoreMotionBlocks(clensed,input,alternative=alt,pthreshold=6,cthreshold=8, gmthreshold=40,dist=3,dmode=2,debug=false,noise=limit,noisy=4, grey=_grey)
}
thescrapyard
1st November 2015, 06:45
I use this I altered to add, I think, grain filtering to the processing section of RemoveDirt and RemoveSpots so it uses the now degrained source as the prefilter for clense. Maybe somebody who can read the script fully can explain it
function RemoveSpots(clip clp, int "limit", bool "_grey")
{
_grey = Default(_grey, false)
limit = Default(limit, 16)
clmode = 17
clensed = Clense(clp, grey=_grey, cache=4)
sbegin = ForwardClense(clp, grey=_grey, cache=-1)
send = BackwardClense(clp, grey=_grey, cache=-1)
##### Uncomment ONE line below to use that filter to degrain #####
# alt = Repair(SCSelect(clp, sbegin, send, clensed, debug=true), clp, mode=limit, modeU = _grey ? -1 : limit).fluxsmoothst(5,5)
# alt = Repair(SCSelect(clp, sbegin, send, clensed, debug=true), clp, mode=limit, modeU = _grey ? -1 : limit).msmooth(threshold=5,strength=3,highq=true,chroma=false)
# alt = Repair(SCSelect(clp, sbegin, send, clensed, debug=true), clp, mode=limit, modeU = _grey ? -1 : limit).convertToYUY2().peachsmoother(100).convertToYV12()
restore = Repair(clensed, clp, mode=limit, modeU = _grey ? -1 : limit)
clp = RestoreMotionBlocks(clensed, restore, neighbour=clp, alternative=alt, gmthreshold=70, dist=1, \
dmode=2, debug=false, noise=10, noisy=12, grey=_grey)
return clp
}
function RemoveSpotsMC_grain(clip clp, int "limit", bool "_grey", int "Vectors")
{
_grey = Default(_grey, false)
limit = Default(limit, 16)
Vectors = Default(Vectors, 1)
Vectors = (Vectors < 1) ? 1 : (Vectors > 3) ? 3 : Vectors
super = MSuper(clp, pel=2, sharp=2)
bvec3 = (Vectors == 3) ? MAnalyse(super, isb=true, delta=3, blksize=8, overlap=4, truemotion=true) : NullClip(clp)
bvec2 = (Vectors >= 2) ? MAnalyse(super, isb=true, delta=2, blksize=8, overlap=4, truemotion=true) : NullClip(clp)
bvec1 = MAnalyse(super, isb=true, delta=1, blksize=8, overlap=4, truemotion=true)
fvec1 = MAnalyse(super, isb=false, delta=1, blksize=8, overlap=4, truemotion=true)
fvec2 = (Vectors >= 2) ? MAnalyse(super, isb=false, delta=2, blksize=8, overlap=4, truemotion=true) : NullClip(clp)
fvec3 = (Vectors == 3) ? MAnalyse(super, isb=false, delta=3, blksize=8, overlap=4, truemotion=true) : NullClip(clp)
backw3 = (Vectors == 3) ? MFlow(clp, super, bvec3) : NullClip(clp)
backw2 = (Vectors >= 2) ? MFlow(clp, super, bvec2) : NullClip(clp)
backw1 = MFlow(clp, super, bvec1)
forw1 = MFlow(clp, super, fvec1)
forw2 = (Vectors >= 2) ? MFlow(clp, super, fvec2) : NullClip(clp)
forw3 = (Vectors == 3) ? MFlow(clp, super, fvec3) : NullClip(clp)
clp = (Vectors == 1) ? interleave(backw1, clp, forw1) : \
(Vectors == 2) ? interleave(backw2, backw1, clp, forw1, forw2) : \
interleave(backw3, backw2, backw1, clp, forw1, forw2, forw3)
clp = RemoveSpots(clp, limit=limit, _grey=_grey)
clp = (Vectors == 1) ? SelectEvery(clp, 3, 1) : \
(Vectors == 2) ? SelectEvery(clp, 5, 2) : \
SelectEvery(clp, 7, 3)
return clp
}
I also use a similiar altered version for heavier grain for RemoveDirt as well
function RemoveDirt(clip input, int limit, bool _grey)
{
clensed=input.Clense(grey=_grey, cache=4)
alt=input.removegrain(2)
##### Uncomment ONE line below to add extra grain removal #####
# alt=input.removegrain(2).fluxsmoothst(5,5)
# alt=input.removegrain(2).msmooth(threshold=5,strength=3,highq=true,chroma=false)
return RestoreMotionBlocks(clensed,input,alternative=alt,pthreshold=6,cthreshold=8, gmthreshold=40,dist=3,dmode=2,debug=false,noise=limit,noisy=4, grey=_grey)
# Alternative settings
# return RestoreMotionBlocks(clensed,input,alternative=alt,pthreshold=4,cthreshold=6, gmthreshold=40,dist=1,dmode=2,debug=false,noise=limit,noisy=12,grey=_grey,show=true)
# return RestoreMotionBlocks(clensed,input,alternative=alt,pthreshold=6,cthreshold=8, gmthreshold=40,dist=3,tolerance= 12,dmode=2,debug=false,noise=limit,noisy=12,grey=_grey,show=false)
}
function RemoveDirtMC(clip,int "limit", bool "_grey")
{
_grey=default(_grey, false)
limit = default(limit,6)
prefiltered = RemoveGrain(clip,2)
superfilt = MSuper(prefiltered, hpad=32, vpad=32,pel=2)
super=MSuper(clip, hpad=32, vpad=32,pel=2)
bvec = MAnalyse(superfilt,isb=true, blksize=16, overlap=2,delta=1, truemotion=true)
fvec = MAnalyse(superfilt,isb=false, blksize=16, overlap=2,delta=1, truemotion=true)
bvec_re = Mrecalculate(super,bvec,blksize=8, overlap=0,thSAD=100)
fvec_re = Mrecalculate(super,fvec,blksize=8, overlap=0,thSAD=100)
backw = MFlow(clip,super,bvec_re)
forw = MFlow(clip,super,fvec_re)
clp=interleave(forw,clip,backw)
clp=clp.RemoveDirt(limit,_grey)
clp=clp.SelectEvery(3,1)
return clp
}
I use either of these for very heavy grain usually for old childrens series or documentaries from the 1940's. It doesn't removal all grain/scratches but enough to make a big difference to the output. They may be overkill but dropping the filter settings down to remove just enough for your needs
To call RemoveSpots or RemoveGrain I use these :
Simply 'RemoveSpots()' does it for me with the defaults and additional grain filtering and also 'RemoveDirt(125,false)'
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.