PDA

View Full Version : Comparing MVDeGrain2 to DeGrainMedian or FFT3DFilter


Chainmax
2nd June 2007, 16:31
I have done a couple of test comparisons between MVDeGrain2 and other denoisers, but haven't been able to assess MVDeGrain2's noise removal strength and amount of detail removal. How would you say a default call (with thSAD=400) would compare to DeGrainMedian() and FFT3DFilter(sigma=1) in those two regards?

*.mp4 guy
2nd June 2007, 19:40
Mvdegrain2 gets rid of about the same amount of noise as degrainmedian(mode=3).fft3dfilter(bw=16, bh=16, ow=8, oh=8, bt=4, sigma=2.5, sigma2=3, sigma3=3.5, sigma4=3), but the noise removal is more consistant (fft3dfilter leaves some blurred noise behind, mvdegrain doesn't) and there is essentially no detail loss (detail loss is about the same as fft3dfilter(bw=8, bh=8, ow=4, oh=4, sigma=0.5)), Mvedegrain also removes banding and in some cases apears to increase color depth (usually when dealing with slightly overcompressed, noisy, high quality mpeg2 sources) whereas degrainmedian, fluxsmoothST, fft3dfilter, dn3d, etc. all cause banding and reduce effective colordepth. The biggest advantage of motion compensated denoising, is not that it is inherently stronger at noise removal, its that it is inherently better at avoiding removing stuff that isn't noise.

Chainmax
2nd June 2007, 20:13
Oh, I'm asking about how strong a default call is in order to know how to adjust it for noisier/cleaner source. So its denoising strength would be somewhere in the middle of the two options I described and adding a quite a few extra benefits. By the way, since you talk about banding, what would be the drawbaks of using a high thr (like 2.4 or 3.0) in gradfun2db? How would a default call to MVDeGrain2 compare to that? What about its chroma denoising, how would you compare to my current favorite (FFT3DFilter on chroma with a sigma of 3)?

Terranigma
2nd June 2007, 21:02
Oh, I'm asking about how strong a default call is in order to know how to adjust it for noisier/cleaner source. So its denoising strength would be somewhere in the middle of the two options I described and adding a quite a few extra benefits.

thsad, iirc, is not the strength parameter for mvdegrain, Overlap is. Mvdegrain works much better if you were to use an overlap value that's equaled to blocksize
(e.g. blksize = 8, overlap=8/2) & dct set to 2. Dct 1 & 2 is very slow, with dct2 being a tad bit slower than 1.

You know, if never hurts to test for yourself. ;)

Chainmax
3rd June 2007, 02:31
From MVDeGrain2's section in MVTool's readme:

The filtering strength is controlled by "thSAD" parameter. It defines threshold of block sum absolute differences. You must enter thSAD value reduced to block size 8x8. The greater the SAD, the lesser the weight. Block with SAD above threshold thSAD have a zero weigtht.
Default thSAD=400.

What I don't completely grasp is wether higher strength is achieved with lower or higher thSAD settings though.

As for testing myself, IMHO testing only makes sense when there's no knowledge on the matter. Case in point: *.mp4guy's answer, he was much more informative than the couple of tests I'd have done.

Terranigma
3rd June 2007, 03:12
From MVDeGrain2's section in MVTool's readme:

Yes, I read that, but I remember seeing something from another post where Fizick said something else.
I'll try and find it ;)

Chainmax
3rd June 2007, 03:26
Thanks, I appreciate it :).

Terranigma
3rd June 2007, 03:28
Thanks, I appreciate it :).

