Top Banner

of 12

2-D Discrete Cosine Transforms

Apr 07, 2018

Download

Documents

lakshmipo
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
  • 8/6/2019 2-D Discrete Cosine Transforms

    1/12

    2-D Discrete cosine transforms

    One disadvantage of the DFT for some applications is that the transform is complex valued, even for realdata. A related transform, the discrete cosine transform (DCT), does not have this problem. The DCT is aseparate transform and not the real part of the DFT. It is widely used in image and video compressionapplications, e.g., JPEG and MPEG. It is also possible to use DCT for filtering using a slightly different

    form of convolution called symmetric convolution.

    Definition (2-D DCT)

    Assume that the data array has finite rectangular support on then the 2-D DCTis given as

    for

    (4.3.

    The DCT basis functions for size 8 x 8 are shown in Figure ( ). The mapping between the mathematicalvalues and the colors (gray levels) is the same as in the DFT case. Each basis function occupies a smallsquare; the squares are then arranged into as 8 x 8 mosaic. Note that unlike the DFT, where the highest

    frequencies occur near , the , the highest frequencies of the DCT occur at the highest

    indices .

    The inverse DCT exists and is given for as,

    (4.3.2

    where the weighting function w(k) is given just as in the case of 1-D DCT by

    (4.3.

    From eqn (4.3.1), we see that the 2-D DCT is a separable operator. As such it can be applied to the rowsand then the columns, or vice versa. Thus the 2-D theory can be developed by repeated application of the1-D theory. In the following subsections we relate the 1-D DCT to 1-D DFT of a symmetrically extendedsequence. This not only provides an understanding of the DCT but also enables its fast calculation. Wealso present a fast DCT calculation that can avoid the use of complex arithmetic in the usual case wherex is a real-valued signal, e.g., an image. (Note: the next two subsections can be skipped by the readerfamiliar with the 1-D DCT)

  • 8/6/2019 2-D Discrete Cosine Transforms

    2/12

    Review of 1- D DCT

    In the 1-D case the DCT is defined as

    (4.3.

    for every Npoint signal having support The corresponding inverse transform, or IDCT,

    can be written as

    (4.3

    It turns out that this 1-D DCT can be understood in terms of the DFT of a symmetrically extendedsequence,

    (4.3.

    This is not the only way to symmetrically extendx, but this method results in the most widely used DCT

    sometimes called DCT-2 with support In fact, on defining the 2N point

    DFT we will show that the DCT can be alternatively expressed as

    (4.3

    Thus the DCT is just the DFT analysis of the symmetrically extended signal defined in (4.3.6):

    Looking at this equation, we see that there is no overlap in its two components, which fit together without

    a gap. We can see that right after comes at position , which is then followed

    by the rest of the nonzero part of x in reverse order, upto , where sits .We can see a

    point of symmetry midway between and N, i.e., at .

    If we consider its periodic extension we will also see a symmetry about the point . We

    thus expect that the 2Npoint will be real valued except for the phase factor . So the phase

  • 8/6/2019 2-D Discrete Cosine Transforms

    3/12

    factor in eqn (4.3.7) is just what is needed to cancel out the phase term in Y and make the DCT real , as itmust if the two equations, (4.3.1) and (4.3.7), are to agree for real valued inputs x.

    To reconcile these two definitions, we start out with eqn (4.3.7), and proceed as follows:

    the last line following from and Euler's relation, which agrees

    with the original definition, eqn (4.3.4).

    The formula for the inverse DCT, can be established similarly, starting out from

    Some 1-D DCT Properties

    1) Linearity:

    2) Energy conservations:

    (4.3.8

    3) Symmetry:

    (a) General case:

    (b) Real-valued case:

  • 8/6/2019 2-D Discrete Cosine Transforms

    4/12

    4) Eigenvectors of unitary DCT: Define the column vector

    and define the matrix C with elements:

    Then the vector contains the unitary DCT, whose elements are given as

    A unitary matrix is one whose inverse is the same as the transpose . For the unitary DCT, we

    have

    and energy balance equation,

    which is a slight modification on the DCT Parseval relation (4.3.8). So the unitary DCT preserves theenergy of the signalx.

    Some 1-D DCT Properties (contd.)

    It turns out that eigenvectors of the unitary DCT are the same as those of the symmetric tridiagonalmatrix,

  • 8/6/2019 2-D Discrete Cosine Transforms

    5/12

    and this holds true for arbitrary values of the parameter . We can relate this matrix Q to the inverse

    covariance matrix of a 1-D first-order stationary Markov random sequence, with correlation coefficient

    necessarily satisfying

    where and . The actual covariance matrix of the Markov

    random sequence is

    with corresponding, first-order difference equation,

    It can further be shown that when , , so that eigenvectors approximate each other too.Because the eigenvectors of a matrix and its inverse are the same, we then have the fact that the unitaryDCT basis vectors approximate the Karhunen-Loeve expansion, with basis vectors given as the solutionto the matrix-vector equation,

    And corresponding Karhunen-Loeve transform (KLT) given by

    Thus the 1-D DCT of a first-order Markov random vector of dimension N should be close to the KLT of x

    when itscorrelation coefficient This ends the review of the 1-D DCT.

    Symmetric Extension in 2-D DCT

  • 8/6/2019 2-D Discrete Cosine Transforms

    6/12

    Since the 2-D DCT

    is just the separable operator resulting from application of the 1-D DCT along first one dimension andthen the other, the order being immaterial, we can easily extend the 1-D DCT properties to the 2-D case.In terms of the connection of the 2-D DCT with the 2-DFT, we thus see that we must symmetrically extendin, say, the horizontal direction and then symmetrically extend that result in the vertical direction. Theresulting symmetric function (extension) becomes

    The symmetry is about the lines and then from (4.3.7), it follows that the 2-D DCT is

    given in terms of the point DFT as

    Comments

    We see that both the 1-D and 2-D DCTs involve only real arithmetic for real-valued data, and this may

    be important in some applications.

    The symmetric extension property can be expected to result in fewer high frequency coefficients in DCT

    with respect to DFT. Such would be expected for lowpass data, since there would often be a jump at the

    four edges of the period of the corresponding periodic sequence which is not

    consistent with small high- frequency coefficients in the DFS or DFT. Thus the DCT is attractive for lossydata storage applications, where the exact value of the data is not of paramount importance.

    The DCT can be used for a symmetrical type of filtering with a symmetrical filter.

    2-D DCT properties are easy generalizations of 1-D DCT properties.

    Karhunen-Loeve Transform (KLT )

    So far no transformation has been found for images that completely removes statistical dependencebetween transformation coefficients. Suppose a reversible transformation is carried out on N-dimensional

    vector to produce N-dimensional vector of transform coefficients, denoted by,

    (4.4.1

  • 8/6/2019 2-D Discrete Cosine Transforms

    7/12

    where is a linear transformation matrix that is orthonormal or unitary;

    ie (4.4.

    (where "1" denotes transpose)

    Denote the m th column of matrix by column vector , then eqn (4.4.2 ) is equivalent

    to

    The vectors are called orthonormal basis vectors for linear transform .

    From eqn (4.4.1) we can express as,

    where are transform coefficients, and is represented as a weighted sum of basisvectors.

    KLT transform is an orthogonal linear transformation that can remove pairwise statistical correlation

    between the transform coefficients; ie the KLT transform coefficients satisfy

    where summation is over all possible values and and P( ) represents the probability.

    This is usually written using the statistical averaging operatorEas,

    or

    where is the variance of .

    Note that statistical independence implies uncorrelation, but the reverse is not generally true (except forjointly Gaussian r v s )

    The KLT can be derived by assuming

  • 8/6/2019 2-D Discrete Cosine Transforms

    8/12

    TheNxNcorrelation matrix of then becomes

    Karhunen-Loeve Transform (KLT ) (continued)

    From the normality or unitary transform condition i.e., we get with the

    variances of along the main diagonal of the matrix. Thus, in terms of column vectors of , the

    above equation becomes

    We see that the basis vectors of the KLT are the eigenvectors of , orthonormalised to

    satisfy

    [Note that whereas the other image transforms like DFT, DCT were independent of data, the KLTtransformation depends on 2

    ndorder satisfies of the data.]

    The variances of the KLT coefficients are the eigenvalues of and since is symmetric and

    positive definite, eigenvalues are real and positive. The KLT basic vectors and transform coefficients arealso real. Besides decorrelating transform coefficients, the KLT has another useful property: it maximizesthe number of transform coefficients that are small enough so that they are insignificant. For example,

    suppose the KLT coefficients are ordered according to decreasing variance

    ie

    Also suppose that for reasons of economy, we transmit only the 1st

    pN coefficients where . The

    receiver then uses the truncated column vector to form the reconstructed values

    as .

    The mean squared error (MSE) between the original and the reconstructed pels is then

  • 8/6/2019 2-D Discrete Cosine Transforms

    9/12

    It can be shown that KLT minimizes the MSE due to truncation.

    Karhunen-Loeve Transform (KLT ) (continued)

    To show that of all possible linear transforms operating on length N vectors having stationary statistics,the KTL minimizes the MSE due to truncation.

    Let be some other transform having unit length basis vectors

    First we show heuristically that the truncation error is minimum if the basis vectors are

    orthogonalised using the well known Gram Schmidt procedure.

    Let be the vector space spanned by the "transmitted" vectors: for and let be

    the space spanned by the remaining vectors. Therefore any vector can be represented by

    plus vector i.e, as shown in figure below.

    f is the space spanned by transmitted basis vectors, then truncation error is the length of

    vector .Error is minimised if is to

    If is the space spanned by transmitted basis vector, then truncation error is the length of vector .

    Error is minimized if is to .

    If only is transmitted, then MSE is the squared length of the error vector , which is clearly

    minimized if is orthogonal to i.e., is orthogonal to . Further orthogonalisation of the basis

  • 8/6/2019 2-D Discrete Cosine Transforms

    10/12

    vectors within , or within , does not affect MSE.

    Thus we assume to be unitary i.e., has orthogonal basis vectors i.e.

    Its transform coefficients are then given by

    The mean square truncation error is as given by eqn ( ) is,

    Now suppose we represent the vectors in terms of KTL basis vectors

    i.e.,

    and, This follows from

    Since is unitary

    (because basis vectors are of unit length)

    Now from equation ( ) we have

    and therefore can be written in terms of as,

    Karhunen-Loeve Transform (KLT ) (continued)

    Since the KTL is unitary,

  • 8/6/2019 2-D Discrete Cosine Transforms

    11/12

    We may now write

    which form eqn , we get

    As ,

    we have

    ie

    which is

    (Since for )

    Thus from eqn for

    we have

    The second summation

    ie

    and since

    we have

  • 8/6/2019 2-D Discrete Cosine Transforms

    12/12

    ie

    which is = MSE for KTL

    This concludes that the MSE for any other linear transform exceeds that of the KTL transform.