0
$\begingroup$

I'm learning images processing using FFT. In my test example provided below the input pixel values are clamped 0-1 (0-255), but I do eventually want to process floating point heightfield pixel values.

The software I'm using (Houdini v18) provides forward and inverse FFT functions and as a base line I can successfully convert an image to frequency space and back.

However when I look at the 2D representation of the frequency space it looks different to any examples I've found online.

Test image:

enter image description here

This is the result of Houdini's FFT with zero frequencies at center (height offset is pixel intensity):

enter image description here

The function returns 2x "images" representing real an imaginary values.

This however is the frequency space representation I find everywhere online: enter image description here

From what I understand the radial type FFT images represent frequency between 0-2PI in u and v and the pixel value is the magnitude. And that most images are offset so 0 is centered.

Do I need to convert the real and imaginary components to frequency and magnitude and plot those? If so how?

EDIT: My end goal is to apply radial pass filters to the FFT so I just need to apply any spacial transforms to get the FFT to that state.

$\endgroup$
  • 1
    $\begingroup$ if you have FFT in complex numbers just treat it as 2D complex valued array and apply your mask on it and take iFFT, the second image as you mentioned is magnitute so it is real^2 + Imaginary^2, if you notice the first image does not have the crossing lines $\endgroup$ – MimSaad Jan 11 at 15:45
  • $\begingroup$ OK so the second image is more meant for visualization purposes and not needed to apply masks? $\endgroup$ – Geordie Jan 13 at 1:43
  • 1
    $\begingroup$ no, you can not apply mask on this and get back correct results. even more, actually this image has gone through a second process. The actual magnitude image is dark everywhere except 1 central pixel because of normalization of 2d array into a gray scale image. the above image is log10 of magnitude values $\endgroup$ – MimSaad Jan 13 at 9:36
  • $\begingroup$ @MinSaad Thanks! None of the tutorials online state this so great info. I guess it's harder to show representations of non-normalized real/imaginary values in 2D form. if you add your comments as an answer I'll mark it as correct. $\endgroup$ – Geordie Jan 14 at 20:11
  • $\begingroup$ OK thanks! I'll add $\endgroup$ – MimSaad Jan 15 at 10:05
1
$\begingroup$

The second image you find online as you mentioned is magnitude and the first image must be either real part or the imaginary part (but not both). If you calculate complex value magnitude for each point, i.e. $Mag_{i,j} = R_{i,j}^2 + I_{i,j}^2$ you get something similar to the following image.

I = imread('cameraman.tif');
F = fft2(I);
F_Centered = fftshift(F);
Mag = abs(F);
imshow(Mag);

enter image description here

but taking log10 harnesses the large magnititde of some frequency bins so for visulasation the normalization does not round them to zero.

imshow(log10(Mag),[])

enter image description here

Thus applying the filter on the above image which is only processed for visualization is not correct and inverse FFT of the values would not have much meaning.

To apply your filter you get the fft of the image, F(image) , then you need to make a same size mask image (all 1 and the frequency section you need to be removed must be zero, also remember symmetry feature of Fourier) and then apply do a element wise multiplication of fft values with this mask.

Also, I would suggest to watch this short lecture by Hoff on this subject:

https://youtu.be/02c6ohQV2TA

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.