Log in

View Full Version : Sharpening VHS capture


yup
16th June 2009, 07:29
Hi folk. Now I try improve quality from VHS capture. VHS tape from camcorder original (no generation copy). Quality very good only grain and white noise. Main idea from videofred thread, difference only that my source interlaced.
script:
SetMemoryMax(1152)
Loadplugin("MT.dll")
LoadPlugin("warpsharp.dll")
LoadPlugin("mt_masktools-25.dll")
LoadPlugin("SSE3Tools.dll")
LoadPlugin("RemoveGrainTSSE3.dll")
LoadPlugin("RemoveGrainSSE3.dll")
LoadPlugin("RepairSSE3.dll")
Import("LimitedSharpenFaster.avsi")
SetMTMode(5)
LSF_sharp_ness=250 LSF_radi_us=3 LSF_sub=1.5 #first sharpening parameters (LimitedSharpenFaster) sub=subsampling
W=720 H=576
DirectShowSource("my.avi")
SetMTMode(2)
source=AssumeTFF()
noise=source.nnedi2(field=-2)
supernoise = MSuper(noise)
backward_vec1=supernoise.MAnalyse(isb = true, delta = 2,blksize=8, overlap=4,dct=0, chroma=true, badSAD=1000)
forward_vec1=supernoise.MAnalyse(isb = false, delta = 2,blksize=8, overlap=4,dct=0, chroma=true, badSAD=1000)
backward_vec2=supernoise.MAnalyse(isb = true, delta = 4,blksize=8, overlap=4,dct=0, chroma=true, badSAD=1000)
forward_vec2=supernoise.MAnalyse(isb = false, delta = 4,blksize=8, overlap=4,dct=0, chroma=true, badSAD=1000)
backward_vec3=supernoise.MAnalyse(isb = true, delta = 6,blksize=8, overlap=4,dct=0, chroma=true, badSAD=1000)
forward_vec3=supernoise.MAnalyse(isb = false, delta = 6,blksize=8, overlap=4,dct=0, chroma=true, badSAD=1000)
noise.MDegrain3(supernoise,backward_vec3,backward_vec2,backward_vec1,forward_vec1,forward_vec2,forward_vec3,thSAD=400,thSADc=400,plane=4)
#HDRAGC()
limitedSharpenFaster(last,smode=3,strength=LSF_sharp_ness,overshoot=50,radius=LSF_radi_us, ss_X=LSF_sub, SS_Y=LSF_sub, dest_x=W,dest_y=H)
AssumeTFF().SeparateFields().SelectEvery(4,0,3)
StackVertical(SeparateFields(source),last)
#Weave()
I use MDegrain on bobed frames, but with field order (even with even, odd with odd), because sharpening better work on bobed frames.
HDRAGC now give flickering, I will be try AutoLevels.
Any suggestion and advice welcome!
With kind regards yup.

LaTo
16th June 2009, 08:00
Without sample it's a bit difficult...
LSF doesn't need radius for Smode=3

You can try this to: (instead of MDegrain3)
noise.MCTemporalDenoise(settings="low",Tovershoot=2,strength=200,chroma=true) ### adjust "settings" to your video, and try with GPU=true (speedup)

yup
16th June 2009, 08:18
LaTo!:thanks:
It is lecture.
Please:
http://www.sendspace.com/file/7muf54
yup

scharfis_brain
16th June 2009, 08:25
you could try tempgauss_mc() as denoiser for your interlaced VHS.
It works pretty well.

LaTo
16th June 2009, 10:02
Replace MDegrain3 & LSF by this:
MCTemporaldenoise(settings="high",chroma=true,strength=300,Tovershoot=7,flat=true,AGstr=4,bias=128)



http://img14.imageshack.us/img14/3963/srcp.jpghttp://img15.imageshack.us/img15/8818/mctd.jpg


Some strong halos are present in the source, you should remove these before MCTemporalDenoise because they are over-enhanced by sharpening.
Try Dehalo_alpha before or others scripts in the forum.

2Bdecided
16th June 2009, 11:39
Be careful not to make it look like plastic / cartoon. The noise hides the low resolution a little - and you can't add more resolution!

It's not really a "difficult" source.

Cheers,
David.

