Skip to main content
Share Your Experience: Take the 2024 Developer Survey
10 votes
Accepted

Convolution Theorem using DCT

I did it for the DCT-I and DCT-II. At first I thought it is about circular convolution, but it is not. After desperate attempts to do it by myself I found the article: Convolution Using Discrete Sine ...
dogtype's user avatar
  • 366
7 votes
Accepted

Fast DCT implementation

Alright, after some days of staring at this problem I hope I can provide a bit of guidance to the next poor soul. Yes the scaling is different. Compared to ...
Pepijn's user avatar
  • 248
7 votes
Accepted

Understanding the DCT

Given $\{x_n, 0 \leq n \leq N - 1\}$, the conventional DFT is defined as $$X_k = \sum_n x_n e^{-j2\pi kn/N}$$ The Parseval theorem gives $$\sum_{n=0}^{N-1} |x_n|^2 = \frac{1}{N}\sum_{k=0}^{N-1} |X_k|^...
AlexTP's user avatar
  • 6,595
6 votes
Accepted

Online DFT Algorithm

(Note: the paper pointed by hotpaw2's link is actually describing in more detail the algorthm I presented here) Consider a data window length of $N$ samples from $n=0$ to $n=N-1$. Let your original ...
Fat32's user avatar
  • 28.3k
6 votes
Accepted

What is the maximum value that can result from a 2D DCT?

As suggested in the comments by Marcus Müller, you have to start from the equation of the DCT: $$ S_{uv} = \frac{1}{4} C_u C_v \sum_{y=0}^7 \sum_{x=0}^7 s_{xy} \cos\frac{(2x+1)u\pi}{16} \cos\frac{(2y+...
Costantino Grana's user avatar
6 votes
Accepted

How does DCT decorrelate images?

[EDIT] In 1991, Nasir Ahmed wrote: "How I Came Up with the Discrete Cosine Transform". Interesting to read, on how he was inspired by Chebyshev polynomials, and on how he didn't get funding,...
Laurent Duval's user avatar
5 votes

Is the DCT prone to spectral leakage like the DFT?

A window function other than rectangular can be applied to suppress sidelobes also with the discrete cosine transform (DCT). Window functions are also sometimes used together with some flavors of DCT ...
Olli Niemitalo's user avatar
4 votes

Illustration of time domain aliasing cancellation (TDAC, MDCT, lapped transform)

Edit: I have recently created two Jupyter Notebooks that illustrate this behaviour and let you play around with some actual matrices and actual signals. I find understanding MDCT easiest if we define ...
Nils Werner's user avatar
4 votes

Online DFT Algorithm

The algorithm for which you may be looking is called a "sliding DFT". For a small number of result bins, that number of "sliding Goertzel" filters can also be used. Here's one online description: ...
hotpaw2's user avatar
  • 35.4k
4 votes

Do DCT results contain phase spectrum?

A DCT is equivalent to a DFT of real data that is doubled and mirrored, thus rendering it symmetric. The DFT of any symmetric real signal has a phase of zero (its all cosines, no antisymmetric sine ...
hotpaw2's user avatar
  • 35.4k
4 votes

Do DCT results contain phase spectrum?

Not really, as the transform is real. However, one could interpret the sign as a poor man's phase, being "quantized" or restricted to values $0$ or $\pi$. In other words, $1 = 1.e^{0.\imath}$ and $-1 =...
Laurent Duval's user avatar
4 votes

Data representation of largest DCT coefficients

Your question is very accurate. Storing only the value of the largest (1 % for instance) coefficients, even from a good sparsifying transform (DCT, wavelet, else) is fool's-gold, since you (more ...
Laurent Duval's user avatar
4 votes

Data representation of largest DCT coefficients

How is bit reduction achieved practically in JPEG? First, the whole graylevel (8-bit per pixel) image is divided into adjacent blocks of 8 x 8 = 64 pixels. Then, each block is independently DCT ...
Fat32's user avatar
  • 28.3k
4 votes
Accepted

Computation of the Inverse DCT (IDCT) Using DCT Or IFFT

Have a look at Fast DCT Algorithm (PDF Version). It has both DCT and Inverse DCT using DFT (FFT). They show how to do a DCT and Inverse without the reflection trick. The standard (Less efficient ...
Royi's user avatar
  • 19.7k
4 votes
Accepted

1D DCT matlab code

You have mistyped the formula, replace this line sum = sum + y(i).*(cos((pi.*(2.*y(i)+1).*u(j))/(2*N))); with the one below, and it works fine. ...
Fat32's user avatar
  • 28.3k
3 votes
Accepted

How to get a real signal from complex ifft values?

You can plot the real and imaginary components from the FFT result separately (or the magnitude and the phase results separately, as two plots). Then you can recombine the data from the two plots ...
hotpaw2's user avatar
  • 35.4k
3 votes
Accepted

validation of a pseudo jpeg compression

If you compute a $8\times 8$ 2D-DCT, and keep the top left corner only, you are keeping a quantity that is proportional to the average of each $8\times 8$ block. This is the DC component, similar to ...
Laurent Duval's user avatar
3 votes
Accepted

MFCC extraction last step DCT or IDCT

I don't believe there is a right answer. DCT or IDCT will achieve the same purpose: decorrelating to put most energy in fewer coefficients. Whatever you do next with your MFCC (compression, feature ...
Lolo's user avatar
  • 206
3 votes

Basis functions in DCT

Because the upper left square would correspond to values of $p=0$ and $q=0$, and $cos(\alpha) = 1 $ if $\alpha=0$, so you get a constant term, that is why it is all gray. Basically as you increment $p$...
bone's user avatar
  • 1,241
3 votes

Understanding the DCT even symmetry

Just as the DFT assumes a periodic signal by construction, the DCT assumes an even signal by construction. We can think of taking a DFT of a non-periodic signal by extending it periodically, but ...
Probably's user avatar
  • 107
3 votes
Accepted

What are the cosine functions in JPEG's DCT-II table?

Those 2D cosine functions are independent of your input image. They are just "cosine waves", or the 64 basis functions that yield 64 coefficients when transforming "$8\times 8$" blocks. Given a $D$ $8\...
Laurent Duval's user avatar
3 votes

1D DCT matlab code

For clarity, I would write this DCT as: $$F(u) = \alpha(u)\sum_{i=0}^{N-1}f(i)\cos\left(\frac{\pi u}{2N}(2i+1)\right)$$ We note that, with this 1-indexing of Matlab: $$y[i+1] = f(i)\,.$$ Then I would ...
Laurent Duval's user avatar
3 votes

Solve for minimum and maximum value of dct coefficient

The max value for a DCT coefficient with this formula would be when $k_1 = 0$ and $k_2 = 0$. Using this give us the $\cos(0) = 1$ so you simply sum up the pixel values. Since the pixel values are $0-...
IanJ's user avatar
  • 244
3 votes

Is there mathematical relationship between the FFT and DCT transforms

You have some confusion in the indices, maybe the correct expression would be $$Y[k] = \sum_{n=1}^N \left[ \sum_{m=1}^N x[m] \cos\left( \frac{(2m+1)n\pi}{2N} \right) \right] e^{-\frac{j2\pi k n}{N}}$...
Bob's user avatar
  • 2,383
3 votes

DCT - Measures of energy compaction gain achieved using DCT over FFT

In Discrete-Time Signal Processing by Oppenheim, chapter 8.5, there is a quantification of mean squared error by setting coefficients to 0 for both DCT and DFT: From this, you can of course calculate ...
jojeck's user avatar
  • 11.1k
2 votes

Fast Cosine Transform via FFT

For true scientific computing, the amount of memory usage is important too. Therefore the N point FFT is more attractive to me. This is only possible due to Hermitian Symmetry of the signal. The ...
JimBamFeng's user avatar
2 votes

Could a DCT be used for an audio magnitude spectrum rather than DFT?

How about with a 50% overlap? From this question, I understand that you are thinking about performing localized, block processing, in the manner of sliding Fourier or spectrogram. Could the DCT be ...
Laurent Duval's user avatar
2 votes
Accepted

How to find first 25 coefficients of DCT in Matlab?

In JPEG compression, DCT coefficients are generally parsed not as sub-blocks, but in an order: corresponding to the entries in the top left corner This corresponds to a zigzag indexing: This can ...
Laurent Duval's user avatar
2 votes

Why discrete cosine transform may not maintain locality

First you have a misconception in your question which I suggest you to edit first: The paper https://www.microsoft.com/en-us/research/wp-content/uploads/2016/02/TASLP2339736-proof.pdf is not authored ...
Nikolay Shmyrev's user avatar
2 votes

Why discrete cosine transform may not maintain locality

In a frequency-like transformation (Fourier, discrete cosine, Walsh), one generally ends up with a sequence of coefficients that account for each frequency component over the support of the basis ...
Laurent Duval's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible