Log in

View Full Version : frequency domain


trevlac
4th June 2004, 20:36
Is there a filter that will transform a frame into the frequency domain?

Arachnotron
4th June 2004, 21:31
Forgive my ignorance, but do you mean something like a FFT-IFFT combo?

trevlac
4th June 2004, 21:46
Originally posted by Arachnotron
Forgive my ignorance, but do you mean something like a FFT-IFFT combo?

Your ignorance? Quit toying with a newbie like with me! :p

I just want an FFT that then displays the pixels. Grey scale is perfect. Thought it would be a nice way to look at the frequency components. Maybe put a circular chart on top to tell me what frequencies are where.

An IFFT would be nice too.

I can't imagine someone out there does not have this. If not, will you write one for me? :D

Arachnotron
4th June 2004, 21:54
I have been looking for a filter like that for some time, but have not found anything yet (wich does not mean much)

I have been toying with the idea to tackle something like this as a first project after finishing your vdub filter course. :)

There is loads of sourcecode on the net for simple image analysis which should be easy to adapt. I fear however speed will be the killer here.

[edit] do you mean a single frame? If so, ImageJ is nice.
http://rsb.info.nih.gov/ij/

But many professional photo editing progs have similar functionality

Wilbert
4th June 2004, 23:38
Kurosu wrote code like that (at least they were talking about it when making his antiblink). Maybe you can ask him.

MfA
5th June 2004, 00:18
With a full screen digital fourier transform there is no "where" for frequencies, it has no localization in the spatial domain.

avih
5th June 2004, 00:29
Originally posted by MfA
With a full screen digital fourier transform there is no "where" for frequencies, it has no localization in the spatial domain.

i think he ment block DCT

trevlac
5th June 2004, 00:53
@MfA, avih

http://www.dai.ed.ac.uk/HIPR2/fourier.htm

Pictures on that page. Can you provide me with the proper name for what I want? I am trying to learn this stuff in my spare time. Strangely enough, I find it fun. :o

If there is a filter that makes those ... that would be fantastic.

If I babble, please point me to something to read ...

Thanks

MfA
5th June 2004, 01:38
Just curious, what do you want to do with it? It would be very hard to do much with it in script, the best you could do is use it with conditional filtering. A DFT with coefficients mapped to 8 bits is not invertible.

Fizick
5th June 2004, 01:43
I make FFT in my Depan plugin. use Ooura fft2d c-source. But only power 2 window size. And not show fft freq, but convolution only.

trevlac
5th June 2004, 03:32
@Fizick

Thank you for the tip. I actually looked at that today. Do you perhaps have source available for Depan? I was hoping to not have to code to much. But maybe the best way to learn.

@MfA,

I'm trying to learn.

There may not be any practical purpose for such a filter. I am interested in gaining a deeper understanding of filtering. A 'view' of the frequency domain would probably help me better put the pieces together.

For example, as I've been learning about color, I found a vector scope helpful.


Maybe this is too specialized and specific to have been of interest to people in the past. As you can see from my link, (as far as I understand), they do a FFT seting the DC at the origin, then normalize the coefficients to a 256 scale.

I was particularly interested in the example where they mask at a given radius and then take the inverse FT.

I did check for Kurosu's avs stuff. His AVS page is 'closed'. :(