yup
17th June 2009, 07:59
:thanks: for all!
@ LaTo my target PAL DVD 720x576 25Hz interlaced.
@ scharfis_brain if i right understandt You suggest:
tempgauss_mc()
limitedSharpenFaster(last,smode=3,strength=LSF_sharp_ness,overshoot=50, ss_X=LSF_sub, SS_Y=LSF_sub, dest_x=W,dest_y=H)
AssumeTFF().SeparateFields().SelectEvery(4,0,3)
Weave()
May be before reinterlace use vertical blur filter (Unfilter)?
@ 2Bdecided You do not see chroma shift?
yup.

R3Z
17th June 2009, 09:38
EDIT: Best to ignore this post, error in script.

Heres another angle, remove some noise, sharpen then re-add some noise to give it a non custard/oil painting look;

http://www.users.on.net/~inet_s51/doom9/test.jpg


Mdegrain2 seems to get rid of most noise and the chroma problem. The detail based grain function just adds some grain based on the detail levels.

Just a suggestion, we all like different things !

Terka
17th June 2009, 10:26
you can try remove the yellow areas using
Camcorder color denoise, see http://acobw.narod.ru/
so the script can be like:

LoadVirtualDubPlugin ("c:\Program Files\AviSynth\plugins\ccd.vdf", "ccd",0)
clp=avisource("c:\hj\kamera\avisynth\psi\!Psi.avi")
clp.ConvertToRGB32(interlaced=true)
ccdamount=49 #try different settings
ccd=last.ccd(ccdamount,1).ccd(ccdamount,1).ConvertToYV12()

videoFred
17th June 2009, 11:59
Heres another angle, remove some noise, sharpen then re-add some noise to give it a non custard/oil painting look;

Your example looks very good, not so 'plastic' at all. I will have a closer look at your 'detailbasedgrain' function.



Fred.

Didée
17th June 2009, 13:24
The result shown by R3Z looks quite good. However, the DetailBasedGrain function looks really fishy! See:

function DetailBasedGrain(clip source, int "BM", int "dmin", int "dmax", int "grain_str", float "blur_str1",float "blur_str2", float "sharp_str")
{
bm=default(bm,"noise") # BlockBuster Method
dmin=default(dmin,1) # Blockbuster Detail Min
dmax=default(dmax,15) # Blockbuster Detail Max
grain_str=default(grain_str,2) # Grain strength
blur_str1=default(blur_str1,1.5) # Blur Strength
blur_str2=default(blur_str2,0.75) # Blur Strength
sharp_str=default(sharp_str,1) # Sharpen Strength

grain_dist = source.BlockBuster(method=bm,detail_min=dmin,detail_max=dmax,variance=grain_str)
difference = mt_makediff(source, grain_dist, U=1, V=1)
grain_pro = difference.Blur(blur_str1).Blur(blur_str2).Sharpen(sharp_str)
mt_makediff(source,grain_pro,U=2,V=2)
grain_dist.addgrain(12,0,0).Blur(1)

return last
}

Note that the greyed lines have no effect at all - their output is not used to build the function's output. Hence, what the function does is

source
Blockbuster()
addgrain()
blur(1)

i.e.
take source, let Blockbuster add noise to flat areas, let addgrain add noise everywhere, and finally blur *everything* (including the original underlying content!)

Is that really the intended operation?


Oh, and ... the "BM" parameter is declared as integer variable, but it's supposed to be a string variable - see default(bm).

R3Z
18th June 2009, 03:23
The result shown by R3Z looks quite good. However, the DetailBasedGrain function looks really fishy! See:

i.e.
take source, let Blockbuster add noise to flat areas, let addgrain add noise everywhere, and finally blur *everything* (including the original underlying content!)

Is that really the intended operation?


Oh, and ... the "BM" parameter is declared as integer variable, but it's supposed to be a string variable - see default(bm).

:confused:

Its supposed to blur the grain added by blockbuster and then add some extra grain ontop after this to help blend in the added grain.

I asked around a bit for help on how to do that and after making the function I had no comments until now !

Edit: I see whats wrong, i am making a few changes and we will see if i have learnt anything.

