PDA

View Full Version : DeFreq plugin - Interference frequency remover


Fizick
26th September 2004, 21:29
I have 2 bad TV channels in my internal analog TV-tuner. :(

Now I make and release beta version of DeFreq plugin - Interference frequency remover ;)

DeFreq spatial filter removes some frequencies from video frames.
It can be used for removal of interference frequency noise (regular inclined strips) from some TV capturing, and also for additional blurring.


Defreq uses Fast Fourier Transform method for frequency selecting an removing.
It is a spatial filter, and works as follows:
1) get frequency spectrum by forward FFT transform of frame image;
2) search some defined spectrum window (windows) for local maximum (extremum, most intense frequency);
3) remove frequencies at this sharp maximum from spectrum;
4) optional remove highest frequencies by low pass filter (for blurring, smoothing);
5) get output frame by inverse FFT transform of cleaned spectrum.

Defreq uses fast external FFTW library version 3 (http://www.fftw.org)
as Windows binary DLL (compiled with gcc under MinGW by Alessio Massaro),
which support for threads and have AMD K7 (3dNow!) support in addition to SSE/SSE2.
It may be downloaded from ftp://ftp.fftw.org/pub/fftw/fftw3win32mingw.zip
You MUST put FFTW3.DLL file from this package to some directory in path (for example, C:\WINNT).

Defreq will NOT work without it!

Try and post report!

scharfis_brain
26th September 2004, 22:28
could you provide some before/after shots?

I do not have TV-reception (I do not pay the fee for our crappy, blocky anlogue cable-TV) here, so I cannot test myself :(

Mug Funky
27th September 2004, 07:17
sorry, i can't see the link with the plugin? i've got fftw3.dll, but no defreq?

[edit]

never, mind. that "www" button is quite small :)

[edit 2]

hmm... it's killing virtualdub on load. fftw3.dll is in c:\winnt\system32, and defreq is being autoloaded.

i'm on a p3 733. could it be a cpu optimization problem?

[edit 3]

works fine when i manually load it... strange. the spectrograms are really pretty :)

hmm.... this is a REALLY sensitive comb-detector. all you need to is look for anything but noise in the middle bit of the spectrogram and you can be sure it's combing - it's a really distinct effect. i wonder if this could be used for anything?

JuanC
27th September 2004, 07:20
Originally posted by scharfis_brain
could you provide some before/after shots? You can see them at his WWW site.

@Fizick: I can't seem to download the plugin. Could there b a problem at your site?

EDIT: I got it now, I think there was something wrong in my browser. Thanks.

kingmob
27th September 2004, 10:50
Ah, i was thinking about this a few weeks ago, but i had no clue as how to program the Fourier Transforms :). I will try this out, sounds absolutely great.

[edit]Works great atm. Might be handy to work it out as a VDmod-filter. That would be easier with the tweaking. At the end you can always specify the paramaters in avisynth.

Mug Funky
27th September 2004, 12:36
hmm. an avisynth GUI would be useful here? maybe "show=true" or an apropriately named parameter could trigger a GUI for tweaking.

also, how are things like FFT size set? this would be a useful thing to play with (to make lowpasses have steeper or gentler rolloffs).

Fizick
27th September 2004, 20:12
Mug Funky,
1)Defreq is autoloaded well for my Athlon.
Can anybody else test this on P3, P4 ?

2)A common type of filter to use in frequency domain filtering is a Butterworth frequency filter. I use it as low pass filter.

But for sharp interference, Defreq02 simply (blindy) set 12 pixels around extemum to 0.

Now I prepare Defreq03 with adaptive frequency region size and degree of amplitude decreasing.

3) What is "Avisynth GUI" ?

As more far "to do", i think about mask using.
The draft mask may be produced by "show" mode, saved as image file, edited by Photoshop, and loaded as as frequency filter.
But it will be slow, and now i am not needed in it. :)

kingmob,
do you want to program the "VDmod-filter" ?
BTW, RGB is not appropriate space.


Can anybody test DeFreq for color interference?
I have not such bad TV sources :( :)
May be VHS ?

Mug Funky
28th September 2004, 16:17
avisynth plugins (i think C only) can have GUIs that flash up when the script is run. i don't know exactly how it works, but a search for "GUIsample" will give you plenty to go on :)

your plugin is C++, so you might not have the option.

Fizick
28th September 2004, 21:13
I hate (and do not know how) any visual control programming ;)
Any buttons nor with C, nor C++, nor FORTRAN.

More questions?
Now I try make v.0.4 with not absolute, but relative (to image size)frequency input.

JuanC
29th September 2004, 05:04
Originally posted by Fizick
1)Defreq is autoloaded well for my Athlon.
Can anybody else test this on P3, P4 ?
I'm on a P4/1.6Ghz. I'm trying DeFreq on a noisy analog TV capture (NTSC 720x480, 29.97 fps, mpeg2 @9mbps). When not separating fields, I have no "vdub disappearing" problems, but as my clips are captured interlaced (I IVTC them afterwards)...

(I use WinXp, fftw3.dll is at \windows\system32)

So, when separating fields, 720x240, 59.94 fps, AND using show & info parameters, sometimes (when using "inappropriate" values for fx/fy ???) DeFreq is making VdubMod disappear when auto loading, and when manually loading, VDubMod disappears after advancing a few frames.

Here's my script: SetMemoryMax(192)
LoadPlugin("G:\Program Files\AviSynth 2.5\plugins\Test\DeFreq.dll")

video1=DGdecode_mpeg2source("test1.d2v")
audio1= WAVSource("test1.WAV")
video1a=AudioDub(video1, audio1)

#AssumeTFF().SeparateFields()
Return DeFreq(fx=68,fy=-75,show=true,info=true)
#Weave()...

Fizick
30th September 2004, 06:13
JuanC, Mug Funky,
It worked OK for me,
but now I changed something (with logarithm) in new version:

Defreq version 0.4, 30 September 2004 - change fx,fy,dx,dy,cutx,cuty parameters to (float) percent of FFT size

Try.

Hallo, anybody is here? :)

Mug Funky
30th September 2004, 08:28
hmm... the filtered result seems to come out strange. like the low frequencies have been replaced with black (rather like a diffuse glow filter set to subtract rather than add).

here's my setting:

defreq(fy=-40,fx=1,sharp=96)

[edit]

this only seems to happen after playing 1 or 2 frames. it doesn't seem to happen at all if you step-through the frames.

[edit 2]

just for fun, here's a nice "soft focus" effect :)
soft=last.defreq(cutx=5,cuty=5,plane=0).defreq(cutx=10,cuty=10,plane=1).defreq(cutx=10,cuty=10,plane=2)
overlay(last,soft,opacity=0.5)

it'd be nice to have 3 plane parameters, rather like masktools has (y=3,u=3,v=3 or something similar). this would save a little typing.

Fizick
30th September 2004, 22:23
Version 0.4.1, 01 October 2004 - fixed bug with init

