Understanding the Basics of FFT for Image Processing

In summary: Sorry, I did not know that.You could pad with zeros or wrap the image around, before multiplying by a window function. The window function removes the high frequency noise due to the edge of the image.And then place the FFT values back into the image in there correct location with respect to original indices?When you take the FT of an image, you treat the pixels as individual samples.You are computing spatial frequencies, not temporal frequencies.And what if your image is not size 2^N ? Does the program just pad with zero? but that would add noise right ?There are also FFT algorithms that factorise the pixel dimensions, then do different radix FFTs
  • #1
btb4198
572
10
if you watch this Video :
The Julia Programming Language
at time marker 28:00, You will see that Grant takes an FFT of an Image.
In order to do a FFT, you need to know the sampling rate, but what is the sampling rate of one image?
And what if your image is not size 2^N ? Does the program just pad with zero? but that would add noise right ?
He conveniently did not explain any of this, I am very disappointed in MIT Right now.
 
Technology news on Phys.org
  • #2
btb4198 said:
In order to do a FFT, you need to know the sampling rate, but what is the sampling rate of one image?
When you take the FT of an image, you treat the pixels as individual samples.
You are computing spatial frequencies, not temporal frequencies.

btb4198 said:
And what if your image is not size 2^N ? Does the program just pad with zero? but that would add noise right ?
You could pad with zeros or wrap the image around, before multiplying by a window function. The window function removes the high frequency noise due to the edge of the image.
There are also FFT algorithms that factorise the pixel dimensions, then do different radix FFTs for those factors. But they usually take longer to generate the result than an image cut down to 2n, or padded out to 2n.
 
  • Like
Likes .Scott and FactChecker
  • #3
Baluncore said:
When you take the FT of an image, you treat the pixels as individual samples.
You are computing spatial frequencies, not temporal frequencies.You could pad with zeros or wrap the image around, before multiplying by a window function. The window function removes the high frequency noise due to the edge of the image.
There are also FFT algorithms that factorise the pixel dimensions, then do different radix FFTs for those factors. But they usually take longer to generate the result than an image cut down to 2n, or padded out to 2n.

Baluncore thanks.
question, so the sampling frequency Fs would be 1hz then ?
 
  • #4
btb4198 said:
so the sampling frequency Fs would be 1hz then ?
No, one pixel. What is the image being projected on? You can use units of pixel size in mm or um or whatever the relevant spatial sampling rate is.
 
  • #5
btb4198 said:
You will see that Grant takes an FFT of an Image.
No, Grant is doing a Fourier Transform, not a Fast Fourier Transform (FFT).
 
  • #6
btb4198 said:
And what if your image is not size 2^N ?
I don't believe that any of the images were of size 2^N pixels. The image of the cat was 500 X 399 pixels.
btb4198 said:
He conveniently did not explain any of this, I am very disappointed in MIT Right now.
This was a 30+ minute lecture. You can't expect him to put in all the details in such a short timeframe.
 
  • #7
btb4198 said:
Baluncore thanks.
question, so the sampling frequency Fs would be 1hz then ?
Balucore another question,

A FFT is done on a 1D-array, like a graph or a Spectrum.
So would convert the 2-D image into a 1D-array by doing :
(this is pseudocode)
image[0 ,0] = image [0] -> image[width, height] = image[size] where size is = to width * height

and then run FFT get corresponding frequencies and then place them back into the image in there correct location with respect to original indices ?

I guess that is what Julia is doing...

Baluncore said:
You could pad with zeros or wrap the image around, before multiplying by a window function. The window function removes the high frequency noise due to the edge of the image.
When you say this, do you mean, if Size is not equate to 2^N you add image[0,0] to image [size +1] untel image.lenght == 2^N?
or did I miss understand that ?
 
  • #8
berkeman said:
No, one pixel. What is the image being projected on? You can use units of pixel size in mm or um or whatever the relevant spatial sampling rate is.
I believe Grant is just using pixels. Fs has to be in Hz right ? and 1/1 = 1Hz. I am not saying this right ?
Fs
fs = 1/T Hz
 
  • #9
btb4198 said:
Fs has to be in Hz right ?
No! Fourier transforms apply to either time domain or spatial domain samples.
 
  • #10
berkeman said:
No! Fourier transforms apply to either time domain or spatial domain samples.
Sorry, I did not know
 
  • #11
Mark44 said:
I don't believe that any of the images were of size 2^N pixels. The image of the cat was 500 X 399 pixels.

This was a 30+ minute lecture. You can't expect him to put in all the details in such a short timeframe.
Oh, I have been trying to watch all the videos in this playlist and so far they never explain this.
 
  • #12
btb4198 said:
A FFT is done on a 1D-array, like a graph or a Spectrum.
So would convert the 2-D image into a 1D-array by doing :
The 2D transform is done by, say;
Replace each row of pixels with its FFT spatial frequency coefficients.
Then replace each column of coefficients with its FFT.
You then have 2D spatial frequencies.
Multiply the 2D spatial freq image by a coefficient mask to convolve or filter the picture.
Inverse transform the columns, then the rows.
Look at the modified image.
 
  • Like
Likes pbuk

FAQ: Understanding the Basics of FFT for Image Processing

What is FFT and how does it work?

FFT stands for Fast Fourier Transform and is a mathematical algorithm used to convert a signal from its original domain (usually time or space) to a representation in the frequency domain. It works by breaking down a signal into its individual frequency components, allowing for a more detailed analysis of the signal.

How is FFT applied to images?

FFT can be applied to images by converting the image from its spatial domain (x and y coordinates) to its frequency domain (magnitude and phase components). This allows us to analyze the image in terms of its frequency content, which can provide useful information for tasks such as image filtering and compression.

What are the benefits of taking the FFT of an image?

Taking the FFT of an image can reveal information about the image that may not be apparent in the spatial domain. It can also be used for tasks such as image compression and denoising, as well as in image processing techniques such as edge detection and feature extraction.

Can you explain the steps involved in taking the FFT of an image?

The first step is to convert the image from its spatial domain to its frequency domain using the FFT algorithm. This involves breaking down the image into its individual frequency components and representing them in terms of magnitude and phase. The second step is to analyze and manipulate the frequency components to perform tasks such as filtering or compression. Finally, the image can be reconstructed in the spatial domain by using the inverse FFT.

Are there any limitations to taking the FFT of an image?

One limitation is that the FFT assumes the image is periodic, meaning it repeats infinitely in all directions. This may not be the case for all images, which can lead to artifacts in the frequency domain representation. Additionally, the FFT may not be suitable for all types of image analysis, and other techniques may be more appropriate depending on the specific task at hand.

Back
Top