Top Banner

of 9

Discrete Cosin Transform

Apr 08, 2018

Download

Documents

Thelinh
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 Discrete Cosin Transform

    1/9

    Image Compression Using the

    Discrete Cosine Transform

    Tran The Linh

    Nguyen Duy Tien

    Ngo Duc ThanhImage Compression Using the DCT

  • 8/6/2019 Discrete Cosin Transform

    2/9

    Image Compression Using the Discrete

    Cosine Transform Abstract

    The discrete cosine transform (DTC) is a

    technique for converting a signal into elementary

    frequency components. It is widely used image

    compression. Here we develop some simple

    functions to compute the DCT and compress

    images.These functions illustrate the power of Matlab in

    the prototyping of image processing algorithms

    Image Compression Using the DCT

  • 8/6/2019 Discrete Cosin Transform

    3/9

    The one-Dimensional Discrete

    Cosine Transform

    The One-Dimensional Discrete Cosine Transform

    The Discrete Cosine Transform of a list of n real

    number x(n), n=1N, is the list of length N givenby:

    where:

    Image Compression Using the DCT

    1

    (2 1)( 1)( ) ( ) ( )cos( ) ( 1... )

    2

    N

    n

    n k y k w k x n k N

    N

    T

    !

    ! !

    10

    ( )2

    if kN

    w k

    otherwiseN

    !

    !

  • 8/6/2019 Discrete Cosin Transform

    4/9

    The one-Dimensional Discrete

    Cosine Transform

    The example

    Image Compression Using the DCT

    x=50sin(2pi*t/40);

    X=dct(x);

    plot(t,x,t,X);legend('x(t)',DCt(x));

  • 8/6/2019 Discrete Cosin Transform

    5/9

    The one-Dimensional Discrete

    Cosine Transform

    The example

    Find how many DCT coefficients represent 99% of the

    energy in a sequence:

    Image Compression Using the DCT

    x = (1:100) + 50*cos((1:100)*2*pi/40);

    X = dct(x); [XX,ind] = sort(abs(X));

    ind = fliplr(ind); i = 1;

    while (norm([X(ind(1:i))

    zeros(1,100-i)])/norm(X)

  • 8/6/2019 Discrete Cosin Transform

    6/9

    The Two-Dimensional Discrete

    Cosine Transform

    The One-Dimensional DCT is useful in

    processing on dimensional signals such as

    speech waveforms. For analysis of two-

    dimensional (2D) signal such as images, we

    need a 2D version of the DCT. for an matrix.

    The DCT-2D is computed in a simply way: The

    DCT-1D is applied to each row of x and the toeach column of the result.

    Image Compression Using the DCT

  • 8/6/2019 Discrete Cosin Transform

    7/9

    The Two-Dimensional Discrete

    Cosine Transform

    Thus, the transform of x given by:

    where:

    Image Compression Using the DCT

    1 1

    0 0

    0 1(2 1) (2 1)cos( )cos( )

    0 12 2

    M N

    pq p q mn

    m n

    p Mm p n qB A

    q NM

    N

    T TE E

    ! !

    e e !

    e e

    11, 0, 0

    2 2,1 1 ,1 1

    p q

    qpNM

    and

    p M q MM N

    E E

    !!

    ! !

    e e e e

  • 8/6/2019 Discrete Cosin Transform

    8/9

    The Two-Dimensional Discrete

    Cosine Transform

    The example

    RGB = imread(hnen.bmp');

    I = rgb2gray(RGB);

    J = dct2(I);

    imshow(log(abs(J)),[]),

    colormap(jet(64)), colorbar;

    Image Compression Using the DCT

  • 8/6/2019 Discrete Cosin Transform

    9/9

    The Two-Dimensional Discrete

    Cosine Transform

    Now set values less than magnitude 10 in the DCT matrix to

    zero, and then reconstruct the image using the inverse DCT

    function idct2.

    Image Compression Using the DCT

    J(abs(J) < 10) = 0;K = idct2(J);

    imshow(I) figure,

    imshow(K,[0 255]);