JuanC
1st October 2004, 06:48
Fizick, thanks alot for the new version 0.4.1. I tried it:

I keep getting VDubMod "vanishing" problems on my P4, but you've narrowed the conditions to make the problem happen (it wasn't unadecuate values for fx or fy, now they're easier to undestand and use). Here's the problem: Every time I use the show=true parameter :( VDmod will vanish just when advancing 1 frame. Note: If I don't use the "show=true" parameter, VDMod won't vanish even after scrubbing the positional slider for a while.

Also, there is an oddity: Using the following script: SetMemoryMax(192)
LoadPlugin("G:\Program Files\AviSynth 2.5\plugins\Test\DeFreq.dll")

video1=DGdecode_mpeg2source("test1.d2v")
audio1= WAVSource("test1.WAV")
video1a=AudioDub(video1, audio1)

MyBlack=BlankClip(video1a, length=30).assumeTFF()
AlignedSplice(MyBlack, video1a)

AssumeTFF().SeparateFields()
Return DeFreq(fx=50,fy=80,show=true,info=true)
#Return Weave() Vdub will show the first 60 frames (0-59) without "vanishing", displaying "DeFreq Peaks: x=0.0 y=0.0 sharp=-1.$", then it will show the first original video clip frame (#60) displaying "normal" DeFreq info with it, but if I try to move to the next frame (#61), VDMod will "vanish".

Hope this report helps any way.

Mug Funky
1st October 2004, 13:34
tanks, muchly for the new version. i haven't found any bugs yet (the strange too-dark frames thing is solved it seems).

the lowpassing gives a very pleasant effect - gentle rolloff of highs, so there's still a bit left.

Fizick
2nd October 2004, 02:00
JuanC,
thanks fo report!
I found and fixed problem for pure black "DeFreq Peaks: x=0.0 y=0.0 sharp=-1.$"
But not with Defreq 0.4.1 not new 0.5, my VDUBMod do not "vanish".
I try almost your script:

setmemorymax(128)
loadplugin("defreq.dll")
avisource("i:\polos2.avi")
video1a=converttoyv12()

MyBlack=BlankClip(video1a, length=30).assumeTFF()
AlignedSplice(MyBlack, video1a)
AssumeTFF().SeparateFields()
Return DeFreq(fx=50,fy=80,show=true,info=true)


Try new released version 0.5.

I wonder, why somebody else do not post anything (my counter show about 100 dounloads of this buggy filter).

Mug Funky,
I like FFT smoothing too. :)
I do not want make processing of 3 color planes for the present (and probably in future). They are processed independently.


BTW, you can see spectrum before and after Defreq with help of two more Defreqs (for test) :)

before=defreq(show=true)
after=defreq(cutx=10,cuty=10).defreq(show=true)
interleave(before,after)

Probably, we can test some other denoising filters this way. :)

before=defreq(show=true)
after=vaguedenoiser.defreq(show=true)
interleave(before,after)

But I use in defreq variable (adaptive) scale for spectrum show,
from min to max (with logarifm).
May be fixed scale will be better for it.


P.S. I will absent some days because of Internet payment overdraft.:(

Fizick
9th October 2004, 01:40
Version 0.5.1, 07 October 2004 - more fast processing of frames which are not needed in cleaning,
source released under GPL.

EpheMeroN
9th October 2004, 02:19
Your plugins are on your WWW yes? What is your URL exactly? Call me stupid :-) but I cannot find it.

JuanC
9th October 2004, 02:46
clicking on the WWW icon under his post will take you to http://bag.hotmail.ru/

Unobtanium
17th October 2004, 06:12
Fizick

I'm testing version 0.5.1 of the filter on a Type-1 DV clip that I captured off-air. The spectrum shows multiple peaks but only one is listed in the info.
Your screen cap photo part 2 gives info on two peaks; is there a way that I can get Defreq to list the X and Y values of the other peaks that appear in the spectrum?

Since you are seeking feedback, some of the following information may be of value to you:

2.6 GHz Pentium 4C (Northwood)
Running at 3.12 GHz
Hyperthreading Enabled
AGP/PCI bus 66/33 MHz
Windows 2000 SP4 environment
1024 MEG of Corsair PC3200 RAM not overclocked
ABIT IC7 MAX3 Motherboard

I have not experienced any stability problems with DeFreq. I am currently viewing the clips with Media Player Classic. I haven't tried VDub or VDubMod yet.

Thank you for making DeFreq available. I think that it will be enormously useful once I learn how to use it effectively.

Fizick
17th October 2004, 21:19
Unobtanium,

is there a way that I can get Defreq to list the X and Y values of the other peaks that appear in the spectrum?
What is your script?
You must set not only fx,fy but also fx2,fy2 to some values.

Unobtanium
19th October 2004, 00:31
Fizick,

Thanks for the prompt reply, the script is:

LoadPlugin(PluginPath + "defreq.dll")
DirectShowSource(SourcePath + SourceName, fps=30, video=true,
\audio=true, seek=true)
SeparateFields()
DeFreq(Show=true, Info=true)
Evens=SelectEven().Subtitle(("Even"), x=600, y=225)
Odds=SelectOdd().Subtitle(("Odd"), x=600, y=225)
StackVertical(Evens, Odds)

When I play the script, DeFreq lists one peak at ~x=10 ~y=-10. The exact frequency shifts a bit from scene to scene, and is mostly the same for both fields.

My question relates to the fact that the left part of the frame (the spectrum) shows additional peaks at higher frequencies. The do not appear to be harmonics of the listed frequency. Please forgive my stupidity if the answer is obvious, but I do not see how to get DeFreq to identify the higher frequency peaks.

Fizick
19th October 2004, 06:49
Unobtanium,
You must add some parameters to Defreq:

DeFreq(fx=10, fy=-10, fx2=10, fy2=20, Show=true, Info=true)



Then you must look to position of rectangles, and tune these parameters and may be others (sharp,dx,dy,dx1,dy2,fx3, fx4 and so on)

johnmeyer
6th November 2004, 21:56
I too have problems with Version 0.5.1, using AVISynth 2.55. Here's the script:
loadPlugin("c:\Program Files\AviSynth 2.5\plugins\defreq.dll")
AVISource("E:\NPS\NPS0001.avi")
converttoYV12(interlaced=true)
AssumeBFF
SeparateFields()
DeFreq(fx=10, fy=-10, fx2=10, fy2=20, Show=true, Info=true)
Weave()
If I run this with the SeparateFields() and Weave() parameters, VirtualDub gives me the following error:

Avisynth read error: Avisynth: caught an access violation at 0x77f581bd, attempting to write to 0x80808080

If I run this WITHOUT the SeparateFields() and Weave() parameters, it works fine. Also, if I remove the Show=true and Info=true, I can run with the SeparateFields() and Weave() parameters. Thus, the problem is only if I use the Show and Info parameters with the fields separated.

Can I simply proceed with the values I get when reading the interlaced source? If so, I can work around this bug.

Until I hear from you, what I am doing is using the values I get when reading the interlaced source.

