JPEG Compression Standard

Embed Size (px)

Citation preview

  • 7/29/2019 JPEG Compression Standard

    1/23

    JPEG Compression Standard

    Mitul Modi

    ME II MSARoll No: 199

    22-Mar-13 JPEG Compression Standard 1

  • 7/29/2019 JPEG Compression Standard

    2/23

    22-Mar-13 JPEG Compression Standard 2

    Outlines:

    JPEG Compression Overview

    YCbCr Color Mode

    Discrete Cosine Transform

    Block diagram of JPEG Compression

    Steps For JPEG Compression

    Matlab code for JPEG Compression using DCT

    Examples

  • 7/29/2019 JPEG Compression Standard

    3/23

    JPEG Compression Overview

    JPEG stands for Joint Photographic Experts Group

    Used on 24-bit color files.

    It is a lossy compression technique, But excellent quality image

    with high compression rates.

    22-Mar-13 JPEG Compression Standard

    3

  • 7/29/2019 JPEG Compression Standard

    4/23

    YCbCr Color Mode:

    22-Mar-13 JPEG Compression Standard 4

    YCbCrcolor mode stores color in terms of its luminance

    (brightness) and blue and red chrominance (hue).

    The human eye is less sensitive to chrominance than luminance.

    YCbCr is not required for JPEG compression, but it gives abetter compression rate.

  • 7/29/2019 JPEG Compression Standard

    5/23

    22-Mar-13 JPEG Compression Standard 5

    Discrete Cosine Transform:

    The DCT transforms the data from the spatial domain to thefrequency domain.

    The spatial domain shows the amplitude of the color as you

    move through space`The frequency domain shows how quickly the amplitude of thecolor is changing from one pixel to the next in an image file.The frequency domain is better representation for data becauseit makes it possible for you to separate out and throw away

    information that isnt very important to human perception.The human eye is not very sensitive to high frequency changes

    especially in photographic images, so the high frequency datacan, to some extent, be discarded.

  • 7/29/2019 JPEG Compression Standard

    6/23

    22-Mar-13 JPEG Compression Standard 6

    Block diagram of JPEG Compression

  • 7/29/2019 JPEG Compression Standard

    7/23

    Steps in JPEG Compression

    1. (Optionally) If the color is represented in RGB mode,translate it to YCbCr.

    2. Divide the file into 8 X 8 blocks.

    3. Transform the pixel information from the spatial domainto the frequency domain with the Discrete CosineTransform.

    4. Quantize the resulting values by dividing each coefficientby an integer value and rounding off to the nearest integer.

    5. Look at the resulting coefficients in a zigzag order.

    6. Do the Entropy Encoding Using Entropy Encoder likeHuffman Encoder and Run-Length Encoder.

    22-Mar-13 JPEG Compression Standard 7

  • 7/29/2019 JPEG Compression Standard

    8/23

    Step 1: Converting RGB to YCbCr.

    22-Mar-13 JPEG Compression Standard 8

    Optional But gives better Compression rate.

    For converting RGB to YCbCr. Take downsampling

    The notation 4:1:1 means that for each block of four pixels,

    you have 4 samples of luminance information (Y), and 1

    each of the two chrominance components (U and V).

    MCUminimum coded unit

    U, V

    Y

    Y

    Y

    Y

    http://www.studio1productions.com/Articles/411samp.htmhttp://www.studio1productions.com/Articles/411samp.htm
  • 7/29/2019 JPEG Compression Standard

    9/23

    Step 2: Divide into 8 X 8 blocks

    Note that with YCbCr color, you have 16 pixels ofinformation in each block for the Y component (thoughonly 8 in each direction for the U and V components).

    If the file doesnt divide evenly into 8 X 8 blocks, extrapixels are added to the end and discarded after thecompression.

    The values are shifted left by subtracting 128.

    22-Mar-13 JPEG Compression Standard 9

  • 7/29/2019 JPEG Compression Standard

    10/23

    Step 3: DCT (1D)

    Transform the pixel information from the spatial domain to

    the frequency domain with the Discrete Cosine Transform.

    The DCT is an array of coefficients (for 1D sequence length

    N)

    22-Mar-13 JPEG Compression Standard 10

    where

  • 7/29/2019 JPEG Compression Standard

    11/23

    Step 3: DCT (2D)

    For N X N pixel image

    the DCT is an array of coefficients

    where

    22-Mar-13 JPEG Compression Standard 11

    N

    vy

    N

    uxpCC

    NDCT

    N

    y xy

    N

    xvuuv 2

    )12(cos

    2

    )12(cos

    2

    1 10

    1

    0

    where

    otherwiseCC

    vuforCC

    vu

    vu

    1

    0,2

    1

    NvNupuv 0,0,

    NvNuDCTuv 0,0,

  • 7/29/2019 JPEG Compression Standard

    12/23

    Continue

    For the 8 X 8 matrix of color data, youre getting an 8 X 8

    matrix of coefficients for the frequency components.

    22-Mar-13 JPEG Compression Standard 12

  • 7/29/2019 JPEG Compression Standard

    13/23

    Continue

    DCT is designed to work on pixel values ranging from -128 to

    127, the original block is leveled off by subtracting 128 from

    each entry. Finally D = TMT

    22-Mar-13 JPEG Compression Standard 13

  • 7/29/2019 JPEG Compression Standard

    14/23

    Step 4: Quantization

    The DCT is lossless in that the reverse DCT will give you

    back exactly your initial information (ignoring the rounding

    error that results from using floating point numbers.)

    The values from the DCT are initially floating-point.Common Quantization Matrix is given by

    22-Mar-13 JPEG Compression Standard 14

    Q(i,j)=

  • 7/29/2019 JPEG Compression Standard

    15/23

    Continue..

    Quantization involves dividing each coefficient by an integer

    between 1 and 255 and rounding off.

    The quantization table is chosen to reduce the precision of

    each coefficient to no more than necessary.The quantization table is carried along with the compressed

    file.

    22-Mar-13 JPEG Compression Standard 15

  • 7/29/2019 JPEG Compression Standard

    16/23

    Step 5: Arrange in zigzag order

    This is done so that the coefficients are in order of increasingfrequency.

    After quantization, most of the coefficients to equal zero.

    JPEG takes advantage of this by encoding quantizedcoefficients in the zig-zag sequence.

    The advantage lies in the

    consolidation of relatively

    large runs of zeros, whichcompress very well.

    22-Mar-13 JPEG Compression Standard 16

  • 7/29/2019 JPEG Compression Standard

    17/23

    22-Mar-13 JPEG Compression Standard 17

    An entropy encoder supplementary compresses thequantized values losslessly to provide a better overallcompression.

    It uses a model to perfectly determine the probabilities foreach quantized value and produces an appropriate codebased on these probabilities so that the resultant outputcode stream is smaller than the input stream.

    The most commonly used entropy encoders are the

    Huffman encoder and the arithmetic encoder, although forapplications requiring fast execution, simple Run LengthEncoding (RLE) is very effective. This improves thecompression of run-length encoding.

    Step 6: Entropy Encoder

  • 7/29/2019 JPEG Compression Standard

    18/23

    22-Mar-13 JPEG Compression Standard 18

    Matlab code :

  • 7/29/2019 JPEG Compression Standard

    19/23

    22-Mar-13 JPEG Compression Standard 19

    Examples :

    DCT to rows only:

  • 7/29/2019 JPEG Compression Standard

    20/23

    22-Mar-13 JPEG Compression Standard 20

    Examples :

    DCT to rows*Column :

  • 7/29/2019 JPEG Compression Standard

    21/23

    Reference:

    Digital Image Processing by Rafael Gonzalez and Richard Woods

    M.Mohamed Sathik , K.Senthamarai Kannan and Y.Jacob Vetha Raj,

    Hybrid JPEG Compression Using Histogram Based Segmentation.

    International Journal of Computer Science and Information Security, Vol.

    8, No. 8, November 2010

    Leger, A., T. Omachi, and T.K. Wallace, "JPEG Still Picture Compression

    Algorithm," Optical Engineering, vol. 30, no. 7, July 1991, pp. 947-954.

    Kiran Bindu, Anita Ganpati, Aman Kumar Sharma, A Comparative

    Study Of Image Compression Algorithms.International Journal of

    Research in Computer Science eISSN 2249-8265 Volume 2 Issue 5 (2012)

    http://www.jpeg.org,

    http://cnx.rice.edu,

    http://www.datacompression.info

    22-Mar-13 JPEG Compression Standard 21

    http://www.jpeg.org/http://cnx.rice.edu/http://www.datacompression.info/http://www.datacompression.info/http://cnx.rice.edu/http://www.jpeg.org/
  • 7/29/2019 JPEG Compression Standard

    22/23

    22-Mar-13 JPEG Compression Standard 22

  • 7/29/2019 JPEG Compression Standard

    23/23

    22-Mar-13 JPEG Compression Standard 23

    Lossy Compression Model