STILL IMAGE COMPRESSION

Embed Size (px)

Citation preview

  • 7/29/2019 STILL IMAGE COMPRESSION

    1/15

    1

    A PROJECT REPORT ON

    STILL IMAGE COMPRESSIONDepartment of Electronics and Telecommunication Engineering

    ABSTRACT:

    Images are generated, edited and transmitted on a very regularbasis in a vast number of systems today. The raw image datagenerated by the sensors on a camera is very voluminous tostore and hence not very efficient. It becomes especiallycumbersome to move it around in bandwidth constrainedsystems or where bandwidth is to be conserved for costpurposes such as the World Wide Web. Such scenariosdemand use of efficient image compressing techniques such asthe JPEG algorithm technique which compresses the image toa high degree with little loss in perceived quality of the image.Today JPEG algorithm has become the de facto standard inimage compression. MATLAB program for DCT based JPEGcompression of an still image was written.

  • 7/29/2019 STILL IMAGE COMPRESSION

    2/15

    2

    CONTENTS: Introduction

    Base line sequential mode compression

    Block diagram for encoder & decoder

    Performing DCT transform

    Quantization of DCT coefficient

    Zigzag ordering of coefficient

    Run-length coding of DCT coefficients(AC and DC)

    JPEG Decoder

    - Block Diagram

    - Explanation

    MATLAB Program

    Conclusion

    Reference

  • 7/29/2019 STILL IMAGE COMPRESSION

    3/15

    3

    Introduction:

    Image compression and coding:

    JPEG:

    The JPEG standard for coding of digital images was designed by JointPhotographic Expert Group (JPEG), under both the International Standards

    Organization (ISO) and the International Telecommunications Union-

    Telecommunication Sector (ITU-T). Aims to support a wide variety of applications for compression of continuous-

    tone images and is most frequently used means of compressing still images.

    JPEG specifies two classes of encoding and decoding, viz. lossless andlossy.

    1. Lossless compression:

    Lossless compression is based on predictive DPCM methodusing neighboring pixel values.

    2. Lossy compression:

    JPEG standard defines three lossy compression modes,namely baseline sequential mode, progressive mode, andhierarchicalmode.

    These compressions are based on Discrete CosineTransform (DCT).

    Transmission of DCT co-efficient are different in all mode.

    Produces reconstructed image with high visual fidelity

    DCT based coding are of 2 types:-1. Baseline system (what is commonly known as JPEG!): lossy

    Can handle gray scale or color images, with 8 bits per colorcomponent

    2. Extended system: can handle higher precision (12 bit) images.

    Baseline sequential mode compression:-

    An image is partitioned into 8x8 non-overlapping pixel block.

    For each 8x8 block, three steps are involved:- Block DCT

    - Perceptual-based quantization

  • 7/29/2019 STILL IMAGE COMPRESSION

    4/15

    4

    - Variable length coding: Run length and Huffmancoding.

    ENDOCER/DECODER BLOCK DIAGRAM

    Fig.1

  • 7/29/2019 STILL IMAGE COMPRESSION

    5/15

    5

    Fig.2

    WHAT DOES A TRANSFORM DO?

    A transform represents an image as linear combination of some basis images and

    specify their linear coefficients.

  • 7/29/2019 STILL IMAGE COMPRESSION

    6/15

    6

    Fig.3

    Basis Image of 8x8 DCT:

    Fig.4

    Performing DCT transformation:

    The image is divided into 8x8 blocks.Zero padding is done if required.

    Consider the following as an example of an 8x8 sub image:

  • 7/29/2019 STILL IMAGE COMPRESSION

    7/15

    7

    Then each 8 bit sample ranging from [0,255] is level shifted by subtracting

    128 to be centered around zero which yields range [-128,127]

    Next is to apply two dimensional DCT on each pixel

    u is the horizontal spatial frequency, for the integers v is the vertical spatial frequency, for the integers

    gx,yis the pixel value at coordinates (x,y)

    .Gu,vis the DCT coefficient at coordinates (u,v)

    Quantization of DCT coefficient:

    Use uniform quantization on each coefficient

    Different coefficient is quantized with different step-size(Q)

    Human eye is more sensitive to low frequency components

    Low frequency coefficients with a smaller Q

    High frequency coefficient with larger Q

    Specified in a normalization matrix

  • 7/29/2019 STILL IMAGE COMPRESSION

    8/15

    8

    Normalization matrix can then be scaled by a scale factor (QP),which isinversely proportional to a quality factor

    Quality factor: 100% best quality -> lower quality

    One can use either the default normalization matrix, or specify anarbitrary matrix

    For color images, a different normalization matrix can be specifiedfor each colorcomponent.

    whereGis the nonquantized DCT coefficients; Q is the quantization matrix above; and

    B is the quantized DCT coefficients.

    Using this quantization matrix with the DCT coefficient matrix from above results

    in:

    For example, using 415 (the DC coefficient) and rounding to the nearest integer,

    Zig-Zag Ordering of DCT Coefficients:

  • 7/29/2019 STILL IMAGE COMPRESSION

    9/15

    9

    After doing Zigzag ordering run-length code is obtained.For the above example run length code is[-26,(0,2),(1,2),(0,2),(0,3),(0,2),(0,3)and so on]

    Coding of Quantized DCT Coefficients:

    o Coding process of DC symbol:

    Collect current and Previous quantized DC values.

    Calculate prediction error

    The prediction error is coded in two parts: Which category it belongs to (Table of JPEG Coefficient Coding

    Categories), and code using a Huffman code (JPEG DefaultDC Code)

    Which position it is in that category, using a fixed length code,

    length=category number

    Encode and concatenate prediction error with its category to get a code word.

    JPEG Tables for Coding DC:

  • 7/29/2019 STILL IMAGE COMPRESSION

    10/15

    10

    o Coding process for AC symbol:

    AC Coefficients: Runlength coding Many high frequency AC coefficients are zero after first few low-frequency

    coefficients Runlength Representation:

    Ordering coefficients in the zigzag order

    Specify how many zeros before a non-zero value, this isdenoted by RUN

    Specify the category in which the nonzero vale falls. And this isdenoted by CAT

    Each symbol=(length-of-zero, non-zero-value)=(RUN,CAT) Code all possible symbols using Huffman coding

    More frequently appearing symbols are given shorter codewords One can use default Huffman tables or specify its own tables. Instead of Huffman coding, arithmetic coding can be used to achievehigher

    coding efficiency at an added complexity.

    JPEG table for coding AC (RUN,CAT) symbol:

  • 7/29/2019 STILL IMAGE COMPRESSION

    11/15

    11

    JPEG DECODER:

  • 7/29/2019 STILL IMAGE COMPRESSION

    12/15

    12

    A JPEG decoder is capable of reconstructing image data from a stream ofcompressed image data. This requires that some transformations be applied to thecompressed image giving reconstruction of the image data.

    BLOCK DIAGRAM:

    o VLD unit:

    The VLD unit should perform the variable length decoding operation. The JPEGstandard allows the use of two DC tables and two AC tables for a baselinesequential decoder. The VLD decide the table needed for the decompression.Present inVLD table. The control logic is responsible for loading the correct Huffmantables in the VLD table. The VLD unit assumes that the correct tables have beenloaded. The VLD requires bits from the compressed image data in order to function.To get one or more bits from the compressed image data, the VLD can ask the bitASU for these bits.

    o ZZ unit:

    The ZZ unit should perform the zigzag scan operation.

    o DQ unit:

    The DQ unit should perform the dequantization allowing the use of up to fourdequantization tables for a baseline sequential decoder. To select the correctdequantization table, an extra parameter should be supplied to the dequantizationunit.The dequantization tables needed by the dequantization unit can be found in the DQtable.The control logic is responsible for loading the correct dequantization tables inthe DQ table.Thedequantization unit assumes that the correct tables have beenloaded.

    o Bit ASU:

    The compressed image data can be modeled as a stream of bytes. The JPEGdecoder movesthrough this byte stream while it decodes the image. The bit ASU isused to facilitate the JPEG decoder in accessing these bits and bytes. The bit ASUhas therefore a number of procedures.

    o IDCT:

  • 7/29/2019 STILL IMAGE COMPRESSION

    13/15

    13

    The IDCT unit in the image processor should realize the inverse discrete cosine

    transform. Ittherefore takes one block as its input. It then applies an inverse discrete

    transformation withan 8-bit precision to it. After computation of the IDCT, the signed

    output samples are level-shifted. This level shifting converts the output to an

    unsigned representation. For 8-bit precision, the level shift is performed by adding128 to every element of the block that came out of the IDCT. If necessary, the output

    samples shall be clamped to stay within the range appropriate for the precision (0 to

    255 for 8-bit precision).

    o Color conversion unit:

    The color conversion unit in the image processor should realize the color conversionfrom theYCbCr coloring scheme to the RGB coloring scheme. This is only necessaryif the number ofimage components equals three. In all other cases, no changes tothe coloring scheme will bemade by the color conversion unit.TheYCbCr to RGBcolor conversion should be done as defined in CCIr. It is used when chromatic imageis taken.

    o Re-ordering unit:

    The output of the color conversion unit is a minimal coded unit [MCU]. It describes allcolorcomponents in a region of the image. The first MCU outputted describes thetop-left mostregion of the image. The MCU are then outputted in a row-by-rowfashion.

    Most image display systems (e.g. video and computer) describe an image in a line-by-line manner. The re-ordering unit should provide a conversion between thesystem in which MCUs are used to describe a region of the image and the system inwhich the image is described in aline-by-line style. If necessary, the re-ordering unitshould resize a MCU to make sure that the original image is maintained.

    o Control logic:

    This unit controls the data flow in the processor and requests communicationpackets from thecommunication channel and sends the enclosed data to the correct

    units. In case, thecommunication packet is a Block packet, the enclosed block mustbe sent to the IDCT unit.When the IDCT unit has finished, the control logic has tocheck whether a complete MCU ispresent in the memory and the MCU can beprocessed. When the control logic receives an EOI packet from the communicationchannel, it should finish its operation..

    RESULT:

  • 7/29/2019 STILL IMAGE COMPRESSION

    14/15

    14

    CONCLUSION:

  • 7/29/2019 STILL IMAGE COMPRESSION

    15/15

    15

    This report describes the design and implementation of a JPEG encoder anddecoder.For JPEG encoder the procedure sequentially follows DCT transformation of eachpixel of the image, Quantization of samples, zigzag ordering to have 2-D array in 1-Dformat, variable length coding using Run length and Hoffmann coding to obtain the

    compressed image. This compressed image is then decoded with the blocks ofvariable length decoder and follows the reverse format. The output aftercompression contains lossy data. However such data losses are irrelevant to theobserver.

    Reference:

    Official JPEG site:www.jpeg.or

    Gonzalez and Woods, Digital image processing, 2ndedition.

    http://www.jpeg.or/http://www.jpeg.or/http://www.jpeg.or/http://www.jpeg.or/