Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion. Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules. |
24th January 2024, 23:28 | #1 | Link |
Registered User
Join Date: Nov 2004
Location: Spain
Posts: 408
|
Strong VHS cleaning
Hi all:
I work mainly with VHS footage.,frecuently very noisy (jitter, swimmering, rainbows). Ordinary strong cleaners do wonderful with noise but, alas, destroy also detail. I've combined two denoisers. The frist do a soft denoinsing, suited to clean less and destroy more detail. I've found that feed mvdegrain with vectors obtained with dct=1 leads to the type of denoise I need. After that, all the noise and detail stealed by the first denoiser is added to the original file, enhancing detail an worsing noise. Then the last step. A strong denoiser than clean well and respect detail. This is the script: Code:
#******************************************************************************************** function VHSClean(clip x ,int "ths" , bool "blur_sharp"){ #******************************************************************************************** ths = default( ths , 100 ) #compromise between strong denoising and detail lost blur_sharp = default( blur_sharp , true ) lambda = 40000 pel = 2 tm = false srhp = 2 srch = 4 badsad = 2000 chroma = true thsc = ths * 2 ths1= ths * 4 thsc1= ths1* 2 bs = 8 bblur = 0.6 csharp = 0.6 # Required planar video (tested on YV16) # Rrequired masktools2, mvtools2. Modern versions # Only tested on VHS footage # Video must be progressive, preferiblely using a good bob deinterlacer sx=x.mSuper(pel=pel, sharp=1) #phase 1. Soft denoising f1x=sx.MAnalyse(delta=1,isb=false,truemotion=tm,blksize=16,blksizev=8,overlap=8,overlapv=4,search=srch,searchparam=srhp,badsad=badsad,dct=1,chroma=chroma,lambda=lambda) b1x=sx.MAnalyse(delta=1,isb= true,truemotion=tm,blksize=16,blksizev=8,overlap=8,overlapv=4,search=srch,searchparam=srhp,badsad=badsad,dct=1,chroma=chroma,lambda=lambda) f2x=sx.MAnalyse(delta=2,isb=false,truemotion=tm,blksize=16,blksizev=8,overlap=8,overlapv=4,search=srch,searchparam=srhp,badsad=badsad,dct=1,chroma=chroma,lambda=lambda) b2x=sx.MAnalyse(delta=2,isb= true,truemotion=tm,blksize=16,blksizev=8,overlap=8,overlapv=4,search=srch,searchparam=srhp,badsad=badsad,dct=1,chroma=chroma,lambda=lambda) x2=x.MDeGrain2(sx, b1x,f1x,b2x,f2x,thSAD=ths,thSADC=thsc) #phase 2. Reinject denoised over original (like a sharpening using blurred version) x3=x.mt_lutxy(x2,expr="x 2 * y -",chroma="process") #phase 3. Strong denoising. Same style as MCDegrainSharp (By Didée and Stainless) x0 = (blur_sharp) ? x3.sharpen(csharp): x3 x1 = (blur_sharp) ? x3.blur(bblur) : x3 sx0 = x0.MSuper(pel=pel, sharp=1,levels=1) # Only 1 Level required for sharpened Super (not MAnalyse-ing) sx1 = x1.MSuper(pel=pel, sharp=1) f1x1=sx1.MAnalyse(delta=1,isb=false,truemotion=tm,blksize=64,blksizev=64,overlap=32,overlapv=32,search=srch,searchparam=srhp,badsad=badsad,dct=0,chroma=chroma,lambda=lambda) b1x1=sx1.MAnalyse(delta=1,isb= true,truemotion=tm,blksize=64,blksizev=64,overlap=32,overlapv=32,search=srch,searchparam=srhp,badsad=badsad,dct=0,chroma=chroma,lambda=lambda) f2x1=sx1.MAnalyse(delta=2,isb=false,truemotion=tm,blksize=64,blksizev=64,overlap=32,overlapv=32,search=srch,searchparam=srhp,badsad=badsad,dct=0,chroma=chroma,lambda=lambda) b2x1=sx1.MAnalyse(delta=2,isb= true,truemotion=tm,blksize=64,blksizev=64,overlap=32,overlapv=32,search=srch,searchparam=srhp,badsad=badsad,dct=0,chroma=chroma,lambda=lambda) f3x1=sx1.MAnalyse(delta=3,isb=false,truemotion=tm,blksize=64,blksizev=64,overlap=32,overlapv=32,search=srch,searchparam=srhp,badsad=badsad,dct=0,chroma=chroma,lambda=lambda) b3x1=sx1.MAnalyse(delta=3,isb= true,truemotion=tm,blksize=64,blksizev=64,overlap=32,overlapv=32,search=srch,searchparam=srhp,badsad=badsad,dct=0,chroma=chroma,lambda=lambda) f4x1=sx1.MAnalyse(delta=4,isb=false,truemotion=tm,blksize=64,blksizev=64,overlap=32,overlapv=32,search=srch,searchparam=srhp,badsad=badsad,dct=0,chroma=chroma,lambda=lambda) b4x1=sx1.MAnalyse(delta=4,isb= true,truemotion=tm,blksize=64,blksizev=64,overlap=32,overlapv=32,search=srch,searchparam=srhp,badsad=badsad,dct=0,chroma=chroma,lambda=lambda) f5x1=sx1.MAnalyse(delta=5,isb=false,truemotion=tm,blksize=64,blksizev=64,overlap=32,overlapv=32,search=srch,searchparam=srhp,badsad=badsad,dct=0,chroma=chroma,lambda=lambda) b5x1=sx1.MAnalyse(delta=5,isb= true,truemotion=tm,blksize=64,blksizev=64,overlap=32,overlapv=32,search=srch,searchparam=srhp,badsad=badsad,dct=0,chroma=chroma,lambda=lambda) f6x1=sx1.MAnalyse(delta=6,isb=false,truemotion=tm,blksize=64,blksizev=64,overlap=32,overlapv=32,search=srch,searchparam=srhp,badsad=badsad,dct=0,chroma=chroma,lambda=lambda) b6x1=sx1.MAnalyse(delta=6,isb= true,truemotion=tm,blksize=64,blksizev=64,overlap=32,overlapv=32,search=srch,searchparam=srhp,badsad=badsad,dct=0,chroma=chroma,lambda=lambda) x4 = x1.MDeGrain6(sx0, b1x1,f1x1,b2x1,f2x1,b3x1,f3x1,b4x1,f4x1,b5x1,f5x1,b6x1,f6x1,thSAD=ths1,thSADC=thsc1) #phase 4. Recover quick flying objects and water drops mx=x4.blur(1.5).mt_lutxy(x3.blur(1.5),expr="y x - abs 12 > 255 0 ?",chroma="process") x4.mt_merge(x3,mx.blur(1.5),luma=true) } Last edited by AVIL; 27th January 2024 at 22:04. |
27th January 2024, 14:10 | #2 | Link |
Registered User
Join Date: Dec 2005
Location: Sweden
Posts: 702
|
Cool script I like the idea alot! Although when trying this out on a bit noisy UHD footage it will show artifacts where motion is. Kinda like "holes" inthe motion blur or where the motion blur should have been if that makes sense.
|
27th January 2024, 22:01 | #4 | Link |
Registered User
Join Date: Nov 2004
Location: Spain
Posts: 408
|
@anton_foy
First, thanks for your feedback. I've not proccessrd UHD video. I suppouse that te compromisoe between the. Soft cleaner and te strong one could be different. For videos of this size, the methode blur-sharp calculates a value of 0.75 for parameter bblur instead the actual valué of 0.6. but i doubt this can resolver the problema. I will try on a UHD video to tune other values, like the blksize at obtainig motion vectors. @Mounir. Many thanks for your observation. Video must be progressive. Its my bad not to mention It in muy script. I do a good bob deinterlacing bafore start denoising the video. I will edit the scriot and also give your script a try |
28th January 2024, 09:53 | #5 | Link |
Registered User
Join Date: Nov 2004
Location: Spain
Posts: 408
|
@anton_foy
Thinking about UHD video, as distances in pixeles can be four times greater than in VHS could be resasonable also raise the value of searchparam. Change, please the value of parameter srhp from 2 to 8 or greater |
28th January 2024, 13:51 | #6 | Link |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
|
Maybe try convert to 16 bit before MvTools stuff, and back to 8 bit at end of script.
For 8 bit, vectors in vector clip are limited to signed 8 bit, ie -128 -> +127 for PEL distance (about 64 pixels @ pel=2, 32 for pel=4), 16 bit allows for greater vector length (pixel distance) in vector clips. Maybe makes a difference, maybe not. [Good for that "Placebo feel good factor"]
__________________
I sometimes post sober. StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace "Some infinities are bigger than other infinities", but how many of them are infinitely bigger ??? Last edited by StainlessS; 28th January 2024 at 16:12. |
29th January 2024, 17:41 | #7 | Link |
Registered User
Join Date: Oct 2001
Location: Germany
Posts: 7,259
|
Side note: did try a 'quick' port to Vapoursynth (not totally sure everything is correct)
|
Thread Tools | Search this Thread |
Display Modes | |
|
|