1
$\begingroup$

I have managed to get the forward Fourier transform of an image to the frequency space like so:

enter image description here

But I cannot for the life of me reconstruct the original image from the inverse Fourier transform of this frequency image? Can someone give pointers, please?

According to various articles, we are supposed to be using somehow both the Real and Imaginary (or Magnitude and Phase) of the results for frequency, so I have saved both the original Real and Imaginary parts while doing the forward transform.

My question is, how can we use these Real and Imaginary parts to reconstruct the original image back using inverse Fourier transform?

Thank you.

$\endgroup$
4
  • $\begingroup$ Whatever library you have used to do the forward FFT will provide an inverse FFT as well. Look that up and read the documentation. $\endgroup$
    – Hilmar
    Dec 17, 2021 at 18:16
  • $\begingroup$ @Hilmar thanks, i am doing it from scratch this time, pixel by pixel here we go... :) $\endgroup$
    – user60606
    Dec 17, 2021 at 18:18
  • $\begingroup$ It would be helpful if you edit your question with the information that you're rolling your own. $\endgroup$
    – TimWescott
    Dec 17, 2021 at 19:20
  • $\begingroup$ how does one do a "pixel by pixel" FFT? an FFT is always an operation of vectors; complex vector of length N in, complex vector of length N out. $\endgroup$ Dec 18, 2021 at 13:12

2 Answers 2

1
$\begingroup$

The inverse FFT is almost identical to the forward one, so you can use what you already have:

  1. Transpose and take conjugate complex
  2. Apply forward 2D FFT
  3. Transpose and take conjugate complex again
  4. Divide by number of elements in the matrix (e.g. 256 for an 8x8 matrix)
$\endgroup$
3
  • $\begingroup$ @ Hilmar thanks! I am still a bit vague about what to do from here, but here's a toy example. Suppose the image is of size 4x4 as follows: [[1,2,1,2],[2,5,4,3],[6,4,3,2],[1,3,2,1]]. Could you perhaps show a simple code for calculating the complete 4x4 Fourier frequencies of these entries, then the code to reconstruct back the original numbers exactly using inverse Fourier process, please? $\endgroup$
    – user60606
    Dec 17, 2021 at 18:45
  • 1
    $\begingroup$ There would be way more code than information. $\endgroup$
    – TimWescott
    Dec 17, 2021 at 19:20
  • $\begingroup$ @James you already have the FFT code; so, instead of running $[[1,2,1,2],[\ldots$ through it, run the result throught it again (after modification as described in steps 3 and 4). You haven't explained why you can't just do that! $\endgroup$ Dec 18, 2021 at 13:14
1
$\begingroup$

A 2D rectangular FFT is just an FFT of all the columns then an FFT of all the rows (or visa-versa).

A 2D rectangular IFFT is just the IFFT of all the columns and then all of the rows.

If you have your FFT code all written, and it's written to accept complex data (which is usually a good idea), then if you start with $x(n)$ and take it's FFT, the FFT of that will be a scaled and time-reversed FFT of $x(n)$.

So if you just take the FFTs that you're generating and take their FFTs, you should get the same images back, only with the pixel values much higher and the letters rotated by 180 degrees.

Once you see that, then you can start working on your IFFT routines.

$\endgroup$
2
  • $\begingroup$ @ TimWescott thank you! I have wondered some about that, using complex input. Since original image is only real-valued, do we construct as input complex numbers with all Imaginary parts zero, like [255,0],[134,0],[23,0],... ? Then, feeding it into the DFT forward transform sum over_all_pixels += [cos(a),sin(a)] where a = - 2 Pi * (u * i / Width + v * j / Height)... Where should the real and complex part be inputed into this forward fourier function? Thanks! $\endgroup$
    – user60606
    Dec 17, 2021 at 19:34
  • 2
    $\begingroup$ @James: Yes, $a = a + j0$, and that's exactly how you express a real $a$ as a complex number. $\endgroup$
    – TimWescott
    Dec 18, 2021 at 0:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.