here (http://forum.doom9.org/showthread.php?p=926329#post926329) you go.

Chainmax
3rd June 2007, 05:11
I see, thanks. The example call in the readme uses defaults on those settings, so blksize=8 and overlap=4. Should I switch to blksize=4, overlap=2? What would thSAD affect then?

Terranigma
3rd June 2007, 18:08
I see, thanks. The example call in the readme uses defaults on those settings, so blksize=8 and overlap=4. Should I switch to blksize=4, overlap=2? What would thSAD affect then?
blksize of 4 is very slow, slower than dct2, so i would only recommend it to be used on letterboxed clips. Larger block sizes, like the doc. says, is less sensitive to noise. 4 would be better than 8, but the quality tradeoff in favor of speed isn't worth it, so just stick with a blksize of 8. If you want better m.e., you could change the search parameter in mvanalyse to 3, and increase the searchparam, to maybe like 12 (with dct2 of course). Or alternatively you could try *.mp4 guy's suggestions here (http://forum.doom9.org/showthread.php?p=964755#post964755) and here (http://forum.doom9.org/showthread.php?p=920050#post920050).

The only thing I would modify/change from what he came up with, is the analysis part, and maybe remove Degrainmedian in favor of better speed & denoising by adding dct 1 or 2 to the mix:

backward_vec2 = source.MVAnalyse(isb=true, delta=2,pel=2,overlap=8/2,idx=1,dct=2)
backward_vec1 = source.MVAnalyse(isb=true, delta=1,pel=2,overlap=8/2,idx=1,dct=2)
forward_vec1 = source.MVAnalyse(isb=false, delta=1,pel=2,overlap=8/2,idx=1,dct=2)
forward_vec2 = source.MVAnalyse(isb=false, delta=2,pel=2,overlap=8/2,idx=1,dct=2)

I'm not 100% sure how thsad works, so I really can't comment on that. =P

foxyshadis
3rd June 2007, 18:53
thSAD is more threshold than strength. If it's low more blocks will be thrown away, if you raise it too high, bad blocks will start getting used in the cleaning.

elguaxo
3rd June 2007, 19:39
I always liked a mild DegrainMedian/FFT3DFilter combo. And if neccesary I applied a second instance of FFT3DFilter just for a stronger Chroma denoising.

I was introduced to MVDeGrain2 by one of the *.mp4 guy's scripts. And now I am using for example this for mild denoising:
vbw1=MVAnalyse(isb=true,truemotion=true,delta=1,pel=2,chroma=true,blksize=8,overlap=2,idx=1,sharp=1)
vfw1=MVAnalyse(isb=false,truemotion=true,delta=1,pel=2,chroma=true,blksize=8,overlap=2,idx=1,sharp=1)
vbw2=MVAnalyse(isb=true,truemotion=true,delta=2,pel=2,chroma=true,blksize=8,overlap=2,idx=1,sharp=1)
vfw2=MVAnalyse(isb=false,truemotion=true,delta=2,pel=2,chroma=true,blksize=8,overlap=2,idx=1,sharp=1)
MVDegrain2(last,vbw1,vfw1,vbw2,vfw2,thSAD=100,idx=2)

Now my questions. Since most of the time it is safe to apply a little stronger chroma denoising, does it makes sense to apply some FFT3DFilter on plane=3 after MVDegrain2 for that? And if I don't use FFT3DFilter, how can I apply a second instance of MVDegrain2 just for a little stronger chroma deonising?

Thanks!

ChrisW77
3rd June 2007, 20:20
I love MVTools, even though I still don't quite know what I'm doing.
After reading through many, many threads, I've come up with the following


source=ConvertToYV12(interlaced=true).Crop(10,4,-10,-10,align=true).Addborders(10,7,10,7)
fields=source.AssumeTFF().SeparateFields().DeGrainMedian(mode=2).RemoveGrain(mode=2)

backward_vec2 = fields.MVAnalyse(isb=true, search=2, truemotion=true, lambda=512, delta=2, pel=2, blksize=16, overlap=8, sharp=1, idx=1)
backward_vec1 = fields.MVAnalyse(isb=true, search=2, truemotion=true, lambda=512, delta=1, pel=2, blksize=16, overlap=8, sharp=1, idx=1)
forward_vec1 = fields.MVAnalyse(isb=false, search=2, truemotion=true, lambda=512, delta=1, pel=2, blksize=16, overlap=8, sharp=1, idx=1)
forward_vec2 = fields.MVAnalyse(isb=false, search=2, truemotion=true, lambda=512, delta=2, pel=2, blksize=16, overlap=8, sharp=1, idx=1)
fields.MVDegrain2(backward_vec1,forward_vec1,backward_vec2,forward_vec2,thSAD=400,idx=1).MVDenoise(backward_vec2,backward_vec1,forward_vec1,forward_vec2,tht=10,thSAD=400)
Weave()


I'm not even sure if thats correct, lol, but it sure looks nice on some of my VHS caps. I wanted to keep them interlaced, crop off overscan, and VHS tape noise, and add black borders to keep the full resolution.

This one

source=ConvertToYV12(interlaced=true)
fields=source.AssumeTFF().SeparateFields().DeGrainMedian(mode=4).RemoveGrain(mode=1)

backward_vec2 = fields.MVAnalyse(isb=true, search=1, lambda=256, delta=2, pel=1, blksize=16, overlap=8, sharp=1, idx=1)
backward_vec1 = fields.MVAnalyse(isb=true, search=1, lambda=256, delta=1, pel=1, blksize=16, overlap=8, sharp=1, idx=1)
forward_vec1 = fields.MVAnalyse(isb=false, search=1, lambda=256, delta=1, pel=1, blksize=16, overlap=8, sharp=1, idx=1)
forward_vec2 = fields.MVAnalyse(isb=false, search=1, lambda=256, delta=2, pel=1, blksize=16, overlap=8, sharp=1, idx=1)
fields.MVDegrain2(backward_vec1,forward_vec1,backward_vec2,forward_vec2,thSAD=400,idx=1)
Weave()


I use on DVB-T caps, that have a bit of background noise in them. I found it works well, and quite speedy, for MVTools :p

Terranigma
3rd June 2007, 20:55
I always liked a mild DegrainMedian/FFT3DFilter combo. And if neccesary I applied a second instance of FFT3DFilter just for a stronger Chroma denoising.

I was introduced to MVDeGrain2 by one of the *.mp4 guy's scripts. And now I am using for example this for mild denoising:
vbw1=MVAnalyse(isb=true,truemotion=true,delta=1,pel=2,chroma=true,blksize=8,overlap=2,idx=1,sharp=1)
vfw1=MVAnalyse(isb=false,truemotion=true,delta=1,pel=2,chroma=true,blksize=8,overlap=2,idx=1,sharp=1)
vbw2=MVAnalyse(isb=true,truemotion=true,delta=2,pel=2,chroma=true,blksize=8,overlap=2,idx=1,sharp=1)
vfw2=MVAnalyse(isb=false,truemotion=true,delta=2,pel=2,chroma=true,blksize=8,overlap=2,idx=1,sharp=1)
MVDegrain2(last,vbw1,vfw1,vbw2,vfw2,thSAD=100,idx=2)

Now my questions. Since most of the time it is safe to apply a little stronger chroma denoising, does it makes sense to apply some FFT3DFilter on plane=3 after MVDegrain2 for that? And if I don't use FFT3DFilter, how can I apply a second instance of MVDegrain2 just for a little stronger chroma deonising?

Thanks!

Degrainmedian's ok, but with dct2and fft3dfilter using plane 4, it's not really needed imo. Here's what i use (Warning.. SLOOOOW)
width=default(width,720)
height=default(height,480)
fields = last
backward_vec2 = fields.MVAnalyse(isb=true, delta=2,pel=2,overlap=8/2,dct=2)
backward_vec1 = fields.MVAnalyse(isb=true, delta=1,pel=2,overlap=8/2,dct=2)
forward_vec1 = fields.MVAnalyse(isb=false, delta=1,pel=2,overlap=8/2,dct=2)
forward_vec2 = fields.MVAnalyse(isb=false, delta=2,pel=2,overlap=8/2,dct=2)
maskp1 = mvmask(kind=1, vectors=forward_vec1, ysc=255).UtoY()
maskp2 = mvmask(kind=1, vectors=forward_vec2).UtoY()
maskp3 = mvmask(kind=1, vectors=backward_vec1, ysc=255).UtoY()
maskp4 = mvmask(kind=1, vectors=backward_vec2).UtoY()
maskf = average(maskp1, 0.25, maskp2, 0.25, maskp3, 0.25, maskp4, 0.25).Spline36Resize(width,height)
smooth = fields.fft3dfilter(bw=16, bh=16, bt=3, sigma=7.9, plane=4)
fields2 = maskedmerge(fields, smooth, maskf)
fields2.MVDegrain2(backward_vec1,forward_vec1,backward_vec2,forward_vec2,plane=4,thSAD=400)
RemoveGrain(0,11).gradfun2db(1.5)

It's a modified version of .mp4 guy's suggestion without the utoy(), degrainmedian(), or idx values in mvanalyse. Yup, no idx. idx can sometimes cause problems so i opt not to use it. By the way, have you seen This (http://forum.doom9.org/showthread.php?t=114582) thread started by Fizick?

elguaxo
3rd June 2007, 21:07
Thanks for the tips Terranigma, gonna try your script! But I meant FFT3DFilter just on plane=3 for stronger Chroma denoising, not plane=4.

Terranigma
3rd June 2007, 21:12
Thanks for the tips Terranigma, gonna try your script! But I meant FFT3DFilter just on plane=3 for stronger Chroma denoising, not plane=4.
I knew what you meant, but it would've been misleading if i'd of set the plane to 3 when I myself use 4. :p

ChrisW77
3rd June 2007, 22:25
being you seem to know everything, I thought you might have had the decency to comment on mine :p

oh well.

*.mp4 guy
3rd June 2007, 22:30
@Terranigma
Without utoy() the mask doesn't actually do anything (fft3dfilter won't process any of the video)... mvanalyse should also have truemotion=true, otherwise it looks good.

@ChrisW77
your script is a completely standard mvdegrain call, it should work fine. fyi If you used slower mvanalyse settings, quality would be better, but your probably trying to speed it up.

Terranigma
3rd June 2007, 22:44
@Terranigma
Without utoy() the mask doesn't actually do anything (fft3dfilter won't process any of the video)... mvanalyse should also have truemotion=true, otherwise it looks good.

Thanks *.mp4 guy. I seem to learn something new everyday, btw, isn't truemotion=true enabled by default? :)

Boulder
4th June 2007, 10:54
Degrainmedian's ok, but with dct2and fft3dfilter using plane 4, it's not really needed imo.Unfortunately the DegrainMedian call is not OK because it is a spatio-temporal filter. The top field will be processed against the bottom field which will make sure that DGM will see slight motion everywhere. Once again, I'd rather smartbob the stream than use SeparateFields().

ChrisW77
4th June 2007, 13:24
your script is a completely standard mvdegrain call, it should work fine. fyi If you used slower mvanalyse settings, quality would be better, but your probably trying to speed it up.

Not trying to doing anything, other than the difficulty of getting responses on this forum.
Every time I read a MVTools thread, I read with anticipation, every reply hoping that at least someone answers the OP's question and goes into detail, rather than just simply saying it's fine.

Not having a go or anything, it can be frustrating when you are still learning. I've read a lot of threads here, old and new, and I'll keep my eye on this one hoping someone goes into detail.

Terranigma
4th June 2007, 15:53
Unfortunately the DegrainMedian call is not OK because it is a spatio-temporal filter. The top field will be processed against the bottom field which will make sure that DGM will see slight motion everywhere. Once again, I'd rather smartbob the stream than use SeparateFields().
Well It's not in my mod anyways. :)
How would you use bob to what I posted on the first page?

*.mp4 guy
4th June 2007, 16:41
@Terranigma
I don't know what truemotions default is, I thought it was false, but maybe things have changed.

@ChrisW77
1 - your not the OP, thats chainmax, I answered his question as well as I could.

2 - into detail about what? The only thing that you did differently in your script then the example in the mvtools documentation was using faster mvanalyse, which I commented on.

[edit]
@Boulder
Terranigma's script wasn't posted in reply to ChrisW77 so there is no reason to make sure it works on interlaced/field separated clips.

@ChrisW77
Boulder is right, you should use a smart bobber instead of field separation, I didn't notice you were working on interlaced material.

ChrisW77
4th June 2007, 18:18
@ChrisW77
Boulder is right, you should use a smart bobber instead of field separation, I didn't notice you were working on interlaced material.

Ok, thanks, Didn't mean to take over the OP's post, or anything, merely try to add something.
Smart Bobbing, is a no go, even though it looks nice on my PC, I'm archiving my old VHS tapes to DVD, and want to preserve 25fps interlace, to play back on a standard DVD player.

Thanks anyway.

Didée
4th June 2007, 18:28
@ ChrisW77 - smart bobbing does not interfere with keeping the original interlacing. In this context, the goal of smart bobbing is just to give the motion engine a "better" base to perform motion search & compensation on, and consequently to get a better result in the end. The original fields of the source are preserved anyway by smart bobbing - it's the quality of the denoising result that should improve by using a smart bobbed source rather than just separated fields.

Terranigma
4th June 2007, 18:47
@ ChrisW77 - smart bobbing does not interfere with keeping the original interlacing. In this context, the goal of smart bobbing is just to give the motion engine a "better" base to perform motion search & compensation on, and consequently to get a better result in the end. The original fields of the source are preserved anyway by smart bobbing - it's the quality of the denoising result that should improve by using a smart bobbed source rather than just separated fields.
Didée, could you please enlighten me on the correct way how i'd go about using a smart bob (such as dgbob) with the code I have posted in my earlier post? :D I would really appreciate your advice. :)

Boulder
4th June 2007, 18:48
@ChrisW77 and Terranigma: this is what I usually use as the basis for encoding my (interlaced) DVB-C captures to MPEG2.
MPEG2Source("path\clip.d2v",cpu=4)
Load_Stdcall_Plugin("c:\progra~1\avisynth 2.5\cplugins\yadif.dll")
YADIF(mode=1) # bob the stream to 50fps, full frame height
vbw1=MVAnalyse(isb=true,truemotion=true,delta=1,pel=2,chroma=false,blksize=16,idx=1,sharp=2)
vfw1=MVAnalyse(isb=false,truemotion=true,delta=1,pel=2,chroma=false,blksize=16,idx=1,sharp=2)
vbw2=MVAnalyse(isb=true,truemotion=true,delta=2,pel=2,chroma=false,blksize=16,idx=1,sharp=2)
vfw2=MVAnalyse(isb=false,truemotion=true,delta=2,pel=2,chroma=false,blksize=16,idx=1,sharp=2)
MVDegrain2(last,vbw2,vfw2,vbw1,vfw1,thSAD=400,idx=1)
Limiter()
SeparateFields() # reinterlace with these last three lines
SelectEvery(4,0,3)
Weave()There's a thousand ways to tweak the script. Overlapping is a no-go for me with interlaced sources as the speed is too slow even for me (but I do use an overlap of 8 pixels for progressive sources). I can leave the computer running 24/7 but I just usually have too much captures to process.

Terranigma
4th June 2007, 18:55
Thanks Boulder for the example, really appreciate it :)

