PDA

View Full Version : Grainoptimizer and ContraSharpening Questions


rkalwaitis
17th July 2009, 16:21
I was looking for the documentation that goes with the grainoptimizer.dll. All I can find is the the dll of course. So as far as the settings go. I know the basic. I do not know what tdsit=18 does, I did see it as tdist=9999 in another post.

I was playing with it using contrasharpening and used the following script. Is it a waiste of time to do grainoptimization since contrasharpening uses removegrain?

Is there an easier way to keep some grain without adding grain and still clean the image? I like contrasharpening because I think that it does make the image sharper than the original .??? (right?)

superfilt=MSuper(pel=4)
forvec1 = MAnalyse(superfilt,isb=false, delta=1, truemotion=true, blksize=16, overlap=8, pelsearch=2, search=3, searchparam=2, DCT=0, global=true, chroma=false,sadx264=0)
forvec2 = MAnalyse(superfilt,isb=false, delta=2, truemotion=true, blksize=16, overlap=8, pelsearch=2, search=3, searchparam=2, DCT=0, global=true, chroma=false,sadx264=0)
forvec3 = MAnalyse(superfilt,isb=false, delta=3, truemotion=true, blksize=16, overlap=8, pelsearch=2, search=3, searchparam=2, DCT=0, global=true, chroma=false,sadx264=0)
bacvec1 = MAnalyse(superfilt,isb=true, delta=1, truemotion=true, blksize=16, overlap=8, pelsearch=2, search=3, searchparam=2, DCT=0, global=true, chroma=false,sadx264=0)
bacvec2 = MAnalyse(superfilt,isb=true, delta=2, truemotion=true, blksize=16, overlap=8, pelsearch=2, search=3, searchparam=2, DCT=0, global=true, chroma=false,sadx264=0)
bacvec3 = MAnalyse(superfilt,isb=true, delta=3, truemotion=true, blksize=16, overlap=8, pelsearch=2, search=3, searchparam=2, DCT=0, global=true, chroma=false,sadx264=0)

function MinBlur(clip clp, int r, int "uv")
{
uv = default(uv,3)
uv2 = (uv==2) ? 1 : uv
rg4 = (uv==3) ? 4 : -1
rg11 = (uv==3) ? 11 : -1
rg20 = (uv==3) ? 20 : -1
medf = (uv==3) ? 1 : -200

RG11D = (r==1) ? mt_makediff(clp,clp.removegrain(11,rg11),U=uv2,V=uv2)
\ : (r==2) ? mt_makediff(clp,clp.removegrain(11,rg11).removegrain(20,rg20),U=uv2,V=uv2)
\ : mt_makediff(clp,clp.removegrain(11,rg11).removegrain(20,rg20).removegrain(20,rg20),U=uv2,V=uv2)
RG4D = (r==1) ? mt_makediff(clp,clp.removegrain(4,rg4),U=uv2,V=uv2)
\ : (r==2) ? mt_makediff(clp,clp.medianblur(2,2*medf,2*medf),U=uv2,V=uv2)
\ : mt_makediff(clp,clp.medianblur(3,3*medf,3*medf),U=uv2,V=uv2)
DD = mt_lutxy(RG11D,RG4D,"x 128 - y 128 - * 0 < 128 x 128 - abs y 128 - abs < x y ? ?",U=uv2,V=uv2)
clp.mt_makediff(DD,U=uv,V=uv)
return(last)
}

source=last
denoised=MDegrain3(superfilt,bacvec1,forvec1,bacvec2,forvec2,bacvec3,forvec3,thSAD=400, plane=4)
s = denoised.minblur(1,1)
allD = mt_makediff(source,denoised)
ssD = mt_makediff(s,s.removegrain(11,-1))
ssDD = ssD.repair(allD,1)
ssDD = ssDD.mt_lutxy(ssD,"x 128 - abs y 128 - abs < x y ?")

denoisedclip=denoised.mt_adddiff(ssDD,U=2,V=2)

source.GrainOptimizer(denoisedclip,tdist=18)