Fizick
7th November 2004, 03:08
johnmeyer,
thanks for report.

It is a strange bug, for height < 540 only (not for my PAL).
I do not quite ungerstand it, but correct in new version 0.5.2.

Try!

johnmeyer
7th November 2004, 09:28
Thank you for such a quick response. I tried the new November 7, 2004 defreq.dll, and I am sorry to report that I get exactly the same error. However, while it is a pain, if I temporarily remove the SeparateFields() and Weave() commands, the numbers I get from the Show and Info settings seem to work extremely well. I just put them into Defreq, un-comment the SeparateFields() and Weave() commands, and proceed.

Thus, I can work around the bug.

The results from this plug-in are amazingly good. Thank you very much.

scharfis_brain
7th November 2004, 11:38
as workaround, you may use:

xxxsource("video.xxx")
assumetff
bob()

defreq()

converttoyuy2()
assumetff()
separatefields()
selectevery(4,0,3)
weave()

if your video is bff, set both assumexff to bff

johnmeyer
7th November 2004, 19:14
Good news: Your script stops the crash.

Bad news: Both x2 and y2 values now report 0.

--------------

Edit:

Ah, I looked back and your script, and added:

converttoYV12(interlaced=true)

before calling defreq, and it now works.

Fizick
7th November 2004, 21:29
Try version 0.5.3

johnmeyer
7th November 2004, 21:56
Good.

This version does not cause problems with either my original script or with the modified bob() script you provided. My only remaining question is about the numbers provided by each script.

When I use this script:loadPlugin("c:\Program Files\AviSynth 2.5\plugins\defreq.dll")
AVISource("E:\NPS\NPS0001.avi")
converttoYV12(interlaced=true)
AssumeBFF
bob()
DeFreq(fx=6.1, fy=4.2, sharp=8.1, fx2=8.6, fy2=13.8,sharp2=7.3, show=true,info=true )
assumebff()
separatefields()
selectevery(4,0,3)
weave()

I get x=4.7, y=5.8, sharp=7.8, x2=7.2, y2=15.4, sharp2=6.2

for the first frame.

However, when I use this script:

loadPlugin("c:\Program Files\AviSynth 2.5\plugins\defreq.dll")
AVISource("E:\NPS\NPS0001.avi")
converttoYV12(interlaced=true)
AssumeBFF
separatefields()
DeFreq(fx=6.1, fy=4.2, sharp=8.1, fx2=8.6, fy2=13.8,sharp2=7.3, show=true,info=true )
weave() I get x=6.6, y=1.7, sharp=4.7, x2=7.2, y2=11.7, sharp2=4.6

Obviously, bob shifts fields, so maybe that's the difference, but I would not have expected such a huge difference. I am not sure which approach I should use. Since I got good results using the second script, I am tempted to continue to use that, unless you advise me otherwise.

Just to be clear, this video is NTSC 29.97 DV BFF video which originated from a camcorder, but then got the diagnol lines from an over-driven amplifier during a duplication process. I couldn't get access to the original tapes, so I had to clean up the copies.

Fizick
7th November 2004, 23:00
Do not use Bob here.
It doubles height by interpolation,
and it is scharfis_brain's "idee fixe" :)

johnmeyer
7th November 2004, 23:32
That's what I thought. I'll stick with the usual method for operating on separate fields.

Once again, thank you very much for all your help. I use most of your plug-ins, and they are all truly remarkable.

My next experiment (in a few days) is going to be to use Depan to generate super-smooth slow motion, much like Motionperfect. I got very interesting results with mvtools, and I want to see if I can do as well or better using depan.

Palmnut
18th November 2004, 21:23
In your html help script you say:

"Set fx=0 for strictly vertical frequency interference stripes, set fy=0 for strictly horizontal one."

I am trying to deal with purely vertical lines (see attached), however if I set fx=0, the show=true display (and the result I see if I subtract the processed from the input) shows horizontal lines. Setting fy=0 seems to produce the required purely vertical response.

Huh?

[EDIT}

Damnit - this should have been added to threadid=82978, but got posted here by mistake. Could a mod please move it to the correct home? Thanks.

Fizick
18th November 2004, 22:15
It is manual bug. Sorry my English :D

zilog jones
29th November 2004, 12:00
What am I supposed to be looking for exactly on the frequency spectrum? Is it only brighter parts of lines like the example on your site, or can it work with other things too?

And how do I set "sharp"? Do I put it higher or lower than what it's usually reading?

I'm trying to see if I can make it help with a VHS capture - there's no really profound stripes on the video (though there seems to be vertical stripes on that channel a lot - I can't really see if they were there on the capture though), but could it help with any other regular interference? I get a thick wobbly line around x=60 vertically down the spectrum (sorry I'm not at home so can't give a picture), broken in parts - could DeFreq do anything about that?

Fizick
29th November 2004, 20:00
try yourself :)

oledoe
2nd December 2004, 13:03
(fx2,fy2) doesn't work.
That can be seen by using watching the output of info=true.
The peak for (fx2,fy2) is always on (0,0)

Line 869-870 ("search Peak in windows" for YUY2) of defreq.cpp should be

if (fx2>0 || fy2 !=0)
DeFreq::SearchPeak(out, outwidth, src_height, fx2, fy2, dx2, dy2, fxPeak2, fyPeak2, sharpPeak2);

Instead, there was a couple of (fx3,fy3) parameters, maybe left over after a copy and paste.

Thanks.

zilog jones
2nd December 2004, 17:30
Originally posted by Fizick
try yourself :)
I've already tried, but I really don't know what I'm doing. Here's two examples of my VHS captures:
http://www.skynet.ie/~zilog/pics/defreq.png
This one is pretty recent, from a cable source (the channel's up somewhere on the hyperband if that's of any help), and it kinda looks like there's vertical striping among other things.

http://www.skynet.ie/~zilog/pics/defreq-crappy_reception.png
This is from a tape recorded in 1989, with a pretty bad reception (UHF). The vertical line on the right side of the spectrum is there nearly all through the capture, sometimes accompanied by a few others near it. The stuff at the left half is always there too.

Basically, where do I set the windows for these? And will it even help much? And can the low-pass filter help?

Fizick
2nd December 2004, 23:11
oledoe,
thanks fo exact report!
Tom barry said sometimes ago, how useful is source releasing for support :)

v.0.5.4 is out.

zilog jones,
i see jitter or interlace on top picture.
The bottom is really bad.

lark
3rd December 2004, 08:56
looks like you have invented a timemachine ;-)

Version 0.5.4 - December 8, 2004

BTW, i'd appreciate, if you'd add news to your home page (i.e. saying, when each plugin was last modified).

regards
t :)

Fizick
3rd December 2004, 09:26
:D

zilog jones
3rd December 2004, 09:55
zilog jones,
i see jitter or interlace on top picture.
The bottom is really bad.

The top one is actually progressive, it's just some of the noise is interlaced, and I know DeFreq can't fix that. I know the bottom one's bad, but how would I set DeFreq for these?!?