ChrisW77
4th June 2007, 19:09
@ ChrisW77 - smart bobbing does not interfere with keeping the original interlacing. In this context, the goal of smart bobbing is just to give the motion engine a "better" base to perform motion search & compensation on, and consequently to get a better result in the end. The original fields of the source are preserved anyway by smart bobbing - it's the quality of the denoising result that should improve by using a smart bobbed source rather than just separated fields.

I appreciate the reply, Didée, that explanation really helps. :)
Just one thing, wouldn't your final file (mine would be a huffy lossless file that I save out to) be now 50fps, and would require a 50fps compatible TV ? Sorry to sound a bit thick.

And Boulder, thats a really nice, interesting script, I'm going to borrow that a moment, and see what happens ;)

Just a quick question, if you don't mind,
What does this actually do ?

SelectEvery(4,0,3)

I see it a lot, in many people's scripts, but can't quite grasp what it's meant for.

Terranigma
4th June 2007, 19:22
Just a quick question, if you don't mind,
What does this actually do ?

SelectEvery(4,0,3)

I see it a lot, in many people's scripts, but can't quite grasp what it's meant for.To reinterlace the source. Boulder commented it out ;)
SeparateFields() # reinterlace with these last three lines
SelectEvery(4,0,3)
Weave()

Didée
4th June 2007, 19:36
The (smart-) bobbing turns 25i into 50p, i.e. it takes the half-heighted fields and makes them fullsized frames, by smart-interpolating the missing scanlines.

