Beginner DCT (Discrete Cosine Transform)

Introduction

: Discrete cosine transform for image compression and so on, and image processing is much faster than FFT, are widely used. I simply learned the next discrete cosine transform and two-dimensional, and do the next notes. Reference links here.

https://blog.csdn.net/yanceyxin/article/details/82080242
https://blog.csdn.net/ahafg/article/details/48808443

One-dimensional DCT transform

Here Insert Picture Description
Wherein, f (i) to the original signal, F (u) is the DCT transform coefficients, N being the number of points of the original signal, c (u) can be considered a compensation coefficient of the DCT transform matrix is ​​orthogonal matrix.

Two-dimensional DCT transform

Here Insert Picture Description
See the conversion range is to N-1, it is suitable for square, if not, do you need to transform filled (see paper indeed is the case, this is more important ), then it should be after the inverse transform removal to get the original reconstruction section (images, etc.).
Here Insert Picture Description
This formula is to say the height of the DCT transformation of the (viewed from the result of conversion is not symmetrical, there should be a symmetrical transformation process). (This may be in accordance with their programming in matlab using the simpler expression evaluation DCT coefficients).

matlab code

Here the code non-original, reference links:

https://blog.csdn.net/ahafg/article/details/48808443

I = [12,23,53,16; 42,16,68,45; 34,62,73,26 ; 72,15,34,28];% data block
D1 = dct (I);% matlab DCT function DCT transform
D2 of DCT2 = (the I);
A = zeros (. 4);% transformation matrix A, may be determined by the function dctmtx (n-)
for I = 0:. 3
for J = 0:. 3
IF == 0 I
A sqrt = (1/4);
the else
A = sqrt (2/4);
End
A (I +. 1, J +. 1) A = COS ((J + 0.5) PI I /. 4);
End
End
D = A
the I * a ';% DCT transform
(upper I ran out)
(hereinafter reference IDCT)
Dl = DCT2 (the I); MATLAB% DCT DCT transformation function
D2 of a =' D a; an inverse DCT transform%
after appreciated that , matlab dct in the DCT is a one-dimensional, two-dimensional and DCT2 dct, the above loop constructs for transformation matrix a is a DCT2 (dct dimensional transform), not to be confused.

Published 22 original articles · won praise 4 · Views 3126

Guess you like

Origin blog.csdn.net/weixin_43633568/article/details/103006592