Fizick
3rd December 2004, 10:06
zilog jones,
No , defreq mostly can delete regular noise.

For your first (progressive) jittered frame, we must have some new plugin to de-jitter it firstly . But not from me, sorry :)

zilog jones
3rd December 2004, 11:25
But don't those straight lines going down the spectrum mean there's some regular noise there?

oledoe
3rd December 2004, 12:05
You've got to love GPL software.
:)

BruceL
18th December 2004, 17:06
Hello Fizick. I was not sure if you were still following this thread but thought I would write anyway. Thank you for a great filter. I have been experimenting with Defreq and have been getting terrific results as I also get diagonal vertical noise lines. I did notice and was not sure if you or anyone else have had this experience. When there is Credit Text, bolder more vertical lines appear. I attached screen shots showing with and without the filter. Any help or advise would be greatly appreciated.

Don't seem to be able to use attachments.

Fizick
19th December 2004, 00:05
BruceL,
May be you use too large search windows?
Post your script!
And spectrum (show mode) image.

BruceL
19th December 2004, 01:38
Fizick,
I spent the rest of today doing more experimenting. I am embarrassed to say one of the windows I made which I thought was helping me, was actually causing the problem. Thank you for your fast response but more importantly, thank you again for sharing such a terrific filter.

EpheMeroN
11th January 2005, 08:42
I think I've figured out DeFreq. A simple call of it like this: DeFreq(fx=x,fy=-x) and the "fx param" refers to the actual angle of the interference noise, while the "fy param" refers to the thickness of the interference noise yes?

The "fx param" from 0-100 goes from center and moves right and upward as you increase the number correct? So, in essence it goes from left to right until its completely vertical. My problem is, this bad analog station I receive in here has BAD interference noise at an extreme right-to-left pattern that I do not know how to fix using DeFreq. Below is an image of what I'm working with:

http://img101.exs.cx/img101/5976/noise019jt.jpg

http://img101.exs.cx/img101/6570/noise023qy.jpg

EpheMeroN
25th January 2005, 08:47
Nothing?

Fizick
25th January 2005, 21:48
EpheMeroN,
I wonder why you interpret the filter manual by so strange way :)
Really, the angle (slope) of stripes is defined by (but not equal to) the fy/fx ratio.
(by cotangent).
The stripes period is defined by inverse absolute length of (fx,fy) vector, i.e. period is about 100/sqrt(fx*fx+fy*fy).
So, if your stripes is near vertical, set small fy<fx.
You must try and watch stripes in show mode).
"Thickness" the noise is controlled by dx, dy parameters.

BTW, it will be great if somebody (not me) write a short article about Defreq to Analog Capture Guide.

Wilbert
25th January 2005, 21:56
BTW, it will be great if somebody (not me) write a short article about Defreq to Analog Capture Guide.
We will some day (in version 4.3 I think ...) :)

EpheMeroN
26th January 2005, 02:40
Mind putting that in Laman's Terms w/ a sample to get me started?

somail
17th March 2005, 09:37
So basically the idea is to get the Stripes (upper right window when show=true )to match the actual interference that you see in the video. To do this you adjust the x,y and place the search window over hot spots untill the right pattern/slope shows in the upper right hand window. Then make show=false, info=false and encode.

Is this correct?

Fizick
17th March 2005, 20:47
Yes,
and you must see some peak (light) near search window center in show mode.

Morpheus_xx
4th April 2005, 16:42
@Fizick:

DeFreq looks very promising to me. Can it help with this problem?
http://forum.doom9.org/showthread.php?s=&threadid=92478

Greetinx
Morpheus

Mug Funky
7th April 2005, 09:59
yay! thread resurrection!

i was watching a particularly bad source on "blue only" mode, and realised that rainbows could be described as a specific frequency of interference that exists only on edges and mainly on the chroma channels (though in bad cases, like the Fawlty Towers DVDs, it spreads to the luma and borks diagonal edges).

so:

could it be possible to use DeFreq with (or without) some masking to nicely get rid of rainbows?

i'll grab a high-bitrate NTSC sample as soon as i finish the current encode i'm on... don't know when i'll be able to host it though (when i get home?).

i thought i'd post here rather than spend all night on it myself because i figured Fizick would know best how to configure his plugin for the desired effect (i find configuring DeFreq rather like playing the theremin with tongs, while wearing earplugs).

[edit]

btw, don't you believe it they say Project A-Ko was digitally remastered... all it is is the old shitty source with a smidge of denoising and some colour correction. grrrrr.

LigH
10th May 2005, 22:26
Hi Fizick,

because I know that you enjoy happy and thankful users so much ... I'd like to forward thanks of another user of the german board, who successfully enhanced his captures using DeFreq:

http://forum.gleitz.info/showpost.php?p=195848&postcount=7

This thread contains some before/after pictures; although they don't show exactly the same frame, they still show the success clearly.

Fizick
10th May 2005, 23:51
Thanks for info!

vcmohan
11th May 2005, 05:54
I think that the type of noise shown in Ephemeron can be effectively removed by fanfilter (http://www.avisynth.org/warpenterprises) plugin and is being discussed in seperate threads of How to remove diagonal bars etc.

hartford
19th May 2005, 05:10
I must thank you for your filter, ie "fanfilter."

I used it after applying DeFreq and it performed well.

I'm not disparaging Fizick's filter. I simply found that
your filter AFTER Fizick's filter gave me the result for which I searched.

loba
27th June 2005, 20:18
Sorry if I'm asking a question in a wrong place, but how to interpret this spectrum surface?

I know that FFT computes sin (or cos) components (amplitude, frequency, phase) of a continuous signal, but cannot interpret the spectrum image that DeFreq shows. In this case what is the signal: separate lines, or the whole datastream (luma, chroma?), what is the x-axiys and y-axis, and the intensity value of the spectrum?

I tried to play with this filter, but cannot get any result. I cannot use what I cannot understand:) Ok, I could live without the math of this FFT thing if I would know what to look for. I know that I should look for peaks in the spectrum, but I have several, are there "good" and "bad" peaks? I also see that I could just use the stripes showing on the right, but should I align the white or the black bars to the noise? I cannot seem to control the width of these bars differently (I have a clip where there are thin vertical noise bars).

Please, provide some hints for a less educated one. Thanks in advance.

Fizick
27th June 2005, 21:25
I am not a teacher, but plugin writer :)
So, please use some book or article.
Shortly, defreq use not 1D, but 2D transform. X and Y are dimension (frequency).
Only spectrum amplitide is shown as image intensity.

trevlac
28th June 2005, 03:53
@loba,

I've never used Fizick's wonderful filter. I really only use digital source. However, I felt compelled to respond. :) This stuff has been a topic of interest for me.

Unfortunately ... the interference pattern is not self evident to the filter. So Fizick has provided 3 ways to help identify the place in the frequency spectrum that contains the noise.

