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.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Development

Reply
 
Thread Tools Search this Thread Display Modes
Old 28th November 2007, 03:17   #1  |  Link
Terranigma
*Space Reserved*
 
Terranigma's Avatar
 
Join Date: May 2006
Posts: 953
dfttest - 2D/3D frequency domain denoiser.

dfttest by tritical

Info:
2D/3D frequency domain denoiser.

Requires libfftw3f-3.dll to be in the search path.
http://www.fftw.org/install/windows.html

Download

Last edited by Terranigma; 26th January 2009 at 02:20.
Terranigma is offline   Reply With Quote
Old 28th November 2007, 05:57   #2  |  Link
DeathAngelBR
Registered User
 
Join Date: Nov 2006
Posts: 83
Straight to the point. Here's some screens. Yep, anime! No conclusion from me except anime is always a bitch to denoise.
It seems a sigma value of 0.25 to 0.5 is enough for grainy anime like this one.

Original noisy frame:


Denoised with a not-so-much-detail-killer.
Code:
fluxsmoothst(9,9)
ttempsmooth()
fastlinedarkenmod(thinning=0, strength=25)
limitedsharpenfaster(smode=4, strength=50)
tweak(sat=1.10)


Next is mc_spuds()
Code:
mc_spuds(frames=2, strength=1, anime=true, starfield=true, lsfstr=50, blocksize=8, overlap=8/2)
ttempsmooth()
fastlinedarkenmod(thinning=0, strength=25)
tweak(sat=1.10)


Using dfttest() default.
Code:
dfttest()
fastlinedarkenmod(thinning=0, strength=25)
limitedsharpenfaster(smode=4, strength=50)
tweak(sat=1.10)

Ooops! Too washed out.

dfttest(sigma=1.0), everything else the same.


dfttest(sigma=0.5)


dfttest(sigma=0.25)
DeathAngelBR is offline   Reply With Quote
Old 28th November 2007, 06:04   #3  |  Link
Adub
Fighting spam with a fish
 
Adub's Avatar
 
Join Date: Sep 2005
Posts: 2,699
What kind of speed are we getting?
__________________
FAQs:Bond's AVC/H.264 FAQ
Site:Adubvideo
Adub is offline   Reply With Quote
Old 28th November 2007, 07:54   #4  |  Link
cestfait
Registered User
 
cestfait's Avatar
 
Join Date: Jul 2007
Posts: 70
WOW!

That is one powerful filter-- I've never seen such a good stand-alone temporal denoiser without artifacts (fluxsmooth and degrainmedian's blurring or temporalsoften and fft3d's ghosting, for example). It also temporally denoises much better than the former examples in general, imho (even when these others are mv-compensated).

It looks like you can set tbsize really high w/o side effects beyond slower processing. (ok, with high temporal radii it can get pretty slow, actually. . .)

Unfortunately, being quite mathematically illiterate, I still have some total blanks here and there in the docs. I wonder if tritical has any explanations for us about the differences between the analysis/synthesis windows. . .

It's really fun to play with, though. Now for some play with the spatial thresholds!

Fabulous! ^_^




P.S. I'm not big on spending my time clocking these filters, but I can say that with low sigma and temporal radii, this filter is acceptably fast. In fact, considering its power, it is pleasingly quick, indeed!

Last edited by cestfait; 28th November 2007 at 09:27.
cestfait is offline   Reply With Quote
Old 28th November 2007, 12:30   #5  |  Link
foxyshadis
ангел смерти
 
foxyshadis's Avatar
 
Join Date: Nov 2004
Location: Lost
Posts: 9,558
btw, if you feel like really slowing it down, dfttest improves much with motion compensation, was originally made for that in fact.

You could use it as a drop-in replacement for mvdegrain in mc_spuds, too, just in case it's still too fast for you.
foxyshadis is offline   Reply With Quote
Old 28th November 2007, 15:14   #6  |  Link
2Bdecided
Registered User
 
Join Date: Dec 2002
Location: UK
Posts: 1,673
The parameters for dfttest have changed since that thread was written. What would be the equivalents of...

dfttest(sigma=3.6,bsize=8,osize=6,ssr=0,tsr=2,max2dblocks=5)

...in that post? I did try to figure the changes out from the help file, but some parameters have vanished!

