EEEB 0765 Digital Signal Processing for Embedded Systems
EEEB 0765 Digital Signal Processing for Embedded Systems 3 DSP Transforms: FFT and DCT Assoc. Prof. Dr. Peerapol Yuvapoositanon Dept. of Electronic Engineering CESd. SP EEEB 0765 DSP fort Embedded Systems http: //embedsigproc. wordpress. com/eeeb 0765 Assoc. Prof. Dr. P. Yuvapoositanon DSPEB-1
Outline • Simulink for Real-time Estimation • FFT and Short-Time FFT (STFFT) • Discrete Cosine Transform (DCT) CESd. SP EEEB 0765 DSP fort Embedded Systems http: //embedsigproc. wordpress. com/eeeb 0765 Assoc. Prof. Dr. P. Yuvapoositanon DSPEB-2
FFT • From • Sometimes, we prefer EEEB 0765 DSP fort Embedded Systems http: //embedsigproc. wordpress. com/eeeb 0765 Assoc. Prof. Dr. P. Yuvapoositanon DSPEB-3
Embedded FFT • FFT is embedded in many instruments: Scope, Spectrum Analyzer. • In Simulink, we can use Spectrum Scope in Signal Processing Blockset. EEEB 0765 DSP fort Embedded Systems http: //embedsigproc. wordpress. com/eeeb 0765 Assoc. Prof. Dr. P. Yuvapoositanon DSPEB-4
Embedded FFT ex_fft_tut. slx EEEB 0765 DSP fort Embedded Systems http: //embedsigproc. wordpress. com/eeeb 0765 Assoc. Prof. Dr. P. Yuvapoositanon DSPEB-5
Filters Analysis with FDATOOL and FFT • Testing a filter sweeping frequency with FDATOOL. • FFT block can interact with FDATOOL. EEEB 0765 DSP fort Embedded Systems http: //embedsigproc. wordpress. com/eeeb 0765 Assoc. Prof. Dr. P. Yuvapoositanon DSPEB-6
Filters Analysis with FDATOOL and FFT doc_vectorscope_tut_mod. mdl EEEB 0765 DSP fort Embedded Systems http: //embedsigproc. wordpress. com/eeeb 0765 Assoc. Prof. Dr. P. Yuvapoositanon DSPEB-7
Short-time FFT (STFFT) • The data to be transformed could be broken up into chunks or frames. EEEB 0765 DSP fort Embedded Systems http: //embedsigproc. wordpress. com/eeeb 0765 Assoc. Prof. Dr. P. Yuvapoositanon DSPEB-8
Short-time FFT (STFFT) • W(n) is a window function EEEB 0765 DSP fort Embedded Systems http: //embedsigproc. wordpress. com/eeeb 0765 Assoc. Prof. Dr. P. Yuvapoositanon DSPEB-9
Uncertainty Principle • Comparison of STFT resolution. The left fig. has better time resolution, and the right one has better frequency resolution. http: //en. wikipedia. org/wiki/Short-time_Fourier_transform EEEB 0765 DSP fort Embedded Systems http: //embedsigproc. wordpress. com/eeeb 0765 Assoc. Prof. Dr. P. Yuvapoositanon DSPEB-10
Comparison: Periodogram v. s STFFT dspstfft. mdl EEEB 0765 DSP fort Embedded Systems http: //embedsigproc. wordpress. com/eeeb 0765 Assoc. Prof. Dr. P. Yuvapoositanon DSPEB-11
Comparison: Periodogram v. s STFFT EEEB 0765 DSP fort Embedded Systems http: //embedsigproc. wordpress. com/eeeb 0765 Assoc. Prof. Dr. P. Yuvapoositanon DSPEB-12
Discrete Cosine Transform EEEB 0765 DSP fort Embedded Systems http: //embedsigproc. wordpress. com/eeeb 0765 Assoc. Prof. Dr. P. Yuvapoositanon DSPEB-13
• x = (1: 100) + 50*cos((1: 100)*2*pi/40); EEEB 0765 DSP fort Embedded Systems http: //embedsigproc. wordpress. com/eeeb 0765 Assoc. Prof. Dr. P. Yuvapoositanon DSPEB-14
Three Largest DCT Coeff • X = dct(x); plot(X) EEEB 0765 DSP fort Embedded Systems http: //embedsigproc. wordpress. com/eeeb 0765 Assoc. Prof. Dr. P. Yuvapoositanon DSPEB-15
99 % of energy is in a few (3) coefficients • [XX, ind] = sort(abs(X)); ind = fliplr(ind); • i = 1; • while (norm([X(ind(1: i)) zeros(1, 100 i)])/norm(X)<. 99) • i = i + 1; • end i=3 EEEB 0765 DSP fort Embedded Systems http: //embedsigproc. wordpress. com/eeeb 0765 Assoc. Prof. Dr. P. Yuvapoositanon DSPEB-16
Idct(X) No. of Coefficients = 100 testdct. m EEEB 0765 DSP fort Embedded Systems http: //embedsigproc. wordpress. com/eeeb 0765 Assoc. Prof. Dr. P. Yuvapoositanon DSPEB-17
No. of Coefficients = 3 EEEB 0765 DSP fort Embedded Systems http: //embedsigproc. wordpress. com/eeeb 0765 Assoc. Prof. Dr. P. Yuvapoositanon DSPEB-18
No. of Coefficients = 5 EEEB 0765 DSP fort Embedded Systems http: //embedsigproc. wordpress. com/eeeb 0765 Assoc. Prof. Dr. P. Yuvapoositanon DSPEB-19
No. of Coefficients = 6 EEEB 0765 DSP fort Embedded Systems http: //embedsigproc. wordpress. com/eeeb 0765 Assoc. Prof. Dr. P. Yuvapoositanon DSPEB-20
No. of Coefficients = 7 EEEB 0765 DSP fort Embedded Systems http: //embedsigproc. wordpress. com/eeeb 0765 Assoc. Prof. Dr. P. Yuvapoositanon DSPEB-21
No. of Coefficients = 8 EEEB 0765 DSP fort Embedded Systems http: //embedsigproc. wordpress. com/eeeb 0765 Assoc. Prof. Dr. P. Yuvapoositanon DSPEB-22
No. of Coefficients = 9 EEEB 0765 DSP fort Embedded Systems http: //embedsigproc. wordpress. com/eeeb 0765 Assoc. Prof. Dr. P. Yuvapoositanon DSPEB-23
2 D-DCT CESd. SP EEEB 0765 DSP fort Embedded Systems http: //embedsigproc. wordpress. com/eeeb 0765 Assoc. Prof. Dr. P. Yuvapoositanon DSPEB-24
2 D DCT Demo • • A = im 2 double(imread('rice. png')); D = dctmtx(size(A, 1)); dct = D*A*D'; figure; imshow(dct) CESd. SP EEEB 0765 DSP fort Embedded Systems http: //embedsigproc. wordpress. com/eeeb 0765 Assoc. Prof. Dr. P. Yuvapoositanon DSPEB-25
Image to be transformed Rice. png CESd. SP EEEB 0765 DSP fort Embedded Systems http: //embedsigproc. wordpress. com/eeeb 0765 Assoc. Prof. Dr. P. Yuvapoositanon DSPEB-26
A = im 2 double(imread('rice. png')); D = dctmtx(size(A, 1)); dct = D*A*D'; figure; imshow(dct) EEEB 0765 DSP fort Embedded Systems http: //embedsigproc. wordpress. com/eeeb 0765 Assoc. Prof. Dr. P. Yuvapoositanon DSPEB-27
DCT Coefficients Large values Small values CESd. SP EEEB 0765 DSP fort Embedded Systems http: //embedsigproc. wordpress. com/eeeb 0765 Assoc. Prof. Dr. P. Yuvapoositanon DSPEB-28
Reconstruction • A=D'*dct*D; • imshow(A) EEEB 0765 DSP fort Embedded Systems http: //embedsigproc. wordpress. com/eeeb 0765 Assoc. Prof. Dr. P. Yuvapoositanon DSPEB-29
Now Construct the reduced >> rddct =zeros(size(A)); EEEB 0765 DSP fort Embedded Systems http: //embedsigproc. wordpress. com/eeeb 0765 Assoc. Prof. Dr. P. Yuvapoositanon DSPEB-30
= 30 x 30 >> rddct(1: 30, 1: 30)=dct(1: 30, 1: 30) ; >> Ard = D'*rddct*D; >> imshow(Ard) EEEB 0765 DSP fort Embedded Systems http: //embedsigproc. wordpress. com/eeeb 0765 Assoc. Prof. Dr. P. Yuvapoositanon DSPEB-31
= 50 x 50 >> rddct(1: 50, 1: 50)=dct(1: 50, 1: 50) ; >> Ard = D'*rddct*D; >> imshow(Ard) EEEB 0765 DSP fort Embedded Systems http: //embedsigproc. wordpress. com/eeeb 0765 Assoc. Prof. Dr. P. Yuvapoositanon DSPEB-32
= 90 x 90 >> rddct(1: 90, 1: 90)=dct(1: 90, 1: 90) ; >> Ard = D'*rddct*D; >> imshow(Ard) EEEB 0765 DSP fort Embedded Systems http: //embedsigproc. wordpress. com/eeeb 0765 Assoc. Prof. Dr. P. Yuvapoositanon DSPEB-33
JPEG Compression Standard EEEB 0765 DSP fort Embedded Systems http: //embedsigproc. wordpress. com/eeeb 0765 Assoc. Prof. Dr. P. Yuvapoositanon DSPEB-34
Demo on JPEG Coding >> I = imread('cameraman. tif'); block 2 D_dct_demo. mdl EEEB 0765 DSP fort Embedded Systems http: //embedsigproc. wordpress. com/eeeb 0765 Assoc. Prof. Dr. P. Yuvapoositanon DSPEB-35
- Slides: 35