A quick guide to frequency analysis: It's just like the audio spectrum you see on an audio equalizer. Audio breaks up the highs and lows. Video breaks up the sharp details and the smooth planes.

Way #1: Frequency image

Audio is shown in 2D as frequency of bar and height of bar. Video is in 3D. X & Y show the orientation and wave length of the frequency (Think of an X,Y graph. If Y is zero and you move across the X's, you are covering the horizontal frequencies where the vertical ones are zero. If you go to a spot where X and Y are not zero, you are talking about a frequency that runs at a diagional angle.) Unfortunately .... the the frequency image is hard to read, especially if you want to know the exact frequency in question (like 3MHz). The 'zero points' are the top left and bottom left.

I believe the top half of the image may represent frequencies (stripes) that go from bottom left to top right. The bottom half represents stripes that go from top left to bottom right (like Fizick's example).

Way #2: Bright spots in the image

The 3D part of the image spectrum analysis is that the brightness of the spots represent the amount of the given frequency in the image. Picture the image 'from the side'. I would look like a 3D mountain range. The bright spots are the highest peaks and a good candidate for a repeating pattern in the regular image.

Trial and error on blocking out the spots is a good way to narrow down. You can also try some big windows to see if you are even looking in the right area.

Way #3: Sample stripes

The angle (orientation) and thickness of the stripes matter. What is black and what is white do not. These are a great way to see if you are close. The stripes are not a 'frequency image', but a regular image of the chosen frequencies. Their black/white starting point doesn't matter because that is actually not a factor of their frequency, but a factor of their phase.


Hope I got it at least reasonably correct .... :)

hartford
28th June 2005, 04:13
My silly take on this filter.

There are infinite numbers that represent 45 degrees. What is the width of 45 degrees? That is the problem.

If the interference is 45 degrees the "width" is generally unknown. That is where "ratios" take effect, and that is what is the difficulty in applying this filter.

If I can see that the the interference is at a particular "angle" but I don't know the "thickness" then I must do trial and error. It would help if there was some way to determine the "thickness."

Sounds silly, but that's my experience.

trevlac
28th June 2005, 19:23
hartford

If you know the interference is 45% and which way it runs ... bottom left to top right for example ... there are actually not too many spots to look. If the 'width' of the interference is a 1 pixel wide line, this coresponds to some frequency at the right edge of the image. If the 'width' is so wide that it covers the entire image, the frequency is at the left edge. The width of the interference bars is related to the spot in the frequency image by imgWidth/2 - barWidth. Count over that many pixels and that is where your frequency is. Um ... at the angel you are looking for.

-------

Anyway ... I've been playing with this stuff a little, and I made a virtualdub filter that might help. Might not.

Load your video and the filter. Click the db (log) radio button, and the 'All' button options. Then click show preview. This will show a frequency image much like Fizick's. You can draw little squares (with your mouse) on the right half of the preview window. This will mask out little bits of frequency. Toggle back and forth between the "Filtered Image" and "Frequency Image" radio buttons to see if you have the right spot.

BUT there are a number of differences in my image vs Fizicks. Mine is twice as wide and duplicated across the center. So ignore the left side of mine. Mine is also oriented where the upper left and lower left corners of Fizick's image are flipped to the center.

http://www.trevlac.us/pics/Orientation.GIF

This may help find the right spots. I hope it does not cause more confusion.


My 'experimental' filter can be had here.

http://www.trevlac.us/FilterDocs/Filters.htm

Fizick
28th June 2005, 19:30
Trevlac,
good guide!

Hartford,
There are infinite numbers that represent ANY angle (not only 45 degrees).
Yes, if you found approriate fx,fy values to represent right angle (as shown),
then you must change BOTH fx, fy (with constant ratio) to set approroate "width" (step).
I do not want change this.
But you can use some script variables. It is not very advanced math, similar to:

frx=30
ratio=-1.5
fry=frx*ratio
defreq(clip, fx=frx,fy=fry)

loba
1st July 2005, 15:31
Anyway ... I've been playing with this stuff a little, and I made a virtualdub filter that might help. Might not.



trevlac,

Great work! I almost understood this whole thing from your webpage. But what's more important, I was able to get some interesting result with your Virtualdub filter (removing vertical bars) using the horizontal lowpass option. Now I wonder if such an option exists in Fizick's DeFreq plugin (for using Avisynth only) or should I remove those bars in Virtualdub and make other filtering in Avisynth... I see that there are cutx and cuty parameters, but there is no option for slope (this parameter did the trick in trevlac's filter, using low freq and a moderate slope). Maybe next version? :)

bdfy
12th July 2005, 22:53
help file seems to be a bit complicated for niewb :(
I played with the parametres , but never got proper results :(
Here is a screenshot from avi-source I want to process
see attachment (80kb)
What parameters should I try ? I wonder if you can give advice using screen...

LigH
12th July 2005, 22:57
Only get an error page.

Why don't you attach the image directly to this thread?

Fizick
13th July 2005, 17:14
bdfy,
Please re-read all this thread.

bdfy
13th July 2005, 21:08
Fizick
Still lots of quastions...
I need to estimate angle,width of stripes and "strengh" of processing. Right ?
Angle:
the angle (slope) of stripes is defined by (but not equal to) the fy/fx ratio.
(by cotangent).
Width:then you must change BOTH fx, fy (with constant ratio) to set approroate "width" (step)...
OK, math is simple , but what is the units for width ? pixels, mm ?
Or the only way to find out the right value is to look at upper right window ( compating with lower one ) using info,show parameters. It's hard enough, but it's accomplishable.
But I still have no idea what plugin shows with Defreq(show=true,info=true) parameters :( How to use this info ?
"Thickness" the noise is controlled by dx, dy parameters.
Is this some kind of processing "strengh" ?
It would be great if you answer in russian here ;)
http://forum.ixbt.com/0029/009331-31.html

Fizick
13th July 2005, 21:35
1. А читал ли ты русскую документацию?
(do you read the russian documentation?)
2. Prease read Trevlac's description.
2. Make some attempts, and you got the right answer yourself. ;)

bdfy
13th July 2005, 22:31
I know, RTFM is always suitable answer :) - Yes, I read all the docs provided with the archieve and this topic from the very beginning. And I still have a lot of questions :(
I believe, you made a great filter , but its help IMO is awfull - there's no easy to understand instruction how to use it. I'm not the first and seems to be not the last man asking simple questions about filter's usage ;) I suppose it would be great to
provide a good tutorial for users in order to avoid oft-recurring questions. Just a quick tute with common example. Just any screenshot and explain how to choose suitable parameters for such a source.

PS : no sense ( i.e fonts :)) to post here in russian

Fizick
14th July 2005, 00:50
I am not a teacher, but plugin writer :)

Sorry, i have no time.
When you learned to use Defreq, please write a tutorial and post here.

bdfy
14th July 2005, 01:00
OK, thus I ask anyone who has enough time and experience with this filter :
TUTORIAL NEEDED!

Fizick
14th July 2005, 06:15
Here is the good tutorial:
http://forum.doom9.org/showthread.php?p=679006#post679006

lumier
31st July 2005, 05:58
Hello Fizick,

I am really impressed with your great filter, it works very well for a lot of my (Hauppauge PVR-150 based) broadcast captures :thanks: .

I do a lot of captures and I have noticed that the intereference frequencies change enough in between captures that I have to figure out new input parameters for defreq every time.

Now you have given us an easy, graphical way to figure these parameters out (defeqs output for show=true) , though I guess that many people might not fully understand how to use it right (took me some time to get used to ...).
E.g. I see people at the beginning of the thread share their input parameters for defreq. This only makes limited sense, because the parameters they give work only for their specific broadcast signal (e.g. the show they recorded) and the noise it contains. As I wrote above I find that for my own captures (TV cable) the interference frequencies (and therefore defreq input parameters) shift dramatically with time and channel!

In this way, defreq works very differently from many other AviSynth filters (e.g. needing very different parameters with every source). Because of this difference, I guess that quite a number of inexperienced users might not understand how to use defreq well.
Automating defreq could strongly improve this, making your filter more "newbie" friendly and thus - I am sure - even more popular.

Here is my idea how to do the automation:
A)
Have defreq run twice in two different modes. The first pass is used to determine the input parameters we currently pass to defreq "by hand" and to output these parameters to a file. The 2nd pass then reads the file and applies these parameters to the source material.
B)
In order to determine the parameters:
Use your defreq show output display (the grayish display showing the input picture transformed to frequency space) and sum the pixel value for each individual pixel in this display over time (e.g. all frames). Now we compare this sum value for each pixel with the sum value for pixels who are close to it. For a pixel that represents an interference frequency (e.g. defreqs needed input parameters would be a window around that pixel), we should find
(Sum Pixel)/(Sum Pixel_close) >> 1.
We could define a cutoff parameter so that when (Sum Pixel)/(Sum Pixel_close) >= parameter defeq assumes the pixel represents an interference frequency.
In other words: we recognize the interference frequencies via their time behavior - interference frequencies are "always on" and the integral over their amplitude over time must be much higher than surrounding amplitudes.