JuanC
5th June 2004, 07:40
Originally posted by trevlac
Is there a filter that will transform a frame into the frequency domain? You made me remember a couple of very interesting old threads:
DCT filter by Tom Barry !!! (http://forum.doom9.org/showthread.php?s=&threadid=38539&perpage=20&highlight=frequency%20domain&pagenumber=1)
And this one (http://forum.doom9.org/showthread.php?s=&threadid=42932&highlight=frequency+domain)

Arachnotron
5th June 2004, 09:11
I was particularly interested in the example where they mask at a given radius and then take the inverse FT.

I was thinking something like that would make a great interference filter. And maybe de-blocking?

[edit] the link I posted has a source, but in java. I do remember there being one that did one for luma and chroma separately for an nmp image, but I cannot find the link again. :(

Fizick
5th June 2004, 10:45
Do you perhaps have source available for Depan? I was hoping to not have to code to much. But maybe the best way to learn.


No, my source quite dirty for learning.
For non-power 2 width and height, you may try fftw library (but is more complicate).

However, i think, that with fft we may make some spatial smoothing filter.

T.Barry DCT filter is not global, but have many small windows with size only 8x8 (or may be 16x16).

Arachnotron
5th June 2004, 11:05
This link gives a nice overview of available FFT code:

http://www.fftw.org/benchfft/ffts.html

(on second thought, this is probably what Fizick was talking about)

There is also some stuff here in the GNU scientific library

http://www.gnu.org/software/gsl/manual/gsl-ref_toc.html

and last, maybe this is of some use:

http://www.robertnz.net/nm_intro.htm

trevlac
5th June 2004, 12:16
I guess we'll have to make one. :)

An interesting note: the math_shared.h file in the avs source seems to contain the same code as is available at http://momonga.t.u-tokyo.ac.jp/~ooura/fft.html , which is I believe the code Fizick is talking about. It seems to be used in the audio resamplers.

Maybe someone could outline the general process. I'm sure power of 2 would be ok. The picture could be clipped externally.

Thanks

Fizick
5th June 2004, 16:11
May be i can help with somewhats...
(This thread begin to belong to AviSynth development...) ;)

MfA
5th June 2004, 19:01
A FFT filter isnt very usefull until avisynth-3.0 comes around and you can pass on floating-point results.

As far as linear filtering is concerned, such as a smoother, there is nothing you can do in the fourier domain you cant do in the spatial domain ... for very large filters using FFT-multiplication-iFFT can be faster, but that is it. Generally nonlinear filters can get better results than linear ones, but the lack of localization makes using them in the fourier domain unrealistic.

kassandro
7th June 2004, 15:42
I wonder, why you always call the Fourier transform of a signal with only 8 discret points FFT. The Fast Fourier Transform is an efficient computation technique for signals with many discret points. Consequently, the actual implemenatations of the DCT for 8x8 blocks concentrate more on efficent use of cpu internals especially SSE than on the basic FFT technique.

MfA
7th June 2004, 19:13
DCT isnt an optimized implementation of the 8 point FFT, their basis functions are somewhat related ... but in the end they are two completely different transforms.

What is under discussion here is full frame 2D FFTs.

d'Oursse
8th June 2004, 08:50
Originally posted by MfA
DCT isnt an optimized implementation of the 8 point FFT, their basis functions are somewhat related ... but in the end they are two completely different transforms.
actually, dct is the real part of the dft. The way you achieve the fast dct is the same than the fft (butterfly method)

kassandro
8th June 2004, 15:37
Originally posted by d'Oursse
actually, dct is the real part of the dft.
This is true. The DCT is the real part of the DFT in the same way as the cosine is the real part of the complex exponential function. In fact, the idea can only be seen from the Fourier Transform, while for the cosine transform the idea is hidden behind trigonometric formulas.

The way you achieve the fast dct is the same than the fft (butterfly method)
You can't really speak of a fast DCT, because the basic FFT step is used only once to pass from 8 to 4 points. These 4 points can then be handled in one stroke using SSE. In general, the FFT reduces the problem from 2^n points to 2^(n-1), then to 2^(n-2) etc. Thus only for large n the savings are significant.

MfA
8th June 2004, 19:30
DCT is equivalent to the real-even-DFT, but that is not the same thing as the real part of the DFT transform.

Wilbert
8th June 2004, 20:03
The DFT of f_k at n is given by

Fn = sum_(k=0)^(N-1) fk * exp(-2*pi*i*n*k/N)

The real part of Fn is given by

Re(Fn) = sum_(k=0)^(N-1) fk * cos(2*pi*i*n*k/N)

which is precisely the DCT.

MfA
8th June 2004, 20:36
This (http://en.wikipedia.org/wiki/Discrete_cosine_transform#DCT-II) is the DCT.

Most important distuingishing feature is that the period increases with steps of pi/N, not 2*pi/N ... the DFT is already a critically sampled transform, 1 coefficient per sample, if you have any less coefficients than that you end up with an aliased/non-invertible transform.

Fizick
23rd September 2004, 21:49
Is anybody interested in FFT-based TV interference remover filter?
I almost finished simple beta version.

Wilbert
23rd September 2004, 22:40
That's one of the things missing in the analog capture guide. So, i'm always interested! I don't have test clips though.

Mug Funky
26th September 2004, 16:49
@ fizick: yes yes yes yes yes... i'm very interested in an FFT based interference killer :)

would it also work on stuff like dot crawl and other composite related artefacts?

could it work on rainbows? these appear to be simple aliasing in the chroma, and as i understand it once aliasing is there it's rather difficult to distinguish from actual signal, but any new filtering methods will help a lot in our war on artefacts :)

Fizick
26th September 2004, 20:31
O.K., two famous members are interested (+ me) :)

Get it for test!
http://forum.doom9.org/showthread.php?s=&threadid=82978