Computing a DCT using an FFT, Signal analysis 
Computing a DCT using an FFT, Signal analysis 
Dec 9 2005, 06:40
Post
#1


Group: Members Posts: 35 Joined: 15April 04 From: Australia Member No.: 13509 
I am trying to make sense of the output of the FFT when used to calculate a type2 DCT (DCTII). I managed to scrape together enough documentation that infomed me that, if I wanted to perform a DCTII using an FFT algorithm, then the data should be arranged to be real even symmetric, with every even indexed data element set to zero.
No problem there. In addition, the outputs are correct, but half the expected value (I can see the output needs scaling by 2 to compensate for the fact that every second sample of the input is zero). However, I am tyring to figure out how the output comes to be what it is? In particular, where the zero comes from (term 4 & term 12) [counting from 0]. Input Real : 0 x0 0 x1 0 x2 0 x3 0 x3 0 x2 0 x1 0 x0 Imag : 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Output Real : ya yb yc yd 0 yd yc yb ya yb yc yd 0 yd yc yb Imag : 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 [grumble: looks good in fixed width font, but spaces are not turning out here] In my real application, I am using a 16 point DCT, which equates to a 64 point FFT, but the above is representative. Any hints? PS: I know there are better ways of doing DCTs, but in my implementation, I only have access to an FFT routine. Cheers,Owen. 


Jun 20 2012, 15:31
Post
#2


Group: Members Posts: 1 Joined: 20June 12 Member No.: 100848 
I think the solution which is mentioned in below address in more optimized than your solution because it uses Npoint FFT to calculate Npoint DCT , but you use 2*N point FFT: http://fourier.eng.hmc.edu/e161/lectures/dct/node2.html I have checked it in MATLAB it was okey except it has forgotten to use sqrt(2) and sqrt(2*N) coeficients as you use them. clc; clear all; close all; x = [ 1, 2, 3, 4, 3, 2, 1, 5, 1, 2, 3, 4, 3, 2, 1, 5, 1, 2, 3, 4, 3, 2, 1, 5, 1, 2, 3, 4, 3, 2, 1, 5 ]; matlab_idct = idct(x); N=length(x); n = 0:N1; shift = exp( (n*pi*j) / (2*N) ); shift = shift * sqrt(2*N); shift(1) = shift(1) / sqrt(2); y = shift .* x ; y = real(ifft(y)); for i=0:((N/2)1) my_idct(2*i + 1) = y(i + 1) ; my_idct(2*i + 2) = y(N  i) ; end 


LoFi Version  Time is now: 23rd May 2015  12:17 