I am curios what you think ...

Fizick
31st July 2005, 13:39
lumier,
Your idea is great!
I say about temporal averering of frequency spectrum.
I am not shure, that fully authomatic parameters estimation will be possible,
but at lat we will see very sharp peak at interference frequency.
Probably we do not need in full clip first pass, but in some range only, about 20 frames. But these frames must be dynamic (not static) scene.
By the way, we can try this method right now, by temporal averaging with TemporalSmooth (with very high thresholds).
I will try implement your suggestions in new version later, after some discussion.

lumier
31st July 2005, 19:55
Your idea is great!

Glad to hear you're excited :)


Probably we do not need in full clip first pass, but in some range only, about 20 frames. But these frames must be dynamic (not static) scene.

Yes, I was thinking that too. Although I wonder about the amount of frames we want to use (dynamic scenes are a MUST). I have noticed that sometimes the interference frequencies seem to "pump" (e.g. come and fade) over the course of a second or so in the frequency space display - so 20 frames might be little bit on the low side.
Tests should help us out a lot here ...


By the way, we can try this method right now, by temporal averaging with TemporalSmooth (with very high thresholds).

Tell me more how you want to go about this.
Also, I noticed that I often find 3+ interference frequencies for my captures. Some of them are not so obvious in absolut amplitude strength (white dot sticking out very strongly in defreqs frequency space display), but when you compare these less obvious ones with their surroundig (pixels close by), they can be easily identified. For these cases we might need to define what we want to consider "close by".


I will try implement your suggestions in new version later, after some discussion.
I am thrilled to hear this.

Lumier

Fizick
31st July 2005, 21:55
Yes, 20 is probably is too small. 100 is better.
Try temporal averaging with TemporalSmooth:

defreq(show=true)
temporalsoften(100,255,255,255)

Fizick
3rd August 2005, 21:49
Version 0.6, August 2, 2005 - added temporal average mode show=2 (thanks to lumier for idea), changed show parameter to integer type; reorganized view of the spectrum window; cleaned a code.

lumier
4th August 2005, 20:29
That was really fast :thanks: ,
I'll try it out ASAP :).

frank10
7th September 2005, 11:06
I've read all the manual and this thread. I have still problem with this clip captured from VHS:

It seems to have this static interference (diagonal BottomLeft-TopRight) not on all the frame, particularly on the top (and so I don't see anything in the VD low-quarter):

http://img239.imageshack.us/img239/4144/interference05bx.th.jpg (http://img239.imageshack.us/my.php?image=interference05bx.jpg)

Looking at the spots I placed two windows, but the resulting pattern doesn't seems to match the original. The result is: nothing change.
In this case should I forgot the spots and try to reproduce the pattern I see in the original?

http://img359.imageshack.us/img359/2701/defreq00000ab.th.jpg (http://img359.imageshack.us/my.php?image=defreq00000ab.jpg)

I don't know what to do now. I tried also SeparateFields but the spots are in different places. Again nothing solves.
Help me please.

Fizick
7th September 2005, 20:57
frank10,
Yes, firstly forgot the spots and try approximately to reproduce the pattern you see in the original.
your current settings are too high. IMHO, your windows is near deinterlace artifactes now. Decrease used fx,fy values.
Then you will see nearest spot.
And always start with one window only.
Good luck! Happy defreqing :)

vcmohan
16th September 2005, 04:47
I checked the clouds image with FanFilter. It appears moire noise of high freq low intensity is present in the upper part, and low freq vertical bands left and right quarters of image. These I assume will be difficult to spot on an fft. On the image there are also horizontal streaks.
I tried the following after converting the image to YUY2 format
YUY=converttoYUY2()
VFan(yuy,0,1,"edge",6,gyplus=0,gyminus=0)
HFan(last,0,1,"edge",6,gyplus=0,gyminus=0)
Subtract(yuy,last).Levels(127,1,129,0,255)
using only one of the fan filters and both, the noise removed can be seen. There are also other problems with the image.

frank10
16th September 2005, 15:03
Thanks vcmohan: it worked with your fanfilter.

Very nice the subtract view.

I tried also these settings:

clip= loadClip...
VFan(clip,0,100000,"pass",4, gyplus=8 )

it seems better than edge because it has less hor 'shift' and blur: in this frame it is clearly visible because of the text-black (also the logo-white):

original frame with text:
http://img269.imageshack.us/img269/8281/fanfilterblacktext0zj.jpg

Could you explain more the gy plus-minus parameter?
It seems to be related to black-white point.

I added also an unsharp mask on fields and peachsmoother for noise.
At the end I have something like this:

SeparateFields ()

VFan(clip,0,100000,"pass",4, gyplus=8 )
HFan(last,0,100000,"edge",6,gyplus=0,gyminus=0)

odd=SelectOdd.UnsharpMask(strength=20, radius=3, threshold=10)
evn=SelectEven.UnsharpMask(strength=20, radius=3, threshold=10)
Interleave(evn,odd)

