As you may know, I use FFT (polar) in two of my G’MIC commands. However, they are unrefined given how little I know about FFT. Questions to start the conversation:
1 How does one interpret FFT or FFT polar pairs in relation to the input image? What are the axes and how are the guidelines drawn?
2 How would one apply low, high or band passes in this space? What shape(s) should masks be? How would denoising work (i.e., on images degraded by Gaussian and other types of noise)?
Denoising can be done using the same principle as removing patterns in images using FFT. Unwanted parts of the FFT amplitude image are set to zero.
In the case of denoising instead of removing peaks, you want to remove low amplitude FFT pixels.
EG
-sp wall
-fftpolar
# Blurring is not essential
# but helps determine which pixels are noise
--blur[0] 2
-gt[-1] 10000 # noise threshold
-mul[0,-1]
-ifftpolar
Generally this type of processing is done on small tiles because processing the whole image this way is not good. I can’t remember exactly why.
Your (ugly ) example uses a hard threshold and denoise_haar uses a soft one. I wrote a simple command using a soft threshold and it softens low peaks as you say.
Against noisy pixels though, it removes mid-range details; i.e., neither the clipping nor the splotchy noise. (Not very clear in the example below due to the high freq noise but if you focus you should be able to see the splotching on the pencils’ coating is still present.)
The problem with removing or reducing frequencies is that edges contain such a wide range of frequencies that it is pretty much guaranteed that they are going to get degraded.
This is why I use FFT to recover details after doing an edge preserving denoise. The residual noise that the FFT step is applied to hopefully has no edges.
EDIT: I remember why tiles are needed. Typically, textures and detail have strong frequencies locally, but when averaged over the image the peaks are reduced considerably. Tiles make identifying signal easier.
Also, one thing I found is that using a median filter and then applying the FFT step to the residual noise seems to be a good way to extract details. I don’t know why using a median filter works so well.
Edit2: I also suggest experimenting on grey scale images at first.
I am asking with regard to the polar version of FFT.
– Freq increases from the centre point (zero).
– Apparently, according to Fred, the centre point represents the centre bias. Should be the average colour of the image. A quick look with G’MIC, this may not be true, or is true only after a few considerations. E.g., if the point is actually centred, or if the magnitude is normalized (edit indeed, I am able to get the colour after I do / {wh}), etc. Further investigation is required. However, it does makes sense if we are only going by the definition in the previous note.
With this in mind, I want to know what the shape of the spread is. See a, b, c and d. Which is correct? Or is it an interpolation among them? Or something completely different? Note that the grey rectangles are the image boundaries. (When we transform the source image, the fftpolar magnitude image and its imaginary counterpart adopt its dimensions.) The dot in the middle is the centre point (or the DC).
@Iain I updated my figure for clarity. Could you please elaborate on your demo and provide snapshots for those who may not have the plugin handy? Thanks.
The demo sets the one pixel (and it’s mirrored equivalent) in the fft polar magnitude image to a large value. All other pixels (except the central DC component) are 0. By doing this you can see the frequency that that pixel represents. The demo is interactive in the plugin and you can drag the point around to get a feel how the frequencies are distributed in the FFT polar image.
Here are some examples. The pixel under the white circle produces the frequency shown.