Log in

View Full Version : Help me fine tune this script for a little less denoising


okc_smoker
9th July 2008, 19:45
First, I'm a relative newbie to AVISynth so pardon any blatant mistakes, stupid questions, etc. I'm still not experienced enough to write my own scripts from scratch, so most of my scripts so far consist of copying and pasting bits and pieces from the forum.

By far my favorite script is this one (http://forum.doom9.org/showthread.php?p=952831#post952831) from Didee that I used on some nasty VHS transfers. I was completely blown away by the results. What I'm working on now is a MiniDV transfer that is MUCH better than the VHS, although it was shot in low light so it's still a bit on the noisy side. I ran Didee's script on it and it was a vast improvement but it was actually just a bit too much denoising. It made skin look just a bit plastic. What I'd like to do is back off the denoising just a bit but keep everything else the same. The problem is that the script is so far over my head that I have no idea where to start. I was hoping some more experienced members might give some suggestions as far as what parts I could tinker with that would vary the amount of denoising.

FWIW, I found that running the resulting AVI file through LimitedSharpenFaster() did eliminate some of the softness around the edges nicely but it didn't do much for non-edge detail, particularly skin.

Thanks!

Ranguvar
9th July 2008, 20:12
For starters, try decreasing the strength of RemoveGrain :)

And about the sharpening, try SeeSaw. LimitedSharpenFaster is great for edges, but SeeSaw does the trick for small details.

Nightshiver
9th July 2008, 20:25
Could you upload a sample clip for us to play with?

okc_smoker
9th July 2008, 20:35
Unless I'm way off, the "11" in RemoveGrain(11) isn't the strength but the mode. According to the documentation, which isn't terribly clear, mode 11 is the "3x3 convolution" mode. Is there another mode that you'd recommend that would be a little weaker?

Also, again, unless I'm totally misunderstanding, there is quite a bit of temporal smoothing going on and RemoveGrain is (I think) the only spatial smoother. Wouldn't it make more sense to adjust/remove one of the temporal smoothers or is RemoveGrain what's giving me the "plastic skin" look?

As far as SeeSaw, how would I implement it in this case? This script already running in the 1 fps range. Would I do something like this right before reinterlacing (with modified parameters to lower the denoising)?

setmemorymax(512)

LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\fluxsmooth.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\MedianBlur.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\mt_masktools.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\MVTools.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\RemoveGrain.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\Repair.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\TTempSmooth.dll")

aviSource("E:\CapSeg.avi")
converttoyv12()

Bob(0,0.5)

...all the denoising stuff here...

SeeSaw(base, last)

SeparateFields().SelectEvery(4,0,3).Weave() # before or after,

interleave( selectevery(5,0).FluxSmoothT(7),selectevery(5,1).FluxSmoothT(7),
\ selectevery(5,2).FluxSmoothT(7),selectevery(5,3).FluxSmoothT(7),
\ selectevery(5,4).FluxSmoothT(7) )

# SeparateFields().SelectEvery(4,0,3).Weave() # that's a question

return(last)




Like I said, way over my head... :)

okc_smoker
9th July 2008, 20:38
Could you upload a sample clip for us to play with?

Uh... how do I put this delicately? For undisclosed reasons, let's just say that's unfortunately not an option in this case. :p

I tried filming a sample video in what I thought was similar lighting, but it is pretty hard to duplicate apparently. Sorry!

Blue_MiSfit
9th July 2008, 20:47
:D

I think I know what you're processing!

Surely there must be some clip that isn't too compromising!

~MiSfit

okc_smoker
9th July 2008, 20:53
I *might* be able to crop out some still before/after images that illustrate what I'm talking about but that's about as much as I could possibly get away with (if I want to stay married). If that's helpful, I'll see what I can do when I get home.

Blue_MiSfit
9th July 2008, 21:25
I knew it!

As they say on Anandtech - pics or ban!

And not because I'm a voyeur. I promise it's all purely academic interest...

:D
~MiSfit

okc_smoker
9th July 2008, 21:36
I value the prospect of taking more video in the future more than not being banned... ;)

Seriously though, any suggestions?

Didée
9th July 2008, 21:53
Given that there's sufficient distortion going on your low-light footage, your milage will be rather little when just putting SeeSaw somewhere before, in or after that script. For strong denoising with more visible detail in the result, some other strategies have been evolved since then.
However for good results, all parts of the puzzle must be fitted to the actual needs & characteristics of the actual source material. Which means that without a sample, there will be no suggestions from here.

okc_smoker
9th July 2008, 23:52
I understand. I was hoping there might be a way to just lower the level of denoising done in this script in a general fashion. Even though it might not be ideal, I think it would still be better than anything I could come up with on my own.

okc_smoker
10th July 2008, 14:54
Would it be possible to address the following on a "hypothetical" level? What would be a better option for RemoveGrain that would leave a little more detail intact?

Unless I'm way off, the "11" in RemoveGrain(11) isn't the strength but the mode. According to the documentation, which isn't terribly clear, mode 11 is the "3x3 convolution" mode. Is there another mode that you'd recommend that would be a little weaker?

