View Full Version : New very slow FFT denoiser
Pages :
1
2
3
4
5
6
7
8
9
[
10]
11
12
13
14
15
16
17
Fizick
29th November 2005, 22:35
Egh,
Thanks for thanks :)
Try check my site again. The last version must be 1.8.4 now ;)
(added multi-plane option)
No comment about shimmering.
But deblurring is not the same as sharpening.
sharpen <1.0 is only for aproximate (reasonable) value in order to nobody try use some crazy values about 1000 :)
So you can use 1.5 freely :)
It is "not good", but "not very bad" :)
Egh
30th November 2005, 00:14
Egh,
Thanks for thanks :)
Try check my site again. The last version must be 1.8.4 now ;)
(added multi-plane option)
No comment about shimmering.
But deblurring is not the same as sharpening.
sharpen <1.0 is only for aproximate (reasonable) value in order to nobody try use some crazy values about 1000 :)
So you can use 1.5 freely :)
It is "not good", but "not very bad" :)
multi-plane is rather good idea, though it's 2x slower then, right? :) (color planes are less resolution than luma, naturally).
what about cutoff params? smin and smax. What is behind those params and why are they 4.0 and 20 by default? I remember I tried >20 and it usually only enhanced sharpness.
Well, for those purposes I tried (see sample in Limited Sharpen thread) so far my filtering chain using FFT3D (with bt=-1) provides b3st results. Not ideal, not removing gaussian blurring or halos completely, far from that. But it can *reasonably*well* increase perceived sharpness of the picture and yet not create noisy artefacts (causual filtering aimed at gaussian blur removal creates so much noise that a serious temporal denoiser needs to be applied, inspite original is very clean and doesnt' need any serious denoising).
Why no comments on shimmering? :P Can I provide you with a sample (video, not stills, cause you notice it only on animated scenes).
Fizick
30th November 2005, 23:46
1. smin protects from increasing the noise.
smax protects against oversharping.
Try set smin=0 and smax=1000 to create simple stupid strong (but slow) sharpening.
2. fft3dfilter still has no option to remove halo, so why it must remove it? :)
But it will not increase it!
Egh
1st December 2005, 01:15
Can you be more specifics on details of noise protection?
2. Halos are not removed by your filter, i also use other filters in the chain. But w/o your filter sharpening the perceived quality of the result is rather poor.
puffpio
1st December 2005, 06:13
revisiting a question I had a while ago...
what would give better picture quality:
1)
TDeint()
FFT3DFilter(sigma=3, plane=4, bt=4, sharpen=0.7)
2)
FFT3DFilter(sigma=3, plane=4, bt=4, sharpen=0.7, interlaced=true)
TDeint()
my gut tells me #3 since if the fields are interlaced, then the noise should be spread within a frame like that....
Boulder
1st December 2005, 06:54
It's recommended to deinterlace/IVTC before doing anything else. There are a few exceptions to the recommendation, but that's just because they don't work well with deinterlaced/IVTC'd material.
Egh
1st December 2005, 14:00
revisiting a question I had a while ago...
what would give better picture quality:
1)
TDeint()
FFT3DFilter(sigma=3, plane=4, bt=4, sharpen=0.7)
2)
FFT3DFilter(sigma=3, plane=4, bt=4, sharpen=0.7, interlaced=true)
TDeint()
my gut tells me #3 since if the fields are interlaced, then the noise should be spread within a frame like that....
My experience is to use FFT3D to decrease the noise created by TDeint() in some specific cases, most notable fadings. So definately after.
raquete
1st December 2005, 17:00
@ Fizick
i have one slow machine and i use fft3d for sharp.the default is (bt=-1,sharpen=0.7) but loading .avs scripts in vdubmod,i see that using (bt=-1,sharpen=0.4) is what i really like.
i don't understand all parameters but comparing your ffft3d with others sharpen filters,your is the winner.
excuse my newby question :o : have any other way to adjust fft3dfilter to get seamless result as (bt=-1,sharpen=0.4) to encode a little fast?
thanks.
Fizick
2nd December 2005, 11:21
raquete,
You may try to decrease overlap sizes. But check gridding!
raquete
3rd December 2005, 19:11
no way my friend.the real problem is my old and slow duron 1.8. :mad:
but i have patience and i'm waiting for a new fft3dfilter faster version in next future.
thank you very much Fizick. ;)
DarkFoon
4th December 2005, 06:48
Happy anneversary, fizick and FFT3D!!!
Sorry, I haven't been around.
the forum quit notifying me of new posts....
Fizick
4th December 2005, 11:51
Version 1.8.5 - 4 December 2005 - fixed bug with memory leakage in constructor (thanks to tsp).
Fizick
4th December 2005, 12:04
DarkFoon, thanks :)
By the way this thread has 461 replies now.
It is record (top place) for two Avisynth forums ("MPEGDecoder.dll (Direct VOB/M2v -> AviSynth)" has 457, "Another motion adaptive deinterlacer and smart bobber" has 424, "Here is LimitedSharpen()" has only 333) , and it is 33-th place in whole doom9 forum! :) :devil:
raquete
4th December 2005, 15:01
then you deserve another congratulation and thanks for the new version!
:)
Fizick
4th December 2005, 15:54
fft3dfilter is not only very slow itself :(, but its development is very slow too. :)
DarkFoon
11th December 2005, 23:24
Hey Everybody!
I've got a very early x-mas gift for you all.
I've found a very effective bunch of FFT3D settings.
I use them to remove noise from my TV captures (mainly anime, but it worked well on a law & order episode with more noise than usual)
I have a hauppauge PVR-250, if that means anything to you guys.
The video frame size was 704x480(both divisible by 16)
And without further ado, the settings!
fft3dfilter(sigma=3, sigma2=5, sigma3=10, sigma4=20, plane=0, bt=3, bw=16, bh=16, ow=8, oh=8, sharpen=0.3, smin=20, smax=1000, wintype=2, kratio=1.0, measure=true, interlaced=false, degrid=1)
It works great with every source I've used. High ammounts of detail retained, while removing all the noise! It's also not too slow.
(I'd provide screen shots, but I've moved all my video work to another computer with no internet, so I can't)
Merry Christmas ya'll (or whatever you celebrate!)
cwk
11th December 2005, 23:36
You beat me to it DarkFoon!
Here is what I use:
one=clip
two=one.FFT3dFilter(bh=32, bw=32, oh=16, ow=16, sigma=1, sigma2=1, sigma3=4, sigma4=16, plane=0)
repair(two, one, 16)
FFT3dFilter(bh=32, bw=32, oh=16, ow=16, sigma=1, sigma2=1, sigma3=4, sigma4=16, plane=3)
The higher sigmas in the lower frequency band take away a tremendous amount of noise, while the lower sigmas in higher frequencies leave details. I use this for VHS caps.
DarkFoon
12th December 2005, 01:39
hehehe.
To filter my chroma, I use FFT3dGPU. I put as many filters as I can before it (a geforce fx5200 is slow compared to FFT3D) and it lessens the slowness.
The settings for FFT3DGPU I can't remember off the top of my head, but its something like 16=bh=bw, mode=0, degrid=5, sigma=10. It works pretty good, and cleans up most of the chroma noise.
one question, what is "repair( two, one, 16)"?
I've never heard of it before
foxyshadis
12th December 2005, 03:25
A filter in the removegrain package (http://www.removegrain.de.tf/) similar to removegrain, but that uses a second guide clip to lessen artifacts (in some cases, I never tried it with fft3d).
cwk
12th December 2005, 03:58
A filter in the removegrain package similar to removegrain, but that uses a second guide clip to lessen artifacts (in some cases, I never tried it with fft3d).
Exactly. I believe repair was originally designed to "repair" artifacts left over by temporal denoisers. I like the way it restores crispness to a clip that has been mildly blurred by FFT. I put the chroma cleaning after repair for a stronger effect. Repair mitigates the effects of whatever filter you are applying to your original clip....
Egh
12th December 2005, 17:46
Exactly. I believe repair was originally designed to "repair" artifacts left over by temporal denoisers. I like the way it restores crispness to a clip that has been mildly blurred by FFT. I put the chroma cleaning after repair for a stronger effect. Repair mitigates the effects of whatever filter you are applying to your original clip....
Repair is a counterpart for RemoveGrain's filter Cleanse() iirc.
So it was developed to remove artifacts creates by Cleanse() usage (which is very powerful filter indeed, though have unique-looking artifacts ^^). As for restoration after FFT3D... Sounds quite good idea to try at least, i'll run some experiments to see if it's good in my cases.
Isochroma
23rd December 2005, 03:42
Any avs script containing FFT3DFilter() will cause VFAPI 1.0.5 to throw an error and abort... ??
Fizick
23rd December 2005, 12:08
Isochroma,
I do not use VFAPI.
But please say: FFT3dfilter, Avisynth versions, script, system config.
What application do you use with VFApi?
IT is very simple questions.
Do you have error with more old FFT3Dfilter version?
Isochroma
23rd December 2005, 18:01
VFAPI 1.0.5
AVISynth 2.5.6 alpha 071005
VirtualDub 1.5.10
AVS Script:
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\DGDecode.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\Decomb521.dll")
MPEG2Source("filename.d2v")
Telecide(order=1)
Decimate(cycle=5, mode=0)
LimitedSharpen(ss_x=2.0, ss_y=2.0, Smode=3, strength=800)
FFT3DFilter(sigma=3,plane=4)
When the avs file is dropped into the VFAPI window, CPU does 100% for about 4 seconds, then nothing.
When the Add Job button is pressed and avs file is selected and opened, a window pops up saying "File 'filename.avs' is invalid". If this is done twice with the same instance of the program then the file, when opened, will cause a peculiar dialog to appear:
http://www.isochroma.com/Testfiles/Misc/vfapi-error2.png
URL path is case sensitive.
Because of this problem, I finally learned how to use ffdshow's AVIS maker! Works fine, if you use absolute paths for absolutely everything in the script...
DarkFoon
23rd December 2005, 19:01
you don't need to use absolute paths with AVIS if you store the resulting file in the same directory as your AVS.
at least I've never had to...
Fizick
23rd December 2005, 23:39
Yes, i make a short test and confirm the problem of fft3dfilter with VFAPI-converter.
(but is is not regular, sometimes for small frames it works).
Workaround: disable fft3dfilter in script, make fake avi, and re-enable fft3dfilter.
It must works. So, it is probably problem with VFAPI-converter , may be because of time delay.
Debug info:
DGVfapi: error (Unknown) loading avisynth script!
DarkFoon
24th December 2005, 05:18
maybe if you set measure=false it will work?
redfordxx
31st December 2005, 18:41
Hi,
I must say this is nice all-in-one filter: denoising, deblocking, deringing, deinterlacing...;-)
Thanks for it.
Only on larger areas I experience colorgradients... anybody noticed it? And been solving it?
redfordxx
2nd January 2006, 17:32
When taking noise pattern, it is looking only at one frame or on multiple frames (acc. to bt)?
DarkFoon
2nd January 2006, 21:40
The mode that uses px and py, only uses 1 frame, and you must specify that frame with the pframe= parameter.
I wonder that if you leave pframe= at default (do not specify it) if it looks at that block (specified by px and py) in every frame.... hmm.
redfordxx
2nd January 2006, 21:54
Thanks
Another question.
When taking noise pattern, will the noise patterns from following samples be the same?
Sample 1:
110 115 110 105 110
Sample 2:
150 155 150 145 150
(it's only + 40)
I other words: Does offset make difference?
redfordxx
6th January 2006, 19:09
Well I will share my noise-weapon.
It is in three parts.
1) script for searching the noise pattern
2) script with list of patterns
3) denoising script
With 1) I will search for the noisy frames and the pattern area. In virtualdub.
I will write it down to the 2), which I have opened in anouther instance of virtual dub. As I am going thru the clip, I am instantly changing the parameters and reloading the (F2) the clips, so the listclip 2) is growing. I can compare already found noise and new found noise by swiching the VD's.
Finally I wil choose noise I like from the list and look at the result in the script 3).
Periodical clip reloading increases memory requirement, so sometimes it is necessary to reopen it. I am suspicious MVTools are the cause of that...
[EDIT] I changed - improved it... now there are 2 more files... one for data and one for fast searching the noise
redfordxx
6th January 2006, 19:15
noisesearch.avs
Import ("noisedata.avs")
LoadPlugin("C:\Program Files\Multimedia\AviSynth 2.5\plugins\TIVTC.dll")
LoadPlugin("C:\Program Files\Multimedia\AviSynth 2.5\plugins\mt_masktools.dll")
LoadPlugin("C:\Program Files\Multimedia\AviSynth 2.5\plugins\MVtools.dll")
LoadPlugin("C:\Program Files\Multimedia\AviSynth 2.5\plugins\DGDecode.dll")
LoadPlugin("C:\Program Files\Multimedia\AviSynth 2.5\plugins\fft3dfilter.dll")
mpeg2source("test.d2v",cpu2="xxxxxx",moderate_h=30, moderate_v=50)
crop(8,64,-8,-64)
AssumeTFF
o=TFM(order=-1,field=-1,mode=1,PP=6,ovr="",input="",output="tivtc1.log",debug=true,display=false,slow=0,mChroma=false,cthresh=10,MI=1,chroma=false,blockx=16,blocky=16,mthresh=5,d2v="")
g5=o.MyConvolution(5,25)
StackVertical(o,g5)
noisesetup.avs
Import ("noisedata.avs")
#tested area
is_=true
block_h_=48
block_w_=48
#frame_=
spot_x_=360
spot_y_=0
plane_=4
LoadPlugin("C:\Program Files\Multimedia\AviSynth 2.5\plugins\TIVTC.dll")
LoadPlugin("C:\Program Files\Multimedia\AviSynth 2.5\plugins\mt_masktools.dll")
#LoadPlugin("C:\Program Files\Multimedia\AviSynth 2.5\plugins\masktools.dll")
LoadPlugin("C:\Program Files\Multimedia\AviSynth 2.5\plugins\MVtools.dll")
LoadPlugin("C:\Program Files\Multimedia\AviSynth 2.5\plugins\DGDecode.dll")
LoadPlugin("C:\Program Files\Multimedia\AviSynth 2.5\plugins\fft3dfilter.dll")
mpeg2source("test.d2v",cpu2="xxxxxx",moderate_h=30, moderate_v=50)
crop(8,64,-8,-64)
AssumeTFF
o=TFM(order=-1,field=-1,mode=1,PP=6,ovr="",input="",output="tivtc1.log",debug=true,display=false,slow=0,mChroma=false,cthresh=10,MI=1,chroma=false,blockx=16,blocky=16,mthresh=5,d2v="")
frames=Framecount(o)
a3=o.mt_Convolution("1 1 1", "1 1 1",y=3,u=3,v=3)
a5=o.mt_Convolution("1 1 1 1 1", "1 1 1 1 1",y=3,u=3,v=3)
a7=o.mt_Convolution("1 1 1 1 1 1 1", "1 1 1 1 1 1 1",y=3,u=3,v=3)
a9=o.mt_Convolution("1 1 1 1 1 1 1 1 1", "1 1 1 1 1 1 1 1 1",y=3,u=3,v=3)
a11=o.mt_Convolution("1 1 1 1 1 1 1 1 1 1 1", "1 1 1 1 1 1 1 1 1 1 1",y=3,u=3,v=3)
d3=Subtract(o,a3).ColorYUV(off_y=2)
d5=Subtract(o,a5).ColorYUV(off_y=2)
d7=Subtract(o,a7).ColorYUV(off_y=2)
d9=Subtract(o,a9).ColorYUV(off_y=2)
d11=Subtract(o,a11).ColorYUV(off_y=2)
g5=o.MyConvolution(5,25)
g3=o.MyConvolution(3,25)
p3=d3.crop(spot_x_,spot_y_,block_w_*2,block_h_*2).mt_lut(y=Select(plane_,3,-128,-128,-128,3),u=Select(plane_,-128,3,-128,3,3),v=Select(plane_,-128,-128,3,3,3)).AddBorders(0,0,block_w_,0)
p5=d5.crop(spot_x_,spot_y_,block_w_*2,block_h_*2).mt_lut(y=Select(plane_,3,-128,-128,-128,3),u=Select(plane_,-128,3,-128,3,3),v=Select(plane_,-128,-128,3,3,3)).AddBorders(0,0,block_w_,0)
p7=d7.crop(spot_x_,spot_y_,block_w_*2,block_h_*2).mt_lut(y=Select(plane_,3,-128,-128,-128,3),u=Select(plane_,-128,3,-128,3,3),v=Select(plane_,-128,-128,3,3,3)).AddBorders(0,0,block_w_,0)
p9=d9.crop(spot_x_,spot_y_,block_w_*2,block_h_*2).mt_lut(y=Select(plane_,3,-128,-128,-128,3),u=Select(plane_,-128,3,-128,3,3),v=Select(plane_,-128,-128,3,3,3)).AddBorders(0,0,block_w_,0)
p11=d11.crop(spot_x_,spot_y_,block_w_*2,block_h_*2).mt_lut(y=Select(plane_,3,-128,-128,-128,3),u=Select(plane_,-128,3,-128,3,3),v=Select(plane_,-128,-128,3,3,3))
pg3=g3.crop(spot_x_,spot_y_,block_w_*2,block_h_*2).mt_lut(y=Select(plane_,3,-128,-128,-128,3),u=Select(plane_,-128,3,-128,3,3),v=Select(plane_,-128,-128,3,3,3)).AddBorders(0,0,block_w_,0)
pg5=g5.crop(spot_x_,spot_y_,block_w_*2,block_h_*2).mt_lut(y=Select(plane_,3,-128,-128,-128,3),u=Select(plane_,-128,3,-128,3,3),v=Select(plane_,-128,-128,3,3,3))
p=StackHorizontal(p3,p5,p7,p9,p11)
p=p.ColorYUV(cont_y=24*256,cont_u=24*256,cont_v=24*256).AddBorders(0,0,o.width-p.width,block_h_)
pg=StackHorizontal(pg3,pg5)
pg=pg.AddBorders(0,0,o.width-pg.width,block_h_)
p=StackVertical(p,pg)
p=p.AddBorders(0,0,0,o.height-p.height)
v=o.crop(spot_x_,spot_y_,block_w_*2,block_h_*2).mt_lut(y=Select(plane_,3,-128,-128,-128,3),u=Select(plane_,-128,3,-128,3,3),v=Select(plane_,-128,-128,3,3,3)).AddBorders(0,0,o.width-block_w_*2,o.height-block_h_*2)
StackVertical(StackHorizontal(p,g3),StackHorizontal(v,o))
#StackVertical(d5.ColorYUV(cont_y=24*256,cont_u=24*256,cont_v=24*256),o)#.mt_lut(y=3,u=-128,v=-128)
spot_? is topleft starting point of the pattern in the block_?
you need latest masktools, otherwise convolution crashes
redfordxx
6th January 2006, 19:21
noiselist.avsImport ("noisedata.avs")
LoadPlugin("C:\Program Files\Multimedia\AviSynth 2.5\plugins\TIVTC.dll")
#LoadPlugin("C:\Program Files\Multimedia\AviSynth 2.5\plugins\mt_masktools.dll")
LoadPlugin("C:\Program Files\Multimedia\AviSynth 2.5\plugins\masktools.dll")
LoadPlugin("C:\Program Files\Multimedia\AviSynth 2.5\plugins\MVtools.dll")
LoadPlugin("C:\Program Files\Multimedia\AviSynth 2.5\plugins\DGDecode.dll")
LoadPlugin("C:\Program Files\Multimedia\AviSynth 2.5\plugins\fft3dfilter.dll")
mpeg2source("test.d2v",cpu2="xxxxxx",moderate_h=30, moderate_v=50)
crop(8,64,-8,-64)
AssumeTFF
o=TFM(order=-1,field=-1,mode=1,PP=6,ovr="",input="",output="tivtc1.log",debug=true,display=false,slow=0,mChroma=false,cthresh=10,MI=1,chroma=false,blockx=16,blocky=16,mthresh=5,d2v="")
g5=o.MyConvolution(5,25)
# here are noise patterns
g5.trim(frame0,-1).crop(spot_x0,spot_y0,block_w0*2,block_h0*2).mt_lut(y=Select(plane0,3,-128,-128,-128,3),u=Select(plane0,-128,3,-128,3,3),v=Select(plane0,-128,-128,3,3,3)).AddBorders(block_w0*3,0,o.width-block_w0*5,o.height-block_h0*2)
(is1==false) ? last : last+g5.trim(frame1,-1).crop(spot_x1,spot_y1,block_w1*2,block_h1*2).mt_lut(y=Select(plane1,3,-128,-128,-128,3),u=Select(plane1,-128,3,-128,3,3),v=Select(plane1,-128,-128,3,3,3)).AddBorders(block_w1*3,0,o.width-block_w1*5,o.height-block_h1*2)
(is2==false) ? last : last+g5.trim(frame2,-1).crop(spot_x2,spot_y2,block_w2*2,block_h2*2).mt_lut(y=Select(plane2,3,-128,-128,-128,3),u=Select(plane2,-128,3,-128,3,3),v=Select(plane2,-128,-128,3,3,3)).AddBorders(block_w2*3,0,o.width-block_w2*5,o.height-block_h2*2)
(is3==false) ? last : last+g5.trim(frame3,-1).crop(spot_x3,spot_y3,block_w3*2,block_h3*2).mt_lut(y=Select(plane3,3,-128,-128,-128,3),u=Select(plane3,-128,3,-128,3,3),v=Select(plane3,-128,-128,3,3,3)).AddBorders(block_w3*3,0,o.width-block_w3*5,o.height-block_h3*2)
#(is4==false) ? last : last+g5.trim(frame4,-1).crop(spot_x4,spot_y4,block_w4*2,block_h4*2).mt_lut(y=Select(plane4,3,-128,-128,-128,3),u=Select(plane4,-128,3,-128,3,3),v=Select(plane4,-128,-128,3,3,3)).AddBorders(block_w4*3,0,o.width-block_w4*5,o.height-block_h4*2)
noisedata.avsfunction FFTDenoise(clip source_, clip pattern_, int frame_, int spot_x_, int spot_y_, int block_w_, int block_h_, int plane_, int contrast_)
{
c=pattern_.trim(frame_,-1).crop(spot_x_,spot_y_,block_w_*2,block_h_*2).mt_lut(y=Select(plane_,3,-128,-128,-128,3),u=Select(plane_,-128,3,-128,3,3),v=Select(plane_,-128,-128,3,3,3))
c=c.ColorYUV(cont_y=contrast_,cont_u=contrast_,cont_v=contrast_)
c=c.AddBorders(0,0,source_.width-c.width,source_.height-c.height)
c=c.AssumeFPS(source_.framerate())+source_
c=c.fft3dfilter(pshow=false,pcutoff=0.02,pframe=0, pfactor=1.0, px=1, py=1, plane=plane_, bt=3, bw=block_w_, bh=block_h_, ow=block_w_/2, oh=block_h_/2, wintype=2, kratio=2.0, measure=true, interlaced=false, degrid=1)
c=c.trim(1,0)
return c
}
function MyConvolution(clip source_, int type_, float enhance_)
{
matrix_="1"
matrix_=(type_==3) ? "-1 -1 -1 -1 8 -1 -1 -1 -1" : matrix_
matrix_=(type_==5) ? "-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 24 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1" : matrix_
divisor_ = 9.0/enhance_
divisor_= (type_==5) ? 25.0/enhance_ : divisor_
g5y=source_.mt_lut(y=3,u=-128,v=-128).ConvertToRGB32("PC.601").GeneralConvolution(bias=128,matrix=matrix_,divisor=divisor_,auto=false).ConvertBackToYUY2("PC.601").ConvertToYV12()
g5u=source_.UtoY.mt_lut(y=3,u=-128,v=-128).ConvertToRGB32("PC.601").GeneralConvolution(bias=128,matrix=matrix_,divisor=divisor_,auto=false).ConvertBackToYUY2("PC.601").ConvertToYV12()
g5v=source_.VtoY.mt_lut(y=3,u=-128,v=-128).ConvertToRGB32("PC.601").GeneralConvolution(bias=128,matrix=matrix_,divisor=divisor_,auto=false).ConvertBackToYUY2("PC.601").ConvertToYV12()
return YtoUV(g5u,g5v,g5y)
}
#all planes dots in blocks
is0=true
block_h0=16
block_w0=16
frame0=4653
spot_x0=352
spot_y0=0
plane0=4
#blockiness
is1=true
block_h1=32
block_w1=48
frame1=4644
spot_x1=8
spot_y1=208
plane1=4
#
is2=true
block_h2=32
block_w2=32
frame2=4643
spot_x2=8
spot_y2=208
plane2=4
is3=false
here are blocks with noise pattern parameters. is?=true enables them in the scripts, where they are imported
redfordxx
6th January 2006, 19:43
Import ("noisedata.avs")
g_enhance=2#increase strenght when g? patteren is used (does not work for d? --- there is needed ColorYUV)
LoadPlugin("C:\Program Files\Multimedia\AviSynth 2.5\plugins\TIVTC.dll")
LoadPlugin("C:\Program Files\Multimedia\AviSynth 2.5\plugins\masktools.dll")
LoadPlugin("C:\Program Files\Multimedia\AviSynth 2.5\plugins\MVtools.dll")
LoadPlugin("C:\Program Files\Multimedia\AviSynth 2.5\plugins\DGDecode.dll")
LoadPlugin("C:\Program Files\Multimedia\AviSynth 2.5\plugins\fft3dfilter.dll")
LoadPlugin("C:\Program Files\Multimedia\AviSynth 2.5\plugins\undot.dll")
mpeg2source("test.d2v",cpu2="xxxxxx",moderate_h=30, moderate_v=50)
#crop(8,64,-8,-64)
crop(8,64,-72,-64)#crop, so it fits the screen (I have 1920x1200;-)
AssumeTFF
o=TFM(order=-1,field=-1,mode=1,PP=6,ovr="",input="",output="tivtc1.log",debug=true,display=false,slow=0,mChroma=false,cthresh=10,MI=1,chroma=false,blockx=16,blocky=16,mthresh=5,d2v="")
a3=o.mt_Convolution("1 1 1", "1 1 1",y=3,u=3,v=3)
a5=o.mt_Convolution("1 1 1 1 1", "1 1 1 1 1",y=3,u=3,v=3)
a7=o.mt_Convolution("1 1 1 1 1 1 1", "1 1 1 1 1 1 1",y=3,u=3,v=3)
a9=o.mt_Convolution("1 1 1 1 1 1 1 1 1", "1 1 1 1 1 1 1 1 1",y=3,u=3,v=3)
a11=o.mt_Convolution("1 1 1 1 1 1 1 1 1 1 1", "1 1 1 1 1 1 1 1 1 1 1",y=3,u=3,v=3)
d3=Subtract(o,a3).ColorYUV(off_y=2)
d5=Subtract(o,a5).ColorYUV(off_y=2)
d7=Subtract(o,a7).ColorYUV(off_y=2)
d9=Subtract(o,a9).ColorYUV(off_y=2)
d11=Subtract(o,a11).ColorYUV(off_y=2)
g5=o.MyConvolution(5,g_enhance)
vb = o.MVAnalyse(isb = true,blksize=4,chroma=true,search=3,searchparam=2,pel=2,idx=1,truemotion=true)
cb = o.MVFlow(vb, mode = 0,idx=1,thSCD1=300,thSCD2=130)
bb=mt_lutxy(cb,o,"x y - abs 4 > 0 255 ?",y=3,u=3,v=3)
mb=MaskedMerge(o,cb,bb,y=3,u=3,v=3)
vf = o.MVAnalyse(isb = false,blksize=4,chroma=true,search=3,searchparam=2,pel=2,idx=1,truemotion=true)
cf = o.MVFlow(vf, mode = 0,idx=1,thSCD1=300,thSCD2=130)
bf=mt_lutxy(cf,o,"x y - abs 4 > 0 255 ?",y=3,u=3,v=3)
mf=MaskedMerge(o,cf,bf,y=3,u=3,v=3)
i=Interleave(mf,o,mb)
#here is denoising - you can compare f0 with f1
f0=i
#f0= (is0==false) ? f0 : f0.FFTDenoise(g5,frame0,spot_x0,spot_y0,block_w0,block_h0,plane0,0)
#f0= (is1==false) ? f0 : f0.FFTDenoise(g5,frame1,spot_x1,spot_y1,block_w1,block_h1,plane1,0)
#f0= (is2==false) ? f0 : f0.FFTDenoise(g5,frame2,spot_x2,spot_y2,block_w2,block_h2,plane2,0)
#f0= (is3==false) ? f0 : f0.FFTDenoise(g5,frame3,spot_x3,spot_y3,block_w3,block_h3,plane3,0)
#f0= (is4==false) ? f0 : f0.FFTDenoise(g5,frame4,spot_x4,spot_y4,block_w4,block_h4,plane4,0)
f0=f0.SelectEvery(3,1)
f1=i
#f1= (is0==false) ? f1 : f1.FFTDenoise(d5,frame0,spot_x0,spot_y0,block_w0,block_h0,plane0,Int(g_enhance*256-256))
f1= (is0==false) ? f1 : f1.FFTDenoise(g5,frame0,spot_x0,spot_y0,block_w0,block_h0,plane0,0)
#f1= (is1==false) ? f1 : f1.FFTDenoise(g5,frame1,spot_x1,spot_y1,block_w1,block_h1,plane1,0)
#f1= (is2==false) ? f1 : f1.FFTDenoise(g5,frame2,spot_x2,spot_y2,block_w2,block_h2,plane2,0)
#f1= (is3==false) ? f1 : f1.FFTDenoise(g5,frame3,spot_x3,spot_y3,block_w3,block_h3,plane3,0)
#f1= (is4==false) ? f1 : f1.FFTDenoise(g5,frame4,spot_x4,spot_y4,block_w4,block_h4,plane4,0)
f1=f1.SelectEvery(3,1)
#for testing purposes - otherwise f? would be output
f0a3=f0.mt_Convolution("1 1 1", "1 1 1",y=3,u=3,v=3)
f0a5=f0.mt_Convolution("1 1 1 1 1", "1 1 1 1 1",y=3,u=3,v=3)
f0a7=f0.mt_Convolution("1 1 1 1 1 1 1", "1 1 1 1 1 1 1",y=3,u=3,v=3)
f0a9=f0.mt_Convolution("1 1 1 1 1 1 1 1 1", "1 1 1 1 1 1 1 1 1",y=3,u=3,v=3)
f0a11=f0.mt_Convolution("1 1 1 1 1 1 1 1 1 1 1", "1 1 1 1 1 1 1 1 1 1 1",y=3,u=3,v=3)
f0d3=Subtract(f0,f0a3).ColorYUV(off_y=2)
f0d5=Subtract(f0,f0a5).ColorYUV(off_y=2)
f0d7=Subtract(f0,f0a7).ColorYUV(off_y=2)
f0d9=Subtract(f0,f0a9).ColorYUV(off_y=2)
f0d11=Subtract(f0,f0a11).ColorYUV(off_y=2)
f1a3=f1.mt_Convolution("1 1 1", "1 1 1",y=3,u=3,v=3)
f1a5=f1.mt_Convolution("1 1 1 1 1", "1 1 1 1 1",y=3,u=3,v=3)
f1a7=f1.mt_Convolution("1 1 1 1 1 1 1", "1 1 1 1 1 1 1",y=3,u=3,v=3)
f1a9=f1.mt_Convolution("1 1 1 1 1 1 1 1 1", "1 1 1 1 1 1 1 1 1",y=3,u=3,v=3)
f1a11=f1.mt_Convolution("1 1 1 1 1 1 1 1 1 1 1", "1 1 1 1 1 1 1 1 1 1 1",y=3,u=3,v=3)
f1d3=Subtract(f1,f1a3).ColorYUV(off_y=2)
f1d5=Subtract(f1,f1a5).ColorYUV(off_y=2)
f1d7=Subtract(f1,f1a7).ColorYUV(off_y=2)
f1d9=Subtract(f1,f1a9).ColorYUV(off_y=2)
f1d11=Subtract(f1,f1a11).ColorYUV(off_y=2)
f1g5=f1.MyConvolution(5,25)
f1d5n=Subtract(f1a5,f1).ColorYUV(off_y=2)
f1d5s=Subtract(f1a5,f1d5n.mt_lut("x 128 - abs 2 > x 128 ?",y=3,u=3,v=3)).ColorYUV(off_y=2)
s0=Subtract(o,f0).ColorYUV(off_y=2).ColorYUV(cont_y=24*256,cont_u=24*256,cont_v=24*256)
s1=Subtract(o,f1).ColorYUV(off_y=2).ColorYUV(cont_y=24*256,cont_u=24*256,cont_v=24*256)
StackVertical(StackHorizontal(f1,f0,o),StackHorizontal(f1g5,s1,o.MyConvolution(5,25)))
here you can observe and compare, which pattern works best for you...and which d* or g* clip for given pattern
This script works for me exactly as it is. However, somebody reported error "Splice: Video framerate doesn't match"
Search for the reason here: ".AssumeFPS(i.framerate())" this is beacuse the FPS is increased with Interleave, but maybe it is not 100%.
redfordxx
6th January 2006, 20:02
There are things to improve, maybe you can help:
1-motion estimation is not very well tuned, and so the scene change decision.
2-are there general convolution filters with bigger kernel than GeneralConvolution (I think it has 5x5)? Moreover, it is not YV12.
3-What happens, when the noise is not everywhere in the referenced pattern block?
4-what is best method for using multiple noise patterns?
Example for 2 patterns:
a) get pattern1 --> MVFlow --> FFT3D pattern1 --> get pattern2 --> MVFlow --> FFT3D pattern2
-this is probably correct but slooow, lets forget it
b) get pattern1 --> MVFlow --> FFT3D pattern1 --> get pattern2 --> FFT3D pattern2
c) get pattern1 get pattern2 --> MVFlow --> FFT3D pattern1 --> FFT3D pattern2
d) get pattern1 get pattern2 create patternmix --> MVFlow --> FFT3D patternmix
now how to create patternmix:
-sum patterns?
-divide referenced pattern block in 2 parts and fill each part with one pattern?
Thanks,
By
R.
redfordxx
7th January 2006, 16:05
I updated the scripts, now all info is in noisedata.avs so I believe it is easier to manage...
Still.. any help with questions above?
tsp
7th January 2006, 16:08
redfordxx: If you only need a mean blur(that is a kernel with only 1's) you can try my variable blur filter (see link in sig)
redfordxx
7th January 2006, 20:13
Right now I need
-1 -1 -1
-1 8 -1
-1 -1 -1
and similar bigger.
I can't do that with masktools convolution.
Didée
7th January 2006, 21:35
The fastest (probably) variants of 3x3 conv blur modes are in kassandro's RemoveGrain package:
1 1 1 / 1 2 1 / 1 1 1 = RemoveGrain(11) (highly accurate, much more than blur(). Really.)
1 1 1 / 1 1 1 / 1 1 1 = RemoveGrain(20)
1 1 1 / 1 0 1 / 1 1 1 = RemoveGrain(19)
The last kernel you posted usually is used for (cheap) edgemasks, and is iplemented in MaskTools as EdgeMask("LaPlace") or mt_edge("LaPlace"). (it *should* be in, acc. to documentation, not sure if it actually is. If it's not, it can be build through DEdgeMask(0,255,0,255,"-1 -1 -1 -1 8 -1 -1 -1 -1") )
Dark Alchemist
7th January 2006, 22:12
1 1 1 / 1 2 1 / 1 1 1 WOW. I plugged that into my meager convolve plugin and all I can say is WOW. A very very very noisey video was cleaned up immensely.
Original (http://img438.imageshack.us/img438/2699/orig5lu.jpg)
Filtered (http://img425.imageshack.us/img425/4032/filtered6ol.jpg)
Didée
7th January 2006, 22:46
Nothing WOW. Leaving exactness-of-arithmetic out of the play, that kernel does just the same as blur(1) does. No magic, just a "dumb" gaussian blur /w radius=1. ;)
BTW, to me your screenshot doesn't look like "very very very noisy". It's moderately noisy. THIS (http://home.arcor.de/dhanselmann/_samples/Babylon5_snip.m2v) is very very very noisy (though Mug Funky might disagree ;) )
(BTW2 - for strong noise, no fun with just spatial filtering. Temporal domain is the mighty one, albeit dangerous as well.)
DeepDVD
7th January 2006, 23:04
I'm sorry if that's a noob question but I get stairs on gradients. It's in all plane-modes. As I can remember, MSU talked about reduced colorwidth.
Is there a chance to smooth the stairy gradient within FFT3D?
Sample: (made brighter and higher key to see a better difference)
http://img473.imageshack.us/img473/9818/stairs8tr.jpg
Dark Alchemist
7th January 2006, 23:27
Yeah, the really noisey parts are later in the movie I have and is from low light. That part is not as noisy as some other parts are.
redfordxx
7th January 2006, 23:28
The last kernel you posted usually is used for (cheap) edgemasks, and is iplemented in MaskTools as EdgeMask("LaPlace") or mt_edge("LaPlace"). (it *should* be in, acc. to documentation, not sure if it actually is. If it's not, it can be build through DEdgeMask(0,255,0,255,"-1 -1 -1 -1 8 -1 -1 -1 -1") )
thanks, but in mys script I need bigger...
The function MyConvolution I have there is not ideal;-)
Dark Alchemist
7th January 2006, 23:42
Temporal filtering can only be done via FFT or is there a temporal convolution scheme? In my searching via google I ran across something that said a 100x100 convolution pattern approaches the level of a fft.
Isochroma
8th January 2006, 00:07
By rotating the video in the third dimension, temporal can be made spacial and spacial made temporal... The best of spacial denoisers may be able to exceed temporal ones.
redfordxx
8th January 2006, 00:16
THIS (http://home.arcor.de/dhanselmann/_samples/Babylon5_snip.m2v) is very very very noisy
I experienced same type of "noise" too. In fact it is not noise of the video, it is something in the DCT --- it is block-oriented. It is possible to get rid of it with FFT3DFilter too, but with stronger parameters (in my script higher enhance_ or contrast_)
The problem is that after little stronger denoising FFD3DFilter produces horizontal and vertical lines pattern... As if the noise were combed out.
Probably a little postprocessing will be necessary.
Dark Alchemist
8th January 2006, 00:44
By rotating the video in the third dimension, temporal can be made spacial and spacial made temporal... The best of spacial denoisers may be able to exceed temporal ones.
Ahem, how do I take a 2d frame and move it into 3d? That part boggles my mind.
Didée
8th January 2006, 01:41
redforxx:
Ahmm ... not quite. The film source has a great amount of film grain. What we actually see is what DCT compression has made out of the grain. On playback, it sorta looks okay ... looking at the single frames, it's a good contra-example for the folks saying "No filtering! I want to keep the film grain!". (Because "the grain" is already gone ... what's left is loads of artefacts which fake the original grain ... rather poor on a per-frame basis, but somewhat succesfull at 24-25Hz ;) ). - Plus, one would need insane bitrates to reproduce it sufficiently.
FFT3D does not a bad job on this source, still its result is highly insufficent for my taste: depending on strength the noise is either only reduced, leaving the source still unstable; or the noise *is* reduced (around sigma=7~8), but detail is killed.
Actually B5 is one of my main test sources for MC'ed denoising, and I'm on the way to get a stable, death calm, sharp and detailed result out of it. Somewhen this year, hopefully ... I'll post something when it's ready. ;)
Ischroma:
We've heard that idea already. It does have its points, but it's not that easy by far. Given we had such a "3D rotation" filter, you can not just throw any spatial filter at it:
a) in "normal" 2D, there is a high probability that nearby pixels are correlated to the actual pixel. This probability is much weaker after rotation. Actually, exactly this is the general problem of temporal filters ... and rotating does not change the problem (the uncertainty of correlation) in any way.
b) A spatial filter works in 2 dimensions. A temporal filter works in 1 dimension. If you rotate & then filter 'spatial', what you effectively do is to filter the (rotated) temporal dimension plus ONE out of the TWO original spatial dimension. That's not good ...
BTW, wanna show us the superiority of NeatImage filtering compared to poor Avisynth filters? Sample was posted above ... :D
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.