peachsmoother(NoiseReduction = 30, Stability = 40, Spatial = 250 )

weave()
CropBottom(8).AddBorders(0,4,0,4)

Is the filter order correct? Is Interleave necessary or not (at the end I have weave, so maybe it is redundant)?


There are also other problems with the image.

Maybe ring? or other more?

I would like to know more on this from experienced people like you because I'm learning filtering now... So any suggestions are welcome.

vcmohan
17th September 2005, 05:50
Glad that FanFilter helped you.

Could you explain more the gy plus-minus parameter?
These are thresholds used as plus or minus of the average values in the span. In one case this interval is allowed while in other its stopped. Edge tries to preserve edges, by splitting the span in 2 halves right and left and then filtering all values which are not within plus and minus of the individual halves mean values. Normally stop or pass gives a smoother or blurred image than edge. But since you used a smaller span you are not noticing it.
Maybe ring? or other more?
When I tried some stronger filter parameters I found strange color bands appear. It appears there is some problem in color as well.

As for usage of weave etc, I hope some experienced user answers you.

Fizick
17th September 2005, 22:21
please do not offtopic here :)

vcmohan
18th September 2005, 04:05
please do not offtopic here :)
Sorry for that. Since a question was asked I could not resist a reply

Poutnik
29th October 2005, 14:25
I have one very noisy TV capture with close to vertical interference.

I am going to try Fizick's script, mentioned at VaqueDenoiser doc, combined with DeFreq ( or VFan ) ....

LoadPlugin("vaguedenoiser.dll")
LoadPlugin("degrainmedian.dll")
avisource("input.avi")
aux=DeGrainMedian(mode=0, limity=7, interlaced=true)
VagueDenoiser(threshold=7, auxclip=aux, interlaced=true, wiener=true)

should I put DeFreq at the end ?

OR maybe aux=DeGrainMedian(mode=0, limity=7, interlaced=true).DeFreq(pars) ?

Poutnik
28th November 2005, 17:51
Another useless idea: Multiple 1D FFT ?

What about performing multiple 1D FFT for given limited set of either horizontal or vertical lines to calculate avg interference frequency and phase shift between lines?

Would it be possible to use it for non-GUI automatic interference remover like Defreq ?

Fizick
28th November 2005, 19:49
Of course NOT "aux=...".
Try use your first way or place defreq right after avisource.

Fizick
28th November 2005, 19:51
Multiple 1D fft I tried use for VHS jitter correction, but this plugin is not finished.

Poutnik
28th November 2005, 20:39
No time to finish or abandoned as bad idea in general ?

Fizick
28th November 2005, 22:39
Both.
results was not very good. algo must be improved. Arfefactes (curved lines).

Fizick
30th December 2005, 00:40
Use fx and fy parameters. And disable all other filters (temporary).

Ok after I get this I'll post in the DeFreq thread.

But can you please post an exact line that I insert? The fx and fy argument usage isn't clear to me. It isn't "show=fx,fy, info=fx,fy" so I'm unsure how I get the "show" and "info" lines to act on the x and y axes.

Try start with:

Defreq(fx=10, fy=10, show=1, info=true)

chipzoller
30th December 2005, 01:57
Ok I got that part, but I don't understand what you mean you say in your site:

"Firstly look to generated sample frequency stripes at the right top corner, and try make them similar to your picture interference pattern (right bottom area)."

Make the stripes similar to the picture interference pattern? I'm beginning to think this is way over my head.

EpheMeroN
25th April 2006, 19:36
I cannot get rid of these vertical lines. They start at the right and angle down towards the left. Please help. I can post sample video as well.

http://img242.imageshack.us/img242/9329/100004ts.th.jpg (http://img242.imageshack.us/my.php?image=100004ts.jpg) http://img242.imageshack.us/img242/240/200003me.th.jpg (http://img242.imageshack.us/my.php?image=200003me.jpg)

Fizick
29th April 2006, 07:30
A little update Defreq Version 0.7, April 28, 2006 - changed cleaning method: more frequencies are decreased near interference peak.
Chanded static linking of FFTW3.DLL library to dynamic loading.

saibo
20th July 2006, 13:05
A little update Defreq Version 0.7, April 28, 2006 - changed cleaning method: more frequencies are decreased near interference peak.
Chanded static linking of FFTW3.DLL library to dynamic loading.

Hi, I have a big problem. I tried your DeFreq Filter but it was not possible to eliminate the wavelike frequence erros. Is there any possibility to eliminate such errors?

http://img87.imageshack.us/img87/2633/testar0.png

Here an example:
http://rapidshare.de/files/26290105/Beispiel.m2v.html

Could it be a typical MOIREЙ effect?

martin53
8th September 2009, 21:50
Fizick,
would it be possible to expose just the forward / the inverse transformation as functions (like the left part of 'show')? That would make it possible to me to experiment with manipulations in the frequency domain - like overlaying a mask...

Fizick
11th September 2009, 19:05
martin53, sorry for late respond.
it is (almost) not possible right now.
'show' represents not raw transformation, but only real part of it, and logariphmed.
FFTW and I use complex float as transformation format.
1. You must store transformed image data somehow - well, it may be packed in any fictive format (e.g. RGB32).
2. You must provide means to manipulate this data - it is not possible in fictive format.
Try ask avisynth core developers to implement float (complex float) image format. ;)
It will not in avisynth 2.6. I already asked it. May be in myphological v3.0 :)

But It is possible to use integer storage format for DCT (not for FFT used in Defreq) with some scaling, but 8 bit is too anyway low IMO.
Try program C code to experiment.

martin53
11th September 2009, 20:27
Fizick,
a big thanks for your response!:thanks:
That's really bad news, but I kept feeling there was a problem like this.
Do you think it is possible that you multiply, or signed add respectively, a mask to the frequency domain? I am almost sure that it would be useful to subtract a small amount of the high frequency area - similar to what is done in subtle audio noise reduction in frequency domain.
And the multiplication with a mask could be an universal approach to your today maximum search and automated suppression of the peak in frequency domain, because one could just paint the suppression filter.

One more aspect: The transformation transforms something that is 'everywhere' in the 'time' or 'xy' domain to one point in the frequency domain, and vice versa. A blurred image due to camera shake contains the shake path (of the camera movement while the shutter was open) like an infinity of parallel paths in the whole image. In fact the image lacks high frequency along the axis or the path of the shake. And I wonder if this kind of information is also transformed to a certain location or localized figure in frequency domain that can be fixed. It should be like a dark area in the frequency domain. If so, FFT/CDT could provide an approach to sharpen images which suffer from this. Of course it is impossible to reconstruct all information fully - it was lost during the capture. But it might be possible to transform the ugly paths of the lit points into more standard shapes, and just leave some soft focus.

I know I can at least do some research in that direction with the help of 'show'. I'll add my results to this thread.

martin