Also, again, unless I'm totally misunderstanding, there is quite a bit of temporal smoothing going on and RemoveGrain is (I think) the only spatial smoother. Wouldn't it make more sense to adjust/remove one of the temporal smoothers or is RemoveGrain what's giving me the "plastic skin" look?

Didée
10th July 2008, 15:48
That's mostly unrelated. Spatial filters like RemoveGrain deal for getting some probabilities, and for contra-sharpening.

It's like if you're going to paint a window frame, and you're protecting the glass with some adhesive tape. Will the painting result change if you use another (cheaper / more expensive) adhesive tape? No, it won't.

edit: looking closely back at the script in question, removegrain(11) is solely used for sharpening -- so obviously it has nothing to do with softening the source ...

The real problem is that this particular script does not fit well to your source. And alas, I have no clue what would need to be changed to make it fit to that particular source.

A primitive way to improve on skin detail could be the following: (but note that it will also restore source noise by the same amount!)

source = last
filtered = source.TheNoiseFilter()
mt_lutxy(filtered,source,"x 2 + y < x 2 + x 2 - y > x 2 - y ? ?",U=3,V=3) # set U,V=2 to not restore on chroma

okc_smoker
10th July 2008, 16:12
I understand and I appreciate the help in spite of the fact that you're essentially taking a shot in the dark. At least it gives me something to work with.

okc_smoker
10th July 2008, 16:31
Also, regarding a sample, when I get home from work I'm going to split out a 10-15 second clip and crop it to provide (hopefully) enough of example to work from without revealing much else.

I was just going to do something like this and save back to DV. Will this give you what you need from technical standpoint (assuming I can find a good portion of the video to crop)? Anything else I should do?

AVISource("clip.avi")

# Deinterlace first?
Crop(x,x,-x,-x)

Edit: Make that AVISource("clip.avi").KillAudio ;)

Didée
10th July 2008, 17:34
Seems okay that way. However, do *not* deinterlace. Recompression to DV probably isn't too bad, yet a lossless compression (e.g. yv12-huffyuv (ffdshow), FFV1 (ffdshow)) would be even better.

Another option could be this: restore the same lighting conditions in the same room, and make a recording with the same equipment, with some non-critical content.

okc_smoker
11th July 2008, 02:25
Okay, I cropped out quite a bit but hopefully there's enough left to make some good suggestions. There's nothing going on in the clip, I just had the camera rolling so don't get too excited. If you genuinely plan on providing helpful input (it doesn't necessarily have to be limited to Didee's script) PM me and I'll give you the link and the password.

2Bdecided
14th July 2008, 15:28
Have you tried mc_spuds and playing with the various parameters? It's probably an easier way into denoising than tweaking a script directly. Still very slow though.

Cheers,
David.

okc_smoker
14th July 2008, 15:34
I did try it although I didn't spend a lot of time playing with the parameters. It worked okay, but Didee provided me with a script that works orders of magnitude better than any one denoiser could do.

2Bdecided
14th July 2008, 16:25
OK, but I thought you wanted less denoising? btw, mc_spuds isn't "one denoiser" - it's a scripted call to several denoising techniques.

NeatVideo is quite good with typical DV camcorder noise, if it learns the pattern - but I prefer AVIsynth methods (and not just for the cost!).


Cheers,
David.

okc_smoker
14th July 2008, 16:28
Ah, thanks for clarifying that. Either way, when I say that it works better I don't necessarily mean that it removes more noise. From what I saw it does a better job at removing the noise I don't want while leaving in a little noise so it doesn't look overprocessed and fake. In other words, the final result just looks better to my eye :).

g-force
15th July 2008, 20:57
...Didee provided me with a script that works orders of magnitude better than any one denoiser could do.

Didée, care to share?

-G

Didée
15th July 2008, 22:57
Rather not. It's highly custom-tailored, not (yet) proof against false mo-comp, therefore needs further tweaking, and it's very slow. Lastly, the denoising core still is the same as the script earlier posted here, just without the final FluxSmooth insanity.

okc_smoker
15th July 2008, 23:04
Didee, I forgot to ask you in my last PM if you use SetMTMode() with scrpts like this? I've noticed some weird results when using it with certain filters like LSF, but it's an intermittent problem. I'm fine with not using it, but it would be nice with a script this slow! :)

Didée
15th July 2008, 23:11
[hurdy-gurdy]

Me-dont-has-a-multi-core, la-la-la-la-laaaa, I-do'ont-kno'ow ...

[/hurdy-gurdy]

Nightshiver
16th July 2008, 01:31
We all need to pitch in and buy Didee a new compy.

Didée
16th July 2008, 01:53
Much more efficient: put effort into developing smarter ways of using multi-threading ... either by developing yourself, or by supporting those who do. I'm just a script fiddler, the real problems are located at lower levels.

okc_smoker
16th July 2008, 02:18
I'm just a script fiddler...

Now there's an understatement! I'm a script fiddler - you're an artist! The Picaso of AVISynth... ;)