[... here comes the motion stuff, working better on full frames than on separated fields ...]

Afterwards, the code SeparateFields().SelectEvery(4,0,3).Weave() takes the 50p, dismisses the interpolated scanlines and constructs 25i again, using only the original scanlines. This part is usually called "Reinterlacing".

ChrisW77
4th June 2007, 19:44
Many thanks, chaps, I now see what you are saying.

I'm going to try a few 5 mins clips, using some of the suggestions in this thread.
I'm going to try moving some filters around to see what happens, and even try this

SeparateFields() # reinterlace with these last three lines
SelectEvery(4,0,3)
DeGrainMedian(mode=2)
RemoveGrain(mode=2)
Weave()

at the end.
Thanks again, and sorry to Chainmax, didn't mean to intervene in your thread. :)

Boulder
4th June 2007, 19:56
No no, don't do it that way, it doesn't work. Reinterlacing needs to be at the end of the script. Everything else should be between the smart bobber and the reinterlacing part.

ChrisW77
4th June 2007, 21:06
No no, don't do it that way, it doesn't work. Reinterlacing needs to be at the end of the script. Everything else should be between the smart bobber and the reinterlacing part.

Haha, I was just about to start some tests, but thought it might be better to see if I was wrong. Thanks again, Boulder. :)

Terranigma
4th June 2007, 22:48
Boulder, would you have an idea as to why i'd see artifacts on certain frames using a bobber (even plain bob()) using either dct 1, 2, or 4 (for MVAnalyse)? Dct 0 and 3 works just fine. It's not really a problem, per se, it's just me being curious. :devil:

