470 likes | 644 Views
DREAM. IDEA. PLAN. IMPLEMENTATION. Introduction to Image Processing. Present to: Amirkabir University of Technology (Tehran Polytechnic) & Semnan University. Dr. Kourosh Kiani Email: kkiani2004@yahoo.com Email: Kourosh.kiani@aut.ac.ir Email : Kourosh.kiani@semnan.ac.ir
E N D
DREAM IDEA PLAN IMPLEMENTATION
Introduction to Image Processing Present to:Amirkabir University of Technology (Tehran Polytechnic) & Semnan University Dr. Kourosh Kiani Email: kkiani2004@yahoo.com Email: Kourosh.kiani@aut.ac.ir Email: Kourosh.kiani@semnan.ac.ir Web: www.kouroshkiani.com
Lecture 09 Discrete Fourier Transform (DFT) of 1D signal
Discrete Time Periodic Signals Definition: A discrete time signal x[n] is periodic with period N if and only if for all n . Meaning: a periodic signal keeps repeating itself forever!
Example: a Sinusoid Consider the Sinusoid: It is periodic with period since for all n.
General Periodic Sinusoid Consider a Sinusoid of the form: with k, N integers. It is periodic with period N since for all n.
Example of Periodic Sinusoid Consider the sinusoid: We can write it as: It is periodic with period since for all n.
Periodic Complex Exponentials Consider a Complex Exponential of the form: It is periodic with period N since for all n.
Example of a Periodic Complex Exponential Consider the Complex Exponential: We can write it as and it is periodic with period N = 20.
Reference Frames Goal: We want to write all discrete time periodic signals in terms of a common set of “reference signals”. • It is like the problem of representing a vector in a reference frame defined by • an origin “0” • reference vectors Reference Frame
Reference Frames in the Plane and in Space For example in the plane we need two reference vectors Reference Frame … while in space we need three reference vectors Reference Frame
A Reference Frame in the Plane If the reference vectors have unit length and they are perpendicular (orthogonal)to each other, then it is very simple: Where projection of along projection of along The plane is a 2 dimensional space.
A Reference Frame in the Space If the reference vectors have unit length and they are perpendicular (orthogonal)to each other, then it is very simple: Where projection of along projection of along projection of along The “space” is a 3 dimensional space.
N E Example: where am I ? Point “x” is 300m East and 200m North of point “0”.
Reference Frames for Signals We want to expand a generic signal into the sum of reference signals. The reference signals can be, for example, sinusoids or complex exponentials reference signals
Back to Periodic Signals A periodic signal x[n] with period N can be expanded in terms of N complex exponentials as
A Simple Example Take the periodic signal x[n] shown below: Notice that it is periodic with period N=2. Then the reference signals are We can easily verify that (try to believe!): for all n.
Another Simple Example Take another periodic signal x[n] with the same period (N=2): Then the reference signals are the same We can easily verify that (again try to believe!): for all n. Same reference signals, just different coefficients
Orthogonal Reference Signals Notice that, given any N, the reference signals are all orthogonal to each other, in the sense Since by the geometric sum
… apply it to the signal representation … and we can compute the coefficients. Call then
Discrete Fourier Series Given a periodic signal x[n] with period N we define the Discrete Fourier Series (DFS) as Since x[n] is periodic, we can sum over any period. The general definition of Discrete Fourier Series (DFS) is for any
Inverse Discrete Fourier Series The inverse operation is called Inverse Discrete Fourier Series (IDFS), defined as
Revisit the Simple Example Recall the periodic signal x[n] shown below, with period N=2: Then Therefore we can write the sequence as
Example of Discrete Fourier Series Consider this periodic signal The period is N=10. We compute the Discrete Fourier Series
Example of DFS Compute the DFS of the periodic signal Compute a few values of the sequence and we see the period is N=2. Then which yields
Signals of Finite Length All signals we collect in experiments have finite length Example: we have 30ms of data sampled at 20kHz (ie 20,000 samples/sec). Then we have
Series Expansion of Finite Data We want to determine a series expansion of a data set of length N. Very easy: just look at the data as one period of a periodic sequence with period N and use the DFS:
Discrete Fourier Transform (DFT) Given a finite interval of a data set of length N, we define the Discrete Fourier Transform (DFT) with the same expression as the Discrete Fourier Series (DFS): And its inverse
Signals of Finite Length All signals we collect in experiments have finite length in time Example: we have 30ms of data sampled at 20kHz (ie 20,000 samples/sec). Then we have
Series Expansion of Finite Data We want to determine a series expansion of a data set of length N. Very easy: just look at the data as one period of a periodic sequence with period N and use the DFS:
Discrete Fourier Transform (DFT) Given a finite of a data set of length N we define the Discrete Fourier Transform (DFT) with the same expression as the Discrete Fourier Series (DFS): and its inverse
Example of Discrete Fourier Transform Consider this signal The length is N=10. We compute the Discrete Fourier Transform
Fs = 1000; % Sampling frequency T = 1/Fs; % Sample time L = 1000; % Length of signal t = (0:L-1)*T; % Time vector % Sum of a 50 Hz sinusoid and a 120 Hz sinusoid x = 0.7*sin(2*pi*50*t) + sin(2*pi*120*t); y = x + 2*randn(size(t)); % Sinusoids plus noise figure (1); plot(Fs*t(1:50),y(1:50)) title('Signal Corrupted with Zero-Mean Random Noise') xlabel('time (milliseconds)')
NFFT = 2^nextpow2(L); % Next power of 2 from length of y Y = fft(y,NFFT)/L; f = Fs/2*linspace(0,1,NFFT/2+1); figure (2); % Plot single-sided amplitude spectrum. plot(f,2*abs(Y(1:NFFT/2+1))) title('Single-Sided Amplitude Spectrum of y(t)') xlabel('Frequency (Hz)') ylabel('|Y(f)|')
Relation Between Dx and Du For a signal f(x) withMpoints, let spatial resolution Dx be space between samples in f(x) and let frequency resolutionDu be space between frequencies components in F(u), we have Example: for a signal f(x) with sampling period 0.5 sec, 100 point, we will get frequency resolution equal to This means that in F(u) we can distinguish 2 frequencies that are apart by 0.02 Hertz or more.
m = 4; n = 2^m-1; x = gf(randi([0 2^m-1],n,1),m); % Random vector y = fft(x); % Transform of x z = ifft(y); % Inverse transform of y ck = isequal(z,x) % Check that ifft(fft(x)) recovers x. [x z]= 5 5 2 2 3 3 0 0 14 14 12 12 5 5 13 13 12 12 9 9 6 6 5 5 1 1 5 5 8 8
Example in Matlab >> a=[1 2 3 4 5 6] a = 1 2 3 4 5 6 >> b=fft(a') b= 21.0000 -3.0000 + 5.1962i -3.0000 + 1.7321i -3.0000 -3.0000 - 1.7321i -3.0000 - 5.1962i >> c=ifft(b); >> a=c' a = 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000
Periodicity of 1-D DFT From DFT: -N 2N N 0 We display only in this range DFT repeats itself every N points (Period = N) but we usually display it for n = 0 ,…, N-1
Conventional Display for 1-D DFT f(x) DFT N-1 N-1 0 0 Time Domain Signal High frequency area Low frequency area The graph F(u) is not easy to understand !
Conventional Display for DFT : FFT Shift FFT Shift: Shift center of the graph F(u) to 0to get better Display which is easier to understand. N-1 0 High frequency area Low frequency area -N/2 N/2-1 0
y=rand(1024,1); z=fft(y) subplot(2,1,1) plot(abs(z)) title('FFT') w=fftshift(z) subplot(2,1,2) plot(abs(w)) title('FFTHIFT')