yup
18th June 2009, 06:37
I try three scripts:
first,fields ordering on bobed frames
SetMemoryMax(1152)
Loadplugin("MT.dll")
LoadPlugin("warpsharp.dll")
LoadPlugin("mt_masktools-25.dll")
LoadPlugin("SSE3Tools.dll")
LoadPlugin("RemoveGrainTSSE3.dll")
LoadPlugin("RemoveGrainSSE3.dll")
LoadPlugin("RepairSSE3.dll")
Import("LimitedSharpenFaster.avsi")
SetMTMode(5)
LSF_sharp_ness=250 LSF_radi_us=3 LSF_sub=1.5 #first sharpening parameters (LimitedSharpenFaster) sub=subsampling
W=720 H=576
DirectShowSource("tape1.avi")
SetMTMode(2)
source=AssumeTFF()
noise=source.nnedi2(field=-2)
supernoise = MSuper(noise)
backward_vec1=supernoise.MAnalyse(isb = true, delta = 2,blksize=8, overlap=4,dct=0, chroma=true, badSAD=1000)
forward_vec1=supernoise.MAnalyse(isb = false, delta = 2,blksize=8, overlap=4,dct=0, chroma=true, badSAD=1000)
backward_vec2=supernoise.MAnalyse(isb = true, delta = 4,blksize=8, overlap=4,dct=0, chroma=true, badSAD=1000)
forward_vec2=supernoise.MAnalyse(isb = false, delta = 4,blksize=8, overlap=4,dct=0, chroma=true, badSAD=1000)
backward_vec3=supernoise.MAnalyse(isb = true, delta = 6,blksize=8, overlap=4,dct=0, chroma=true, badSAD=1000)
forward_vec3=supernoise.MAnalyse(isb = false, delta = 6,blksize=8, overlap=4,dct=0, chroma=true, badSAD=1000)
noise.MDegrain3(supernoise,backward_vec3,backward_vec2,backward_vec1,forward_vec1,forward_vec2,forward_vec3,thSAD=400,thSADc=400,plane=4)
limitedSharpenFaster(last,smode=3,strength=LSF_sharp_ness,overshoot=50, ss_X=LSF_sub, SS_Y=LSF_sub, dest_x=W,dest_y=H)
AssumeTFF().SeparateFields().SelectEvery(4,0,3)
Weave()
second on fields
SetMemoryMax(1152)
Loadplugin("MT.dll")
LoadPlugin("warpsharp.dll")
LoadPlugin("mt_masktools-25.dll")
LoadPlugin("SSE3Tools.dll")
LoadPlugin("RemoveGrainTSSE3.dll")
LoadPlugin("RemoveGrainSSE3.dll")
LoadPlugin("RepairSSE3.dll")
Import("LimitedSharpenFaster.avsi")
SetMTMode(5)
LSF_sharp_ness=250 LSF_radi_us=3 LSF_sub=1.5 #first sharpening parameters (LimitedSharpenFaster) sub=subsampling
W=720 H=576
DirectShowSource("tape1.avi")
SetMTMode(2)
source=AssumeTFF()
noise=source.SeparateFields()
supernoise = MSuper(noise)
backward_vec1=supernoise.MAnalyse(isb = true, delta = 2,blksize=8, overlap=4,dct=0, chroma=true, badSAD=1000)
forward_vec1=supernoise.MAnalyse(isb = false, delta = 2,blksize=8, overlap=4,dct=0, chroma=true, badSAD=1000)
backward_vec2=supernoise.MAnalyse(isb = true, delta = 4,blksize=8, overlap=4,dct=0, chroma=true, badSAD=1000)
forward_vec2=supernoise.MAnalyse(isb = false, delta = 4,blksize=8, overlap=4,dct=0, chroma=true, badSAD=1000)
backward_vec3=supernoise.MAnalyse(isb = true, delta = 6,blksize=8, overlap=4,dct=0, chroma=true, badSAD=1000)
forward_vec3=supernoise.MAnalyse(isb = false, delta = 6,blksize=8, overlap=4,dct=0, chroma=true, badSAD=1000)
noise.MDegrain3(supernoise,backward_vec3,backward_vec2,backward_vec1,forward_vec1,forward_vec2,forward_vec3,thSAD=400,thSADc=400,plane=4)
weave.nnedi2(field=-2)
limitedSharpenFaster(last,smode=3,strength=LSF_sharp_ness,overshoot=50, ss_X=LSF_sub, SS_Y=LSF_sub, dest_x=W,dest_y=H)
AssumeTFF().SeparateFields().SelectEvery(4,0,3)
Weave()
third on bobed frames
SetMemoryMax(1152)
Loadplugin("MT.dll")
LoadPlugin("warpsharp.dll")
LoadPlugin("mt_masktools-25.dll")
LoadPlugin("SSE3Tools.dll")
LoadPlugin("RemoveGrainTSSE3.dll")
LoadPlugin("RemoveGrainSSE3.dll")
LoadPlugin("RepairSSE3.dll")
Import("LimitedSharpenFaster.avsi")
SetMTMode(5)
LSF_sharp_ness=250 LSF_radi_us=3 LSF_sub=1.5 #first sharpening parameters (LimitedSharpenFaster) sub=subsampling
W=720 H=576
DirectShowSource("tape1.avi")
SetMTMode(2)
source=AssumeTFF()
noise=source.nnedi2(field=-2)
supernoise = MSuper(noise)
backward_vec1=supernoise.MAnalyse(isb = true, delta = 1,blksize=8, overlap=4,dct=0, chroma=true, badSAD=1000)
forward_vec1=supernoise.MAnalyse(isb = false, delta = 1,blksize=8, overlap=4,dct=0, chroma=true, badSAD=1000)
backward_vec2=supernoise.MAnalyse(isb = true, delta = 2,blksize=8, overlap=4,dct=0, chroma=true, badSAD=1000)
forward_vec2=supernoise.MAnalyse(isb = false, delta = 2,blksize=8, overlap=4,dct=0, chroma=true, badSAD=1000)
backward_vec3=supernoise.MAnalyse(isb = true, delta = 3,blksize=8, overlap=4,dct=0, chroma=true, badSAD=1000)
forward_vec3=supernoise.MAnalyse(isb = false, delta = 3,blksize=8, overlap=4,dct=0, chroma=true, badSAD=1000)
noise.MDegrain3(supernoise,backward_vec3,backward_vec2,backward_vec1,forward_vec1,forward_vec2,forward_vec3,thSAD=400,thSADc=400,plane=4)
limitedSharpenFaster(last,smode=3,strength=LSF_sharp_ness,overshoot=50, ss_X=LSF_sub, SS_Y=LSF_sub, dest_x=W,dest_y=H)
AssumeTFF().SeparateFields().SelectEvery(4,0,3)
Weave()
All give relatively good result comparing to source.
I think tat first script work better than other espicialy on static background. Also speak me that I need make before reinterlacing (or nothing)?
Please explain.
yup.

