Author Topic: trying to understand/interpret FFT results of non 2^n x 2^n geometries  (Read 3963 times)

ruediger

  • Guest
Hi all,

I tried to visualize the remaining non-gaussian noise of a calibrated bias files using the FFT process. However, I'm not sure how to interpret the results I got when performing the FFT on the 5634x3753 file from my EOS 5D II. Only after cropping the bias image to 2048x2048 and performing the FFT again it looks as expected (see screenshot right image).
Trying the same process for comparison in ImageJ leads to an 8192x8192 result which looks reasonable, also the inverse FFT of this results leads to the original file (with the original geometry).
My basic knowledge about FFT is mainly from http://www.qsimaging.com/ccd_noise_ffts.html and http://cns-alumni.bu.edu/~slehar/fourier/fourier.html.
Also, why is PixInsight generating two resulting images? From the mentioned articles I expect only one (the magnitude image). How to interpret the phase image?

Rüdiger

Offline msmythers

  • PTeam Member
  • PixInsight Jedi
  • *****
  • Posts: 1178
    • astrobin
I think I can answer the part of why you are getting to 2 images. You are really getting 2 data sets, magnitude and phase. In the FFT conversion process to the frequency domain data is converted to real and imaginary numbers, I-Q data. Those 2 components can give you the vector, magnitude and the direction, phase. This is all my old brain remembers at this point.


Mike

ruediger

  • Guest
I understand ... so in most articles only the "power spectrum" of the FFT result is displayed and worked with. I was puzzled because ImageJ only generates one image, but after reading the documentation it clearly states that the "power spectrum" is displayed as 8 bit image for visualization only but the full FFT result is stored as a property attached to this 8 bit image.

Rüdiger

Offline Peter

  • Member
  • *
  • Posts: 57
Hi Rudiger, you got me interested in your trials in FFT and followed your link to the qsi website. Thank you for that, my questionis regarding the group of galaxies imaged on their website in an introduction to image analysis. If not already done then can the community of Pixinsight name tat galaxy right of centre the "Danish Pastry" galaxy? Just a thought..... O0

Offline Carlos Milovic

  • PTeam Member
  • PixInsight Jedi Master
  • ******
  • Posts: 2172
  • Join the dark side... we have cookies
    • http://www.astrophoto.cl
Hi Rüdiger

First things first. :)

The Fourier Transform is an operation that in its core what it does it trying to modelate your data through sine and cosine functions. The value of the FT, at a given point, is the amplitude of the sine or cosine that better fits the data (or, to be more precise, is the projection of your data to the space where sine and cosines live. To discriminate between sines and cosines the imaginary number is used. So, if you have, for example 1+0·i, then you are using just a cosine. On the other hand, a 0+1·i value tells you that this is only a sine. Mixed terms tell you that there is a mixture of a sine and a cosine, both of the same frequency.  Usually the frequency of the sines and cosines are plotted from the center of the image, increasing theyr value. Also, since negative frequencies are the same as positive ones, all the data is mirroed; the forier transform is simetrical (in the diagonal). Going back to the mixture of a sine and a cosine for a given frequency, a complex number "a+b·i" may algo be written as: "c·e^(i·phi)", using Euler's theorem. phi is the phase, and c is the magnitude. The magnitide is like the length of the vector, the sum of the square components. The phase tells you the fraction of sines and cosines the signal has. It has the same meaning as change of phase in the senosoid signal. Let's take a cosine: f(x) = cos(f*x). If you add a phase: f(x) = cos(f*x + phi), the function will start at a different place. If the phase is 90 degrees (pi/2), then the cosine is equivalent to a sine without any phase. So, the phase information gives you an idea of the placement of the signal, although is not really straigthforward to interpret. I may give you an example of this if you want, for a very simple case. Anyway, for most applications, phase information is ignored, or just never touched. What we modify or inspect is the magnitude information.


Now, about the size of the image in the fourier space. The Fourier Transform is a very expensive operation. It is proportional to N^2 (N is the total number of pixels). To make it more manegeable, a very smart procedure was designed, the Fast Fourier Transform (FFT), which is only proportional to N·log(N). This is really a lot faster, but the problem with the first (and faster) FFT is that it needed the image to be a perfect multiple of 2^n. If you have another geometry, you cannot use the FFT. So, to overcome this, images are zero padded (zeros are added outside the boundaries of the image, to make is larger) until you reach the 2^n requisite. In modern implementations of the FFT, you don't have to go to 2^n, but any integer would work just fine too (for example 5^n), although not as fast. So, going back on track, the result of this is first: you have to operate with larger images, and second: these extra pixels, padded with zeros, create an artificial boundary on the images. Images are modeled by the standard FT as a periodical signal (that's why we try to use sines and cosines). By adding those zeroes, a very sharp edge is created in the image, at every boundary. To represent a sharp edge we need a lot (all) of sines and cosines, with different frequencies. That's why a cross is created in the fourier space. There are all the senosoids needed to represent those edges (both vertical and horozontal... we do not need diagonal sinosoids).

A final though about noise inspection in the fourier space. It is only benefical if you think that you have some periodical patterns in there. These patterns may be modelled by sinosoids, so you should end with a peak (and it's mirror) in the fourier space. If you have verticall lines, you'll get some dots in the horizontal line. If the pattern is not closelly fitted by sinosids, you'll end with spreaded peaks (you'll need more sinosoids to reconstruct the original pattern). If you don't have any periodical pattern, or clear peaks in the fourier space, then most probably a noise reduction scheme in the normal image space would work way much better.


Hope this helps.


Regards,

Carlos Milovic F.
--------------------------------
PixInsight Project Developer
http://www.pixinsight.com

ruediger

  • Guest
Thanks Carlos for your very informative response, which gave me a much better understanding of FFT than I had before!

Rüdiger

Offline Juan Conejero

  • PTeam Member
  • PixInsight Jedi Grand Master
  • ********
  • Posts: 7111
    • http://pixinsight.com/
Just a note to add more precise information about PixInsight's FFT support. Current versions of PixInsight/PCL use a mixed-radix Cooley-Tukey FTT algorithm. The underlying implementation is a custom adaptation of the excellent KISS FFT library by Mark Borgerding. In PixInsight/PCL/PJSR, the FFT can be applied to vectors and matrices (and hence images) of arbitrary even dimensions. However, the transformation is much faster if applied to vectors (or matrices) of length (or number of rows/columns) factorizable as:

n = 2n2 * 3n3 * 4n4 * 5n5

where n2, n3, n4, and n5 are arbitrary positive integers, and n must be an even integer.
Juan Conejero
PixInsight Development Team
http://pixinsight.com/