Cheers,
David.
2Bdecided is offline   Reply With Quote
Old 28th November 2007, 21:28   #7  |  Link
tritical
Registered User
 
Join Date: Dec 2003
Location: MO, US
Posts: 999
closest thing to:

dfttest(sigma=3.6,bsize=8,osize=6,ssr=0,tsr=2,max2dblocks=5)

would be:

dfttest(sigma=3.6,sbsize=8,sosize=6,tbsize=5)

The max2dblocks parameter is gone now along with ssr/tsr. ssr/tsr (spatial search radius, temporal search radius) were part of its internal mc, which I decided to remove since external mc with mvtools is faster and better. Previously, it would search within the area defined by ssr/tsr for the best matching blocks (most similar to the block on the current frame), and then choose the best 'max2dblocks' worth to include in the 3d transform. With ssr=0/tsr=2 and max2dblocks=5 it is essentially the same as using tbsize=5 and tmode=0 in the new filter.

Atm, the temporal operation of this filter (tbsize>1) is quite a bit slower than it needs to be since I don't cache the 2d transforms on each frame. The upside of the current method is that it uses a lot less memory (especially for small windows with large overlaps). If I get the time I will add optional caching. Also, there are 2 more filter types I would like to add.

Quote:
Unfortunately, being quite mathematically illiterate, I still have some total blanks here and there in the docs. I wonder if tritical has any explanations for us about the differences between the analysis/synthesis windows. . .
I'm not an expert on windowing function characteristics either. Basically, I just included a bunch of different ones to play with. This page gives a nice overview, and has most of the ones I implemented listed:

http://en.wikipedia.org/wiki/Window_function

Last edited by tritical; 28th November 2007 at 21:30.
tritical is offline   Reply With Quote
Old 29th November 2007, 23:25   #8  |  Link
*.mp4 guy
Registered User
 
*.mp4 guy's Avatar
 
Join Date: Feb 2004
Posts: 1,348
Did you implement a "square" (sometimes called rectangular, Dirichlet, or sinc) windowing function (a square windowing function is just a plain cut-off, its the simplest one). With high overlap square often looks the best, square also always retains the most detail.

Last edited by *.mp4 guy; 29th November 2007 at 23:27.
*.mp4 guy is offline   Reply With Quote
Old 29th November 2007, 23:49   #9  |  Link
Terranigma
*Space Reserved*
 
Terranigma's Avatar
 
Join Date: May 2006
Posts: 953
Quote:
Originally Posted by *.mp4 guy View Post
Did you implement a "square" (sometimes called rectangular, Dirichlet, or sinc) windowing function (a square windowing function is just a plain cut-off, its the simplest one). With high overlap square often looks the best, square also always retains the most detail.
Quote:
Originally Posted by dfttest.txt
swin,twin -

Sets the type of analysis/synthesis window to be used for spatial (swin) and
temporal (twin) processing. Possible settings:

0: hanning
1: hamming
2: blackman
3: 4 term blackman-harris
4: kaiser-bessel
5: 7 term blackman-harris
6: flat top
7: rectangular
8: Bartlett
9: Bartlett-Hann
10: Nuttall
11: Blackman-Nuttall

default: 0,0
So you think tritical should change the default to 7?

