DSPRelated.com
Forums

How zero padding affects DCT of a sequence?

Started by AB58 2 months ago5 replieslatest reply 2 months ago124 views

Post deleted by author

[ - ]
Reply by kazSeptember 26, 2024

If you have matlab you can check that directly. May be Octave also support DCT.

I don't know the answer but can play in Matalb: 

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

x = randn(1,500)+j*randn(1,500);

y = [dct(x) zeros(1,70)];

td = idct(y);

figure;

plot(abs(fft(x)));

hold

plot(abs(fft(td)),'g--')

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

it seems positive frequencies are somehow recovered but the negative looks weird. I leave the conclusion to you.

screenshot 2024-09-26 175613_72374.png


if you replace dct/idct with fft/ifft you recover your signal

[ - ]
Reply by AB58September 26, 2024

I did do it in MATLAB. It seems both for FFT & DCT the final output somehow represents the original input x. For example, for FFT, the final output td has the scaled version of original input x occurring at a regular interval. But I am not sure how can I explain it mathematically.

[ - ]
Reply by kazSeptember 26, 2024

As I see it the dct plus zeros followed by idct leads to shift of negative bins by the number of zeros with minor scaling issues.

fft + zeros followed by ifft keeps bins as the original.

x = randn(1,500)+j*randn(1,500);

y = [dct(x) zeros(1,70)];

td = idct(y);

figure;

plot(abs(fft(x)),'*-');

hold

td = fft(td);

td = [td(1:250) td(321:end)];

plot(abs((td))*63/67,'g*--')

screenshot 2024-09-26 194838_52801.png

[ - ]
Reply by AB58September 26, 2024

How do you differentiate the positive and negative frequencies from the plot? The plot in the R.H.S represents the negative frequency?

[ - ]
Reply by kazSeptember 26, 2024

for n = 500 as my example:

bin 1 is dc

bins 2:250 are positive frequencies

bins 251:500 are negative frequencies