Edit: Oops! My Mistake. It has nothing to do with bob. it's just dct, so now I see why Fizick said that these modes are experimental.
Adaptive switchin is hard to impement: spatial and dct SAD are not coinside, so some osclillation.

All other DCT modes are experimental too (mode dct=3 has a bug, it will be fixed soon in new beta).

Whatever this bug is in mode 3, I hope I don't encounter it :D

Chainmax
5th June 2007, 00:30
After reading this thread (http://forum.doom9.org/showthread.php?p=964755#post964755) that Terranigma linked to, it seems that the way to increase denoising is indeed to use higher values of thSAD.

Terranigma
5th June 2007, 00:47
After reading this thread (http://forum.doom9.org/showthread.php?p=964755#post964755) that Terranigma linked to, it seems that the way to increase denoising is indeed to use higher values of thSAD.

Well sorta. You have to take in account to what foxyshadis said:
thSAD is more threshold than strength. If it's low more blocks will be thrown away, if you raise it too high, bad blocks will start getting used in the cleaning.
After doing some tests with higher values of thsad, it seems that 400 is the safest value to use. Try setting it to 800, and examine the frame(s) closely. Depending on the source, you might notice some areas will show signs of combing. Overlap is useful to prevent blocking and avoid destroying details; the higher the value, the more efficient it is (The slower the processing too). Back to your question, mvdegrain fares better than fft3d and degrainmedian in certain aspects, fft3d fares better than mvdegrain and degrainmedian in certain aspects, and degrainmedian fares better than fft3d and mvdegrain in certain aspects. If I were you, i'd use a combination of all 3, but would only add degrainmedian if there was a call for seesaw somewhere.

I've learned a lot from this thread, and I have you to thank for creating it. :)

*.mp4 guy
5th June 2007, 09:33
After reading this thread (http://forum.doom9.org/showthread.php?p=964755#post964755) that Terranigma linked to, it seems that the way to increase denoising is indeed to use higher values of thSAD.
Increasing thSAD only increases denoising on really ugly sources, like the ones being discussed in the thread you linked to. on a good source, even with very strong grain, raising thSAD doesn't help and causes to many artifacts.

raziel666
5th June 2007, 09:49
Pretty interesting discussion here. :) I have some questions I would like to ask:
1) Does the use of "clip2x" improve the denoising ?
2) Is it recommended to apply some sort of sharpening after the denoising part?
3) I have some overlays I want to apply, should I apply them before or after the denoising part?
4) I can't seem to find the average() and maskedmerge() functions and because of this avisynth keeps throwing me errors.
Any help would be appreciated.

Boulder
5th June 2007, 10:42
Average and MaskedMerge are possibly from MaskTools v1.5.x. If you need sharpening, you might want to check out SeeSaw and use the result of MVDegrain2 as the denoised clip there.

foxyshadis
5th June 2007, 13:13
clip2x just lets you choose the hpel resizer, rather than using the default bilinear. It can lead to better motion compensation and a somewhat sharper output, if you use, say, lanczos or spline. I haven't tested thoroughly, only a few experiments that didn't show a big effect.