Also, you think you could explain how each method works (if you don't mind ?)

Last edited by Terranigma; 29th November 2007 at 23:54.
Terranigma is offline   Reply With Quote
Old 30th November 2007, 00:05   #10  |  Link
*.mp4 guy
Registered User
 
*.mp4 guy's Avatar
 
Join Date: Feb 2004
Posts: 1,348
Well, I don't know how the windowing functions will effect denoising specifically, but generally speaking a rectangular windowing function retains the most detail and has the most artifacts (ringing). All of the other windowing functions give less "wieght" to pixels close to the edges of the window when performing the dft transform, to try to lower the amount of ringing while retaining a certain type of information as well as possible (what is targeted varies amoung windowing functions) I would Guess that 7 would work the best, but obviously, to be sure testing would have to be done.

The wikipedia page should give you a good idea about how each different method works, the blue shape in the picture associated with each function gives a visual representation of how the weight of outlying pixels is reduced compared to the center pixel (in actuality they don't represent this, but for this usage of windowing functions its safe to think of them in this way).
*.mp4 guy is offline   Reply With Quote
Old 30th November 2007, 03:14   #11  |  Link
tritical
Registered User
 
Join Date: Dec 2003
Location: MO, US
Posts: 999
I guess I'll try to give an explanation of some of the differences between the windows. There are basically three main characteristics to look at... the main lobe width, the peak side lobe level, and the side lobe roll off.

A small main lobe width gives better resolution. That is, given two equal magnitude peaks in the frequency spectrum, the smaller the main lobe width, the closer together the two peaks can be and we will still be able to resolve them. The rectangular window has the smallest main lobe width.

A small peak side lobe level makes it possible to resolve a weak (small) peak that is next to a, relatively speaking, strong (large) peak. The peak side lobe level determines the maximum response outside the main lobe. In other words, if the peak side lobe level is too high, then the energy from a strong peak can leak into nearby frequency bins and cover up a smaller peak if one is present. Of the windows implemented in dfttest, flat top or 7-term blackman-harris has the smallest peak side lobe level. The rectangular window has the largest peak side lobe level.

The third characteristic is the side lobe roll off, which gives the rate of decrease in the peak of each side lobe as you move away from the main lobe. Sometimes trading a faster roll off for a larger peak side lobe level (the peak side lobe level generally occurs in the side lobes closest to the main lobe) is good if there are no nearby peaks, but there are some farther away.

Thus, the best window would have a small main lobe width, a small side peak, and a fast roll off. The problem is that you can't have all of that at the same time. Generally, the smaller the main lobe width, the higher the side peak and vice versa. Of the windows in dfttest, the order from smallest to largest in terms of main lobe width is:

rectangular
bartlett
hamming
hanning
bartlett-hann
blackman
blackman-harris (4-term)
blackman-nutall
nutall
blackman-harris (7-term)
flat top

I left out kaiser-bessel because it is adjustable and could end up anywhere in there.

Exactly which window is best for denoising is hard to say, and would also depend on overlap amount, window size, etc... I can say from my tests in the objective denoiser thread that hanning/hamming with large overlap >= 75% and window size around 8-16 seemed to work best for removal of gaussian white noise (in terms of resulting psnr and ssim).

http://en.wikipedia.org/wiki/Image:W...parsion%29.png

This graph from wikipedia has pretty much all of the windows listed above, and shows the main lobe, along with the frequency envelope (you can see the peak side lobe level and how fast the roll off is).
tritical is offline   Reply With Quote
Old 30th November 2007, 04:00   #12  |  Link
*.mp4 guy
Registered User
 
*.mp4 guy's Avatar
 
Join Date: Feb 2004
Posts: 1,348
Quote:
Originally Posted by tritical View Post
Exactly which window is best for denoising is hard to say, and would also depend on overlap amount, window size, etc... I can say from my tests in the objective denoiser thread that hanning/hamming with large overlap >= 75% and window size around 8-16 seemed to work best for removal of gaussian white noise (in terms of resulting psnr and ssim).
Nitpick: its important to note that addgrain produces noise that may differ from other guassian-like noise commonly seen in actual video.

Anyway, sorry for veering a bit off topic, I just wanted to know if the option was available (its left out surprisingly often when multiple windowing functions are available) I'm sure the default settings dfttest uses are as close to optinal for any given source as you can expect defaults to be.
*.mp4 guy is offline   Reply With Quote
Old 1st December 2007, 04:11   #13  |  Link
Chainmax
Huh?
 
Chainmax's Avatar
 
Join Date: Sep 2003
Location: Uruguay
Posts: 3,103
Quote:
Originally Posted by Terranigma View Post
...
Requires libfftw3f-3.dll to be in the search path.
http://www.fftw.org/install/windows.html
...
What exactly does that mean? All I see on that link are compilation instructions.
__________________
Read Decomb's readmes and tutorials, the IVTC tutorial and the capture guide in order to learn about combing and how to deal with it.
Chainmax is offline   Reply With Quote
Old 1st December 2007, 04:18   #14  |  Link
Dark Shikari
x264 developer
 
Dark Shikari's Avatar
 
Join Date: Sep 2005
Posts: 8,666
Quote:
Originally Posted by Chainmax View Post
What exactly does that mean? All I see on that link are compilation instructions.
The top section on the page is titled "precompiled..."
Dark Shikari is offline   Reply With Quote
Old 1st December 2007, 23:03   #15  |  Link
Chainmax
Huh?
 
Chainmax's Avatar
 
Join Date: Sep 2003
Location: Uruguay
Posts: 3,103
dfttest already has a pre-compiled DLL included. What I don't understand is what does "Requires libfftw3f-3.dll to be in the search path" mean, which doesn't seem to be clarified in the URL.
__________________
Read Decomb's readmes and tutorials, the IVTC tutorial and the capture guide in order to learn about combing and how to deal with it.
Chainmax is offline   Reply With Quote
Old 1st December 2007, 23:19   #16  |  Link
Terranigma
*Space Reserved*
 
Terranigma's Avatar
 
Join Date: May 2006
Posts: 953
The post was taken vertabimly from dfttest's .txt document. What that means is, is that it needs to be in WINDOWS's directory like fftw3.dll
Terranigma is offline   Reply With Quote
Old 4th December 2007, 00:07   #17  |  Link
Chainmax
Huh?
 
Chainmax's Avatar
 
Join Date: Sep 2003
Location: Uruguay
Posts: 3,103
Here's a comparison between DeGrainMedian(limitY=5,limitUV=7,mode=0) and dfttest(sigma=1.25) on an extremely crappy source:


Source (resized by two on VDub's preview window):


DeGrainMedian(limitY=5,limitUV=7,mode=0):


dfttest(sigma=1.25):



If you want more pics, let me know.
__________________
Read Decomb's readmes and tutorials, the IVTC tutorial and the capture guide in order to learn about combing and how to deal with it.
Chainmax is offline   Reply With Quote
Old 4th December 2007, 05:01   #18  |  Link
BlueCup
Registered User
 
Join Date: Jan 2003
Posts: 66
I think I can count the blocks in that first picture, whoa. Is that even watchable?
BlueCup is offline   Reply With Quote
Old 4th December 2007, 10:06   #19  |  Link
Chainmax
Huh?
 
Chainmax's Avatar
 
Join Date: Sep 2003
Location: Uruguay
Posts: 3,103
From a distance .

It's so sad because it's one of my favorite clips and as far as I know it's only available in this crappy YouTube form. x20
__________________
Read Decomb's readmes and tutorials, the IVTC tutorial and the capture guide in order to learn about combing and how to deal with it.
Chainmax is offline   Reply With Quote
Old 26th December 2007, 13:00   #20  |  Link
Chainmax
Huh?
 
Chainmax's Avatar
 
Join Date: Sep 2003
Location: Uruguay
Posts: 3,103
It seems dfttest can cause some problem with the order of the frames being displayed. I was trying to re-encode Pirate Baby's Cabana Battle Street Fight 2006 (freeware video, available here), and after encoding the video would sometimes jerk around as if a wrong field order was assumed. Here's the filterchain:

Code:
SetMemoryMax(512)

LoadPlugin("X:\wherever\MT.dll")

LoadPlugin("X:\wherever\MT_MaskTools.dll")
LoadPlugin("X:\wherever\DGDecode.dll")
LoadPlugin("X:\wherever\DCTFilter.dll")
Import("X:\wherever\DeBlock_QED_MT2.avs")

LoadPlugin("X:\wherever\RemoveGrainSSE3.dll")

LoadPlugin("X:\wherever\dfttest.dll")

Import("X:\wherever\LimitedSharpenFaster.avs")
Import("X:\wherever\Soothe_MT2.avs")





SetMTMode(5)
DirectShowSource("X:\wherever\PaulRobertson_PirateBabysCabanaBattleStreetFight2006.mpg",fps=25,audio=false)

ConvertToYV12()

SetMTMode(2)
DeBlock_QED_MT2(quant1=35,aOff1=16,quant2=45,aOff2=6)

RemoveGrain(mode=5)

Crop(12,52,328,184,align=true)

dfttest(sigma=1.5)

Spline36Resize(320,176)

RemoveGrain(mode=5)

LimitedSharpenFaster(SMode=4,Strength=200)
Commenting out the dfttest line would solve the issue.


[edit]mmm...commenting out the SetMTMode calls instead also solves the issue. Should I post this in the MT thread as well?
__________________
Read Decomb's readmes and tutorials, the IVTC tutorial and the capture guide in order to learn about combing and how to deal with it.
Chainmax is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 18:33.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.