How does the DCT (Discrete Cosine Transform) help to compress sound (or any wave-like data)? According to the DCT transform there are N input values and N output values as a result. Where is the compression achieved and how?
-
This question is not directly related to programming; it is more about signal processing and Mathematics. Thus you should consider moving it to the [Signal Processing Stack Exchange](https://dsp.stackexchange.com/) or the [Mathematics Stack Exchange](https://math.stackexchange.com/). – KasparJohannes Apr 08 '19 at 18:18
3 Answers
The DCT does not compress. The size of the DCT output is the same as the size of the input signal. What the DCT does, however, is compact the energy of the signal. Roughly speaking, you end up with a small subset of big coefficients and a lot of small coefficients in the frequency domain. This situation is perfect for an entropy encoder that can remove the redundancies in the DCT output, thus providing compression.

- 564
- 4
- 11
Think about the sequence 1,2,3,4,5,.. It will not compress using LZ (zip) at all because there is zero repetition. Now encode the sequence as differences: 1,1,1,1,1,... Zip will compress it 99% now. Every algorithm detects a certain pattern well. DCT helps to encode the data into a format that is well compressible.

- 11,129
- 19
- 93
- 159

- 168,620
- 35
- 240
- 369
IMO it's an analysis of repetitions of certain values of the input (wave) presented in the form of frequencies (frequence + amplitude + repetition). For example if you have many low noise in the audio (bass) a DCT will oupout many values (=similar values) with low frequencies (i.e. think of an Equalizer-Band). This can be exploited for any compression algorithm. And also a DCT is loseless and reversible.

- 12,486
- 7
- 35
- 72
-
1Loseless? Can you please give some links on the algorithms you've written? – maximus Apr 26 '11 at 03:36
-
Maybe it's lossy but if you can round the coefficents you can compress a bit: http://en.wikipedia.org/wiki/Discrete_cosine_transform – Micromega Apr 26 '11 at 10:14
-
I tried it the DCT. Just converting to frequency domain and again to time domain. The final result was different than original one.. – maximus Apr 26 '11 at 10:47
-
Strange! Have you looked at the bottom of the page http://en.wikipedia.org/wiki/Discrete_cosine_transform? There is a DCT of a 8x8 Bitmap? – Micromega Apr 26 '11 at 10:54