Sharpening is one of those taste things, we can't tell you what you'll like. :p If you do use SeeSaw with it, you'll want to tune the parameters to keep more of the denoised input, probably, since the defaults prefer the original over the denoised.

Didée
5th June 2007, 14:00
After reading this thread (http://forum.doom9.org/showthread.php?p=964755#post964755) that Terranigma linked to, it seems that the way to increase denoising is indeed to use higher values of thSAD.

Think about what you were doing when the roof is leaking:
- If it's sufficient to put a bucket below, then use higher thSAD in MVDegrain.
- If you prefer sealing the roof, then make it so that present noise doesn't influence SAD calculation. :)

elguaxo
5th June 2007, 15:12
- If you prefer sealing the roof, then make it so that present noise doesn't influence SAD calculation. :)

:eek: How can we try to do this?

ChrisW77
5th June 2007, 17:31
In the end, I've settled with this


setmemorymax(768)
Load_Stdcall_Plugin("C:\Program Files\AviSynth\plugins\yadif.dll")
LoadPlugin("C:\Program Files\AviSynth\plugins\RemoveGrainSSE2.dll")
LoadPlugin("C:\Program Files\AviSynth\plugins\FluxSmooth.dll")
LoadPlugin("C:\Program Files\AviSynth\plugins\MVTools.dll")
LoadPlugin("C:\Program Files\AviSynth\plugins\DeGrainMedian.dll")
LoadPlugin("C:\Program Files\AviSynth\plugins\DGDecode.dll")
LoadPlugin("C:\Program Files\AviSynth\plugins\mpasource.dll")

SetMTMode(2,0) # Not sure if any gain in this line
video=mpeg2source("E:\Videos\OLDVHS\project1.d2v", cpu=6, iPP=true, idct=3)
audio=MPASource("E:\Videos\OLDVHS\project1 T01 DELAY 0ms.mpa", normalize = false)
AudioDub(video, audio)

AssumeTFF()
yadif(mode=1,order=1) # Bobbed to 50fps

SetMTMode(0) # For MVTools as it doesn't seem to play nicely with dual core
source=ConvertToYV12(interlaced=true)
fields=source.DeGrainMedian(mode=1,interlaced=true).RemoveGrain(mode=2)

vbw1=fields.MVAnalyse(isb=true,truemotion=true,delta=1,pel=2,chroma=false,blksize=16,overlap=8,sharp=2,idx=1)
vfw1=fields.MVAnalyse(isb=false,truemotion=true,delta=1,pel=2,chroma=false,blksize=16,overlap=8,sharp=2,idx=1)
vbw2=fields.MVAnalyse(isb=true,truemotion=true,delta=2,pel=2,chroma=false,blksize=16,overlap=8,sharp=2,idx=1)
vfw2=fields.MVAnalyse(isb=false,truemotion=true,delta=2,pel=2,chroma=false,blksize=16,overlap=8,sharp=2,idx=1)
MVDegrain2(last,vbw2,vfw2,vbw1,vfw1,thSAD=800,idx=1).MVDenoise(vbw2,vfw2,vbw1,vfw1,tht=10,thSAD=800)
Crop(10,4,-14,-10,align=true).Addborders(12,7,12,7)
Limiter()
SeparateFields() # reinterlace
SelectEvery(4,0,3)
Weave()

MT("a = last
b = a.FluxSmoothT(3)
SeeSaw(a,b, NRlimit=1, NRlimit2=5, Sstr=3.0, Szp=10, Slimit=20, ssx=1.2, ssy=1.2, Sdamplo=10, Spower=5, sootheT=50, sootheS=50,SdampHi=35, bias=90)",2,2)


The source is from old VHS tapes going back over the last 20 years, most of which have been recorded in Long-Play Mode, from a UHF Aerial Source, and the odd analogue Satellite cap.
It's a bit strong, and the SeeSaw settings are strong, but the tests I've done look great, if a little soft, but not really noticeable on a CRT TV.

Many thanks to all, a really interesting thread, as most are, on this forum :)

Boulder
5th June 2007, 17:35
@elguaxo: By using a denoised clip for the MVAnalyse parts and then the original clip for MVDegrain2. EDIT: Just make sure you don't use the same idx value for both MVAnalyse and MVDegrain2.

@foxyshadis: Doesn't sharp=2 (the default) already use a Lanczos-like resizer for the interpolation?

Boulder
5th June 2007, 17:37
@ChrisW77: Don't use interlaced=true in DegrainMedian, your clip is progressive after the bobbing part. You also probably don't need CPU=6 as the deringing tends to soften the image quite a bit. If you need dehaloing/deringing, there are better alternatives. EDIT: Also remove the interlaced=true parameter from ConverttoYV12().

You also must place the SeeSaw part before reinterlacing.

elguaxo
5th June 2007, 17:39
:thanks:

ChrisW77
5th June 2007, 18:42
@ChrisW77: Don't use interlaced=true in DegrainMedian, your clip is progressive after the bobbing part. You also probably don't need CPU=6 as the deringing tends to soften the image quite a bit. If you need dehaloing/deringing, there are better alternatives. EDIT: Also remove the interlaced=true parameter from ConverttoYV12().

You also must place the SeeSaw part before reinterlacing.

I didn't spot those, many thanks. I'm still learning :D

You also probably don't need CPU=6 as the deringing tends to soften the image quite a bit.

Some of the old shows I'm doing have a lot of overlaid text that pop up to describe the current scene, and there is quite a bit of dehaloing going on. I've tried Didée's dehalo_alpha, but it didn't seem strong enough, though it preserved the most detail.
Again, thanks for all your help. I'm beginning to see where I go wrong, and how to do certain things better.

Chainmax
6th June 2007, 04:57
Didée, Boulder: so something like this

source=last
backward_vec2 = source.DeGrainMedian(mode=3).MVAnalyse(isb = true, delta = 2, pel = 2, overlap=4, sharp=1, idx = 1)
backward_vec1 = source.DeGrainMedian(mode=3).MVAnalyse(isb = true, delta = 1, pel = 2, overlap=4, sharp=1, idx = 1)
forward_vec1 = source.DeGrainMedian(mode=3).MVAnalyse(isb = false, delta = 1, pel = 2, overlap=4, sharp=1, idx = 1)
forward_vec2 = source.DeGrainMedian(mode=3).MVAnalyse(isb = false, delta = 2, pel = 2, overlap=4, sharp=1, idx = 1)
source.MVDegrain2(backward_vec1,forward_vec1,backward_vec2,forward_vec2,thSAD=400,idx=2)

then? Does the idx have to be different for MVAnalyse and MVDeGrain2 only on this scenario or always? In any case, if these settings still aren't enough then do I just have to add another denoiser?

Boulder
6th June 2007, 05:13
A bit more simple approach would be
source=last
denoised=DegrainMedian(mode=3)
backward_vec2 = MVAnalyse(denoised,isb = true, delta = 2, pel = 2, overlap=4, sharp=1, idx = 1)
backward_vec1 = MVAnalyse(denoised,isb = true, delta = 1, pel = 2, overlap=4, sharp=1, idx = 1)
forward_vec1 = MVAnalyse(denoised,isb = false, delta = 1, pel = 2, overlap=4, sharp=1, idx = 1)
forward_vec2 = MVAnalyse(denoised,isb = false, delta = 2, pel = 2, overlap=4, sharp=1, idx = 1)
MVDegrain2(source,backward_vec1,forward_vec1,backward_vec2,forward_vec2,thSAD=400,idx=2)You need different idx's when the source clips are different. If you use the exact same source clip for MVAnalyse and MVDegrain2, you can (and should) use the same idx.

raziel666
6th June 2007, 08:41
Still trying to use Terranigma's script, but I keep getting messages that avisynth doesn't know an AVERAGE() function. I've tried masktools 1.5.8 and some 2.0 alpha and had no luck with them. Does anyone know in which plugin this function exists?

*.mp4 guy
6th June 2007, 09:54
:search: Its an independant plugin, specifically for quickly averaging clips together.

Didée
6th June 2007, 10:54
Average is a bit difficult to find, since Clouded/mg262's page is offline. Some time back, Wilbert did put most of his stuff online, but I can't find the link right now ...

Average_24Oct05.dll (http://home.arcor.de/dhanselmann/_stuff/Average_24Oct05.dll)

raziel666
6th June 2007, 14:23
Thanks a lot for the link! Gonna try it tonight and see what happens...

Wilbert
6th June 2007, 23:18
Average is a bit difficult to find, since Clouded/mg262's page is offline. Some time back, Wilbert did put most of his stuff online, but I can't find the link right now ...
It's listed in the sticky:

http://forum.doom9.org/showthread.php?t=118430

I don't have the source of the Average plugin though ;(

yup
9th June 2007, 08:04
Hi folk!
Good thread.
We can join power MVAnalyse and FFT3d plugin
backward_vectors = source.MVAnalyse(isb = true, truemotion=true, delta = 1, idx = 1)
forward_vectors = source.MVAnalyse(isb = false, truemotion=true, delta = 1, idx = 1)
forward_compensation = source.MVFlow(forward_vectors, idx=1, thSCD1=500) backward_compensation = source.MVFlow(backward_vectors, idx=1, thSCD1=500)
mask_backward=MVMask (kind=2, backward_vectors)
mask_forward=MVMask (kind=2, forward_vectors)
mask_backward = mt_binarize(mask_backward,threshold=254)
mask_ forward = mt_binarize(mask_ forward,threshold=254)
mask_tot= mt_logic(mask_backward, mask_ forward,mode="or")
interleave(forward_compensation, source, backward_compensation)
FFT3DFilter(bt=3)
filteredmotion=Selectevery(3,1)
filtered= FFT3DFilter(bt=1)
mt_merge(filteredmotion, filtered, mask_tot)

I sure that this script have error, last time I teaching MVTools, but mt_masktools not yet. Idea very simple use motion compensated frame for use FFT3D in bt=3 mode and use FFT3D in bt=1 for occlusion block. We can also use Deblock for mask_tot. Please advice how can make this script really work.
With kind regards yup.

HisDivineShadow
15th June 2007, 07:41
I'm really finding this filter setup quite interesting. I do have some questions though.

1) My sources are PAL (retail dvd's - yes I own them), and 99% of the time progressive. Is there any adjustments that I should make for this? It just seems most of the scripts in this thread are for interlaced sources.

2) Testing some of the scripts I find nearly all the detail is preserved (which is good), however any scene that has rain or deliberate noise (eg. flashback) is somewhat butchered. Can I lower the sensitivity to compensate for that?

I used to be a fan of FFT3D filter, but find it leaves ringing and banding on high noise sources. These scripts dont give me that problem.

Speed is not really a concern, though even I would admit that encoding at .05fps would be a pain ;)