martin53
13th September 2009, 13:16
I made an analysis script so everyone can examine the effects of simple blurring on spectral density for himself or herself.

pi = 3.1415926536
#====== USER INPUT =====

#Motion blur length (integer) [ 0 ... ]
# the value indicates the length ot the motion trail
# 0 produces an uncorrelated random noise clip
# variation changes the number of notch bands in the spectral density
blur= 7

#direction of blur in radians
# variation changes the angle of the notch bands in the spectral density
global phi= 0 #pi/20

#deltaPhi adds to the angle of the blur on its path and results in a bent motion
#values != 0 change the linear notch bands to elliptic(?) figures
global deltaPhi= 0 #1.0/blur * pi/4

#oversample factor (integer) [1 ... ] for the blur, compensates the Overlay(...) integer offset error.
#8 seems the best compromise for good correction and expense.
#no need for oversample with phi=0, phi=pi/2 etc
global oversample= 8

#clip size (integer) [32, 64, 128, 256 ... ]
#dimension of the quadratic original clip.
# 64 is fine to see the principles
dim = 64

#====== SUBFUNCTIONS =====

#mBlur performs the motion blur by recursively overlaying the semi-transparent, slightly shifted original
function mBlur(clip shifted, clip original, int i, int blurLength) {
Overlay(shifted, original, x=round(cos(phi+i*deltaPhi)*i*oversample), y=round(sin(phi+i*deltaPhi)*i*oversample), opacity=1.0/(i+1), pc_range=true)
return i >= blurLength ? last : mBlur(last, original, i+1, blurLength)
}

#====== MAIN SCRIPT =====

#create a random noise clip
BlankClip(width=dim+2*blur, height=dim+2*blur, color=$808080).AddGrain(2500)

#apply a motion blur to the clip - oversampled operation for better math precision -
oversample > 1 ? Lanczos4Resize(oversample*(dim+2*blur), oversample*(dim+2*blur)) : last
blur > 0 ? mBlur(last, last, 1, blur) : last
oversample > 1 ? Lanczos4Resize(dim+2*blur, dim+2*blur) : last

#cut off the border of the original clip where the motion blur could not be applied properly
crop(blur ,blur ,-blur ,-blur )

#make DeFreq() calculate the spectral density of the blurred noise
#and display the clip and its spectral density distribution
ConvertToYUY2()
stackhorizontal(last, crop( DeFreq(show=2), 0, 0, -dim/2, 0) )


My conclusions are
- movies with perfect quality have an even spectral density, i.e. a constant gray in "show" mode. (of course not one single picture, but the average over a complete movie)
- For real pictures with good quality, the limited bandwith makes the average of the spectral density dim to the right. Acoustically spoken, this would sound a bit dull. I verified that with some movies in place of the random noise.
- a remarkable motion blur has an affect that reminds my acoustical mind to interference with a slightly delayed echo, i.e. some frequencies are boosted because the original and the echo add with the same polarity, while the frequencies inbetween are extinguished because the echo has the inverse polarity and always adds to zero with the original.

martin

martin53
13th September 2009, 15:51
Fizick and Mohan,
I have some ambitions to enhance some of my photos and movies with spectral-based concepts.
I have photos in my archive where I could not keep the camera steady.
And when I shoot some video clips, it sometimes appears that during a pan, the frames are blurred because it is dark and the camera uses a long exposure time.

When I experimented with the script from my 1st follow-up, I was reminded of equalizers. While those equalizers (those with many sliders, or the parametrical ones which allow more precise control over fewer filters) only need to compensate a one-dimensional frequency response, the task is more complex in the two dimensional domain.

At least, beside the feature to attenuate some frequencies, all equalizers also need to amplify other frequency ranges.

:) So I kindly ask both of you: could DeFreq() and/or FFTQuiver() be developed further to allow amplification of frequency areas? As far as I understand, both are designed to kill some frequencies up to now.

The question needs to be answered: "Where to derive the filter settings from". I would like to present my thoughts here, it is not yet a perfect description for 1:1 implementation.

When working with photos, there is no chance to scroll through the frames and use DeFreq()'s show=2 averaging mode. Of course, the specific information in the image makes up a complex spectral density, and just normalizing to that must return random noise, not to a processed image.

But specific with the motion blur, there is one transformation which is neutral to the problem, i.e. could help: It should be possible to rotate the original image horizontally or vertically through the frame, and thus get a vast number of frames for analysis:

overlay(stackhorizontal(last, last), x=...)
# x = -1 ... -(width-1)

because the right and left edges usually don't tile nicely, the border should be darkened with some gradient. This is slow but it provides high quality which is needed for high resolution photos.

After that, a blurring should provide what I'd like to call the "defect mask" even from one source image. I'm still unsure if F2QMask could already use the inverse of this with some gamma change as "equalizer mask", because of the black-to-white range and the fact that F2Quiver multiplies (or convolves?) with the mask instead of dividing by (i.e. normalizing to) the mask. The proportional or inverse proportional characteristic of the multiplication is essential here!

When working with movies, any manual process and maybe even the slow approach above is impractical. But I think that it is not too complicated for a filter chain to generate the "equalizer mask" automatically on a frame-by-frame basis for DVD or HD resolutions.
Again, on a frame-by-frame basis, there is no averaging approach for obtaining the spectral density. But from all the above, we learned that the gradients in the frequency domain are extremely small, i.e. it is not neccessary at all to have a mask with edges. The mask is much more like a blurry cloud. And there is one more important fact: The very right of the frequency domain deals with hard edges of the image. It is not reasonable to correct too much there. But the more left hand areas of the frequency domain represent larger distances between pixels - this is where motion blur affects the image mostly.
In few words: it should be sufficient to blur the obtained frequency representation of a frame massively (and I really mean massively) and to restrict it to the left hand part in order to get the "equalizer mask". Again, the "equalizer mask" needed to be a point-by-point-divisor in the frequency domain.

Of course I'm also still eager to see the "globally subtract a little bit from the luma spectrum" feature in FFTQuiver() or DeFreq(). I experimented a bit with the script from the previous post and a chain of blur()'s instead of the motion blur, and it seems to me that it would be useful to have DeFreq() search for the point in frequency domain where there is the least spectral density instead of the most, and then subtract this amount from all frequencies before retransforming. It should help reduce the noise from those tiny digital camera sensors.

(to others who might come across this topic: don't forget to read the thread about the other capable FFT filter FFTQuiver from vcmohan: http://forum.doom9.org/showthread.php?t=107725

martin

Mounir
13th November 2009, 19:15
How does one use the show & info parameters?

I tried this for example Return DeFreq(fx=68,fy=-75,show=true,info=true) , but i get an error so i assume i'm doing something wrong.

Fizick
14th November 2009, 18:31
Mounir,
are your full script and "error" top secret ? ;)

fbs
25th December 2010, 09:15
I wish it wasn't dead.. because it somewhat works.. and it's the only filter I know which can do frequency removal..

ps.: I really didn't understand it's readme.. most stuff doesn't make sense