Take the 2-minute tour ×
Signal Processing Stack Exchange is a question and answer site for practitioners of the art and science of signal, image and video processing. It's 100% free, no registration required.

So, When we take the FFT of any Composite or Single Sine Wave we get exact frequency on x-axis of the plot. The point where we get the original frequency in FFT is depend upon the Sampling Rate and the Length of the actual signal, i.e

If there is Sine wave of 100KHz and the Sampling Frequency equals to 1MHz, and If we are plotting the 10 Oscillations i.e t = 10/f then the length of the Signal would be 100. and If we plot the FFT of that signal than the First point in FFT represent 10KHz i.e 1MHz/100 = 10KHz. So the actual signal frequency will be plotted on the 10th point of FFT graph, ( 10KHz*10 = 100KHz ).

This is how we can see the Frequency of our actual signal in Frequency domain.

but what about an Image ?

Consider a binary 8x8 image ,

image = [zeros(8,4) ones(8,4)]

image =

     0     0     0     0     1     1     1     1
     0     0     0     0     1     1     1     1
     0     0     0     0     1     1     1     1
     0     0     0     0     1     1     1     1
     0     0     0     0     1     1     1     1
     0     0     0     0     1     1     1     1
     0     0     0     0     1     1     1     1
     0     0     0     0     1     1     1     1

The FFT will be calculated for each row and for each column which mean the number of samples to calculate each FFT will be 8.

I know that the FFT values have no frequencies, it has only complex amplitudes, then how does the FFT is plotted for image, How can identify the actual frequency like i did in case of Sine wave by dividing the Fs with length of Signal ?

Here is 1D FFT of the Signal,

x = [0 0 0 0 1 1 1 1]; %what are the frequencies here

    % Samples = 8

    f = fft(x)
    plot (abs(f))

enter image description here

Can somebody explain me please what are the frequencies in the FFT plot ! ??? I just need one good example that explain the graph of FFt of this signal like i did for a sine wave.

share|improve this question
3  
In general, the best way to "understand" a transform is to play with the inverse transform. Look at the inverse 2D FFT of a 2D array with a single white point. Move the point somewhere else and try again, etc. –  endolith Sep 28 '12 at 15:18
    
may be useful : dsp.stackexchange.com/questions/1637/… –  Abid Rahman K Feb 24 '13 at 8:19
add comment

2 Answers

x = [0 0 0 0 1 1 1 1] is one cycle of a (not bandlimited) square wave, with a DC offset, with a period equal to the period of the window.

....''''....''''....''''

The DC component is the FFT value at index 1 (remember that Matlab's array indexing starts at 1 instead of the more sane 0-based indexing), and to get the true value you have to divide by the number of samples (4/8 = 1/2 DC offset). The square wave is the components at index 2 and 4. Because the signal is real, the components at 6, 7, 8 are just mirror images of 4, 3, 2.

A square wave is made up of odd harmonics with 1/n amplitude, so with fundamental f1

  • frequency f1, amplitude 1
  • frequency 3*f1, amplitude 1/3
  • frequency 5*f1, amplitude 1/5
  • frequency 7*f1, amplitude 1/7
  • ...

Since your number of samples is so low, you only have room for the first 2 harmonics before you hit the Nyquist frequency. So the value at index 4 is the 3rd harmonic, which should be approximately 1/3 of the value at index 2, the first harmonic (though not exactly 1/3 because of aliasing).

If your sampling frequency is 1 MHz, and the value at index 2 represents the fundamental frequency, then you know the square wave fundamental frequency is (index-1)*fs/N = (2-1)*1MHz/8 = 125 kHz, or 1/8th of the sampling frequency, as you would expect.

Try experimenting with longer signals and it will be easier to see what's happening.

share|improve this answer
    
OK, so when i simply display this image, image = [0 0 0 0 1 1 1 1]; f = fft2(image) imshow(fftshift(f)); it will output three colors black-white-black, what are the frequencies here , and what are the points which are actually displayed in this image ? –  Sufiyan Ghori Sep 28 '12 at 22:37
1  
@Efected: With imshow, the color is proportional to the amplitude, so black is 0 and white is the maximum value. So it's the same as your plot above, except with DC in the center. For 1D, a plot is better than imshow. –  endolith Sep 28 '12 at 23:41
    
you said here that nyquist rate will be hit after 2 samples , how do you know that if there is no sampling frequency defined ? –  Sufiyan Ghori Oct 21 '12 at 16:54
    
@efected: the sampling rate is the inverse of the distance between pixels. You may not know what it is in real world units like dots per inch, but the frequencies of the fft are proportionally the same no matter what –  endolith Dec 8 '12 at 16:46
add comment

First of all, for short 1D signal it is useful to do the FFT of original signal padded with zeros. That way FFT will have higher resolution and it will be easier to identify specific frequencies. For plotting of FFT I use this simple function to generate accurate frequency axis.

function f=faxis(N,fs)
 deltaf=fs/N;
 if 2*floor(N/2)==N % N is even
 f=linspace(-fs/2,fs/2-deltaf,N);
 else % N is odd
 f=linspace(-(fs-deltaf)/2,(fs-deltaf)/2,N);
end

Example of plotting fft of signal:

x = [0 0 0 0 1 1 1 1];
f = fft(x,1024); % fft of x padded 1016 zeros

% plotting f in logarithmic scale, sampling frequency is 10000 Hz
plot(faxis(length(f),10000), 20*log10(abs(fftshift(f))));

For 2D signals (images):

image = [zeros(8,4) ones(8,4)]
f = fft2(image,1024,1024); % padding to get higher resolution in frequency
imagesc(20*log10(abs(fftshift(f)))); % ploting in logarithmic scale

For images, frequency unit is unclear (it isn'n Herz, because it's spatial frequency, it should be something like 1/meter) so it is beter to think in digital termes where maximum frequency is PI (or 1.0). Using the code above, you will open a figure where the lowest frequencies will be in the middle, and at the edges high frequencies (PI).

share|improve this answer
    
the signal 's' is collection of sample itself , isn't it ? then how did you sampled it with the sampling frequency of 10000Hz ? what i really want to know is how can i compare the fft of sine wave and the of discrete signal so that i can understand the FFt of discrete points too –  Sufiyan Ghori Sep 28 '12 at 14:53
    
I think you are you missing an end in your function. –  nobar Apr 18 at 8:05
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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