Questions tagged [dct]

Discrete Cosine Transform (DCT).

A discrete cosine transform (DCT) expresses a sequence of finitely many data points in terms of a sum of cosine functions oscillating at different frequencies. DCT's are important to numerous applications in science and engineering, from lossy compression of audio (e.g. MP3) and images (e.g. JPEG) (where small high-frequency components can be discarded), to spectral methods for the numerical solution of partial differential equations.

More information on Wikipedia: Discrete cosine transform .

277 questions
21
votes
2 answers

How do I apply a DCT to an image in Python?

I want to apply a Discrete Cosine Transform (as well as the inverse) to an image in Python and I'm wondering what is the best way to do it and how. I've looked at PIL and OpenCV but I still don't understand how to use it.
jmnwong
  • 1,577
  • 6
  • 22
  • 33
18
votes
2 answers

Extracting DCT coefficients from encoded images and video

Is there a way to easily extract the DCT coefficients (and quantization parameters) from encoded images and video? Any decoder software must be using them to decode block-DCT encoded images and video. So I'm pretty sure the decoder knows what they…
mpenkov
  • 21,621
  • 10
  • 84
  • 126
17
votes
6 answers

Video Compression: What is discrete cosine transform?

I've implemented an image/video transformation technique called discrete cosine transform. This technique is used in MPEG video encoding. I based my algorithm on the ideas presented at the following…
Justin Tanner
  • 14,062
  • 17
  • 82
  • 103
15
votes
4 answers

why DCT transform is preferred over other transforms in video/image compression

I went through how DCT (discrete cosine transform) is used in image and video compression standards. But why DCT only is preferred over other transforms like dft or dst?
mrsatish
  • 429
  • 2
  • 7
  • 15
14
votes
2 answers

Is there an equivalent of the matlab 'idealfilter' for Python in Scipy (or other libraries)?

I am looking for an equivalent of the time series idealfilter that is implemented in Matlab, for Python. My goal is to implement an ideal filter using Discrete Cosine Transform as is used in the Eulerian Video Magnification paper in Python in order…
Daniel Castro
  • 448
  • 1
  • 3
  • 10
13
votes
1 answer

What is the "Law of the Eight"?

While studying this document on the Evolution of JPEG, i came across "The law of the eight" in Section 7.3 of the above document. Despite the introduction of other block sizes from 1 to 16 with the SmartScale extension, beyond the fixed size 8 in…
TheCodeArtist
  • 21,479
  • 4
  • 69
  • 130
10
votes
1 answer

In scipy why doesn't idct(dct(a)) equal to a?

I am trying to implement JPEG compression using python. When I tried to apply the DCT, quantization, IDCT process for a tiff image, I found something strange for scipy.fftpack.dct/idct. Since there is only 1D dct/idct within scipy package, I was…
yc2986
  • 1,101
  • 3
  • 20
  • 23
9
votes
3 answers

Discrete Cosine Transform DCT implementation C

Im trying to implement a forward and inverse Discrete Cosine Transform (DCT) in C. The code is to transorm a single input block of pixels to the transformation matrix via the dct() function and then back to the original pixel values via the idct()…
user915071
  • 175
  • 1
  • 1
  • 6
9
votes
3 answers

Why JPEG compression processes image by 8x8 blocks?

Why JPEG compression processes image by 8x8 blocks instead of applying Discrete Cosine Transform to the whole image?
rcp
  • 111
  • 1
  • 2
  • 3
8
votes
2 answers

Use Python's Scipy DCT-II to do 2D or ND DCT

I would like to use scipy's DCT-II since it is already coded and fast. Looking at the doc, it seems it is the 1D implementation. Is it possible to use it in such a way to use it as a 3D implementation? I'm not sure about the math. Are the 2D and 3D…
macrocosme
  • 473
  • 7
  • 24
8
votes
3 answers

How to perform a *Fast* DCT (Discrete Cosine Transform) in R?

Using Rprof revealed the dct in the dtt package to be the main offender in a piece of R code that was running quite slowly. Swapping it out for fft in the stats package (which is not the same transformation, but should take the same time to compute)…
user334911
7
votes
2 answers

Fast DCT transformation

Standard equation for generating DCT coefficients in JPEG compression process is DCT formula given by: I have red that this implementation is expensive (slow), and there is much faster way. Is there explicit formula for this faster way of…
MrD
  • 2,423
  • 3
  • 33
  • 57
7
votes
1 answer

Problems with DCT and IDCT algorithm in java

Here I have my DCT algorithm class with "applyDCT" and "applyIDCT" methods. Technically after doing a forward DCT (discrete cosine transform) on a 2x2 table of random integers between 0 and 255, and then immediately doing a reverse DCT on these…
Jean-François Beaulieu
  • 4,305
  • 22
  • 74
  • 107
6
votes
1 answer

I am looking for a simple algorithm for fast DCT and IDCT of matrix [NxM]

I am looking for a simple algorithm to perform fast DCT (type 2) of a matrix of any size [NxM], and also an algorithm for the inverse transformation IDCT (also called DCT type 3). I need a DCT-2D algorithm, but even a DCT-1D algorithm is good…
5
votes
2 answers

Looking for 8x8 (or nxn) Discrete Cosine Transform (DCT)/IDCT Pseudo-Code

I've been searching Google for a while now to find pseudo-code of a decently efficient 8x8 (or nxn) DCT algorithm, and I can't find anything! I implemented the naive approach, and it took far too long to execute. If you could post some pseudo-code…
user904963
  • 1,520
  • 2
  • 15
  • 33
1
2 3
18 19