yup
15th June 2007, 08:14
HisDivineShadow You try my test script?
If yes could change line
mask_tot= mt_logic(mask_backward, mask_ forward,mode="or")
In this case we could use 2D filtering for block which have occlusions in both directions (forward and backward).
For speedup
1) MVAnalyse try use blksize=16, without overlap, chroma=false and dct=0, processing faster quality worst.
2) FFT3Dfilter use high value bw and bh.
This only draft we can tune more parameters for MVTools and FFT3Dfilter, for this we need help from guru script writers. Please help and advice.

With kind regards yup.

HisDivineShadow
15th June 2007, 08:25
yup,

What am I changing that line to? Seems the same as whats in your script.

I get a script error with yours. "Script error: expected a , or )"

yup
17th June 2007, 17:15
HisDivineShadow!
Try this script:
LoadPlugin("mt_masktools.dll")
source=AVISource("test.avi")
backward_vectors = source.MVAnalyse(isb = true, truemotion=true, delta = 1, idx = 1)
forward_vectors = source.MVAnalyse(isb = false, truemotion=true, delta = 1, idx = 1)
forward_compensation = source.MVFlow(forward_vectors, idx=1, thSCD1=500)
backward_compensation = source.MVFlow(backward_vectors, idx=1, thSCD1=500)
mask_backward=source.MVMask (kind=2, backward_vectors)
mask_forward=source.MVMask (kind=2, forward_vectors)
mask_backward = mt_binarize(mask_backward,threshold=254)
mask_forward = mt_binarize(mask_forward,threshold=254)
mask_tot= mt_logic(mask_backward, mask_forward, mode="or")
interleave(forward_compensation, source, backward_compensation)
FFT3DFilter(bt=3)
filteredmotion=Selectevery(3,1)
filtered= source.FFT3DFilter(bt=1)
mt_merge(filteredmotion, filtered, mask_tot)