R3Z
18th June 2009, 08:10
Hopefully this is right, at least it looks that way when comparing frames between each stage of filtering (using subtract);

http://www.users.on.net/~inet_s51/doom9/test2.jpg

AVISOURCE(....

Bob(0,0.75)

bobbed= last
src = last

super = src.MSuper()
bvec2 = super.MAnalyse(isb=true, delta=2, overlap=8,blksize=16)
bvec1 = super.MAnalyse(isb=true, delta=1, overlap=8,blksize=16)
fvec1 = super.MAnalyse(isb=false, delta=1, overlap=8,blksize=16)
fvec2 = super.MAnalyse(isb=false, delta=2, overlap=8,blksize=16)

src.MDegrain2(super, bvec1, fvec1, bvec2, fvec2)

LimitedSharpenFaster(last,smode=4,strength=180,overshoot=50,soft=30)

comp=last

function DetailBasedGrain(clip src, string "BM", int "dmin", int "dmax", int "grain_str", float "blur_str1",float "blur_str2", float "sharp_str")
{
bm=default(bm,"noise") # BlockBuster Method
dmin=default(dmin,1) # Blockbuster Detail Min
dmax=default(dmax,15) # Blockbuster Detail Max
grain_str=default(grain_str,2) # Grain strength
blur_str1=default(blur_str1,1.5) # Blur Strength
blur_str2=default(blur_str2,0.75) # Blur Strength
sharp_str=default(sharp_str,1) # Sharpen Strength

grain_dist = src.BlockBuster(method=bm,detail_min=dmin,detail_max=dmax,variance=grain_str)
difference = mt_makediff(src, grain_dist, U=1, V=1)
grain_blur = difference.Blur(blur_str1).Blur(blur_str2).Sharpen(sharp_str)
difference2=mt_makediff(src,grain_blur,U=2,V=2)

Blank=BlankClip(width=src.width(), height=src.height(),pixel_type="YV12").ColorYUV(off_y=-128)
PP_Grain=Blank.Addgrain(3,0.2,0.4).Blur(.8)
PP=Overlay(Difference2,PP_Grain,mode="subtract")

return PP
}

DetailBasedGrain(dmax=23,grain_str=12,blur_str2=1.5,blur_str1=1, sharp_str=0.9)

substrong = Subtract(comp,last).Levels(127, 1, 129, 0, 255)

StackHorizontal(src.subtitle("original"),last.subtitle("processed"),substrong.subtitle("amp dif"))

If anyone could help out, i would like to make the second addgrain and blur an option, kind of like an if then else statement. Not sure how to do it yet !