Fourier Filtering
bigwww.epfl.ch
bigwww.epfl.ch
This (generally) only applies to coherent light, so it's not something we're used to everyday, but it forms the basis of a lot of laser-based optical technologies. Combined with some other effects you can do "all-optical" signal processing [1,2], or generate create dynamic, "programmable" holograms [3]
[1] https://ieeexplore.ieee.org/document/686739
[2] https://ieeexplore.ieee.org/document/6648413
[3] https://en.wikipedia.org/wiki/Computer-generated_holography
I'm not an expert, but it's interesting.
Intro to Fourier Optics and the 4F correlator https://www.youtube.com/watch?v=wcRB3TWIAXE
Anyway, I might give a simple draw-on-canvas website a go, give me a few hours.
[0] https://www.nayuki.io/page/free-small-fft-in-multiple-langua...
[1] https://www.nayuki.io/res/free-small-fft-in-multiple-languag...
typedef struct {
double r;
double i;
} complex;
void fourier(complex * x, complex * y, int np)
{
int n, k;
for (k = 0; k < np; ++k)
{
y[k].r = y[k].i = 0;
for (n = 0; n < np; ++n)
{
double c = cos(2*M_PI*k*n/np);
double s = sin(2*M_PI*k*n/np);
y[k].r += x[n].r * c + x[n].i * s;
y[k].i += -x[n].r * s + x[n].i * c;
}
}
}
20 years ago, on a middle of the road desktop, that was fast enough that I was able to do an almost real time guitar tuner with it.I'm always struck by this thought when I see code like this. It's not a lot of code, but if I had to actually go through and internalize it, it would certainly take me a while.
Oh yeah, I definitely didn't mean to imply that it was easy code. It has that elegance that you really only see in the kind of concise code that can only be written by people who really grok the underlying system (both programming and FFT).
Notice that the direct and inverse transforms are essentially the same transformation. So you can draw on the image side and swap both images on your mind.
Maybe a DCT would be more amenable to hand-editing because it's real and has no symmetry constraints.
Or I should have a 2d image, and I draw dark/light. It reflects appropriately to get the other half, and multiplies the image (without rotating). Right now, this image looks like a donut.
I'm drawing the filter, you see. It applies the filter, and shows me:
* The source image FFT(what I drewFFT(image))
The point spread function / convolution kernel FFT(what I drew)
Edit: https://en.wikipedia.org/wiki/Hybrid_image
Are those worth a thousand words?
This demo:
1. Performs a Fourier transform on some image pixels, taking the pixel data from the "time" domain into the frequency domain. (Think of time as "how far through the image we are", and the pixel's intensity as the signal's magnitude; frequency in this case becomes a slightly abstract concept.)
2. Visualises that frequency domain in various ways - by default you're seeing the magnitude of the transformed signal
3. applies a band-pass filter to that frequency domain - i.e. only allowing signals above a certain frequency (low-cut) and below another certain frequency (high-cut), and removing the rest. Playing with this might give you an intuitive notion of what "frequency" means here.
4. applies the inverse transform, giving you a signal back in the time domain (i.e. a normally viewable image).
You can see what the effect of bandpassing the frequency-domain signal is on the end result. Thinking about it in terms of Information, if we band-pass half of the given frequency spectrum out, we're essentially throwing away half of the Information... but yet the image is still useful to a human (this is the principle of how lossy compression algorithms work, as others have noted).
[0] In the case of a "perfect" transform, in reality most algorithms are lossy
I think it is interesting because it reveals a couple things. First, that most of the content we find essential to the image is in the low-frequencies (the high-cut slider can be moved very far left before the image appears altered). Second, it demonstrates that a sharp cutoff of frequencies results in ringing (oscillations) in the image (the opposite is also true -- a sharp edge in the image will produce oscillating wavelength magnitudes in the frequency plot).
This method of removing wavelength-related content (called Fourier Filtering) is very precise in terms of cutting out specific frequencies, but the effect can be undesirable in terms of producing images that appear smooth and artifact-free (no blemishes). If you want to produce a smoother image which has certain periodic content removed, you would have to filter it out gradually in the Fourier representation (called filter "roll-off") instead of a sharp cut-off.
No, the Nyquist frequency isn’t the relevant parameter here. What is happening here is that you have a low-pass filter with a very steep cutoff (or high-pass, depending on what you are sweeping). As you sweep the cutoff, because the filter is so steep, the band suddenly disappears when the content moves from one side of the cutoff to the other.
https://pursuit.unimelb.edu.au/articles/it-s-time-to-retire-...