With kind regards yup.

Didée
17th June 2007, 17:40
Still won't work. Swap 'kind' and 'vectors' in "mask_XY=.." creation. (You can't use unnamed arguments after having used named arguments.)
While you're at it, delete the space between MVMask and paranthesis.

yup
17th June 2007, 18:01
Didée!
Thank You for advice:thanks:
I hope that now work script
backward_vectors = source.MVAnalyse(isb = true, truemotion=true, delta = 1, idx = 1)
forward_vectors = source.MVAnalyse(isb = false, truemotion=true, delta = 1, idx = 1)
forward_compensation = source.MVFlow(forward_vectors, idx=1, thSCD1=500)
backward_compensation = source.MVFlow(backward_vectors, idx=1, thSCD1=500)
mask_backward=source.MVMask(backward_vectors, kind=2)
mask_forward=source.MVMask(forward_vectors, kind=2)
mask_backward = mt_binarize(mask_backward,threshold=254)
mask_forward = mt_binarize(mask_forward,threshold=254)
mask_tot= mt_logic(mask_backward, mask_forward, mode="or")
interleave(forward_compensation, source, backward_compensation)
FFT3DFilter(bt=3)
filteredmotion=Selectevery(3,1)
filtered= source.FFT3DFilter(bt=1)
mt_merge(filteredmotion, filtered, mask_tot)
Also advice about mask formation.
With kind regards yup.

Didée
17th June 2007, 18:13
What kind of advice? -What springs immediately to my eyes is that hard thresholding thingy with mt_binarize ... something that, for my personal taste, is not nice. Problems with flickering of the mask itself can arise. Instead of that binarization + logic-OR 'ing , I'd rather use something like
mask_backward=source.MVMask(backward_vectors, kind=2, ml=??)
mask_forward=source.MVMask(forward_vectors, kind=2, ml=??)
mask_tot= mt_logic(mask_backward, mask_forward, mode="max")

i.e. leave out the binarization, and tweak the sensitivity of the mask with the 'ml' parameter.

However, honestly, I find the script as a whole makes much effort for only little gain, if at all. Just using overlapped search/compensation and using FFT3DFilter on that deals very well ... do you see noticeable improvement by using pure spatial fft-filtering for occlusion areas?