Image Compression Senthil

Embed Size (px)

Citation preview

  • 8/6/2019 Image Compression Senthil

    1/24

    Image Compression

    Need for Image Compression:

    With the advanced development in internet, teleconfere-ncing, multimedia and high-definition television technologies,the amount of information that is handled by computers hasgrown exponentially over the decades. High-quality imagedata requires large amounts of storage space andtransmission bandwidth, something which the current

    technology is unable to handle technically and economically.One of the possible solutions to this problem is to compressthe information so that the storage space and transmissiontime can be reduced.

    Error-Free Compression

    The simplest approach to error-free image compressionis to reduce only coding redundancy. Coding redundancynormally is present in any natural binary encoding of thegray levels in an image. To do so requires construction of avariable-length code that assigns the shortest possible codewords to the most probable gray levels.

    Lossless compressionlossless compression for legal and medical

    documents, computer programs.exploit only code and inter-pixel redundancy.

    Lossy compressiondigital image and video where some errors or loss can

    be tolerated.exploit both code and inter-pixel redundancy and

    sycho-visual perception properties.

  • 8/6/2019 Image Compression Senthil

    2/24

    Huffman Coding

    Variable length code whose length is inversely proportionalto that characters frequency. must satisfy non-prefix property to be uniquely decodable. two pass algorithm

    first pass accumulates the character frequency andgenerate code book

    second pass does compression with the code book.

    create codes by constructing a binary tree:

    1. consider all characters as free nodes.2. assign two free nodes with lowest frequency to a

    parent nodes with weights equal to sum of theirfrequencies.

    3. remove the two free nodes and add the newly createdparent node to the list of free nodes.

    4. repeat step2 and 3 until there is one free node left. Itbecomes the root of tree.

    Huffman Coding (Optimal Coding) -Huffman Source reductions

  • 8/6/2019 Image Compression Senthil

    3/24

    Huffman Code assignment Procedure

    Coding Efficiency = 0.973

    symbolbitsentropy

    symbolbits

    Lavg

    /14.2

    /2.2

    )5)(04.0()5)(06.0()4)(1.0()3)(1.0()2)(3.0()1)(4.0(

    =

    =

    +++++=

    =

    =1

    0

    )()(L

    k

    krkavg rprlL

  • 8/6/2019 Image Compression Senthil

    4/24

    Arithmetic Coding (non block codes)

    Is a Non-block code unlike Huffman code. An entire sequence of source symbols is assigned a

    single arithmetic code. The code word itself defines an interval of real

    numbers between 0 and 1. As the number of symbols 'n' the message increases,

    the interval becomes smaller and the number ofinformation units required to represent the interval

    becomes larger.

    Ex: a five-symbol sequence

    Arithmetic coding Procedure

  • 8/6/2019 Image Compression Senthil

    5/24

    Arithmetic Coding Example

    take in complete data stream and output one specificcodeword which is floating point number between 0and 1.

    two pass algorithm:* first pass computes characters frequency and

    constructs probability table with ranges assigned toeach entry of the table.

    * second pass does actual compressionfirst character of input stream constrains outputnumber to its corresponding range, and the rangeof next character of input stream further constrainsthe number, and so on.

    decoding is reverse of encoding. achieve higher compression ratio than Huffman, butcomputationally expensive.

  • 8/6/2019 Image Compression Senthil

    6/24

    LZW Coding (Lempel-Ziv-Welch)

    Assign fixed-length code words to variable lengthsequence of source symbols.

    Requires no a priori knowledge of the probabilities ofoccurrence of the symbol to be coded.

    Has been integrated into imaging format: GIF, TIFF(compressed TIFF, and uncompressed TIFF), PDF, PNG.

    LZW Coding process

    Construct a dictionary containing the source symbols.Examine the images pixel

    The gray sequences that are not in the dictionaryare placed in algorithmically determined locations.

    Unique feature: coding dictionary or code book iscreated while the data are being encoded.

    LZW decoder builds an identical decompress dictionaryas it decides simultaneously the encoded datastream.

    An LZW coding example: A 4x4, 8-bit image

    39 39 126 126

    39 39 126 126

    39 39 126 126

    39 39 126 126

  • 8/6/2019 Image Compression Senthil

    7/24

    A 512- word dictionary with the following starting content isassumed:

    For a 8 bit monochrome images, the first 256 words of the

    dictionary are assigned to the gray values 0,1,2,....255. For

    instance, the first two pixels are white 255-255 might be

    assigned to the location 256, the address following the

    locations reserved for gray levels 0 through 255.

    If a 9 bit, 512-word dictionary is employed in the coding

    process, the original (8+8) bits that were used to represent

    the two pixels are replaced by a single 9-bit code word.

    Dictionary Location Entry

    01...255256..511

    01...255----..----

  • 8/6/2019 Image Compression Senthil

    8/24

    If the concatenated sequence is not found, the address ofthe currently recognized sequence is output as the nextencoded value.

    Nine additional code words are defined. At the end, thedictionary contains 265 code words and the LZW algorithm

    has successfully identified several repeating gray-levelsequences-reduce the 128 bit image (16 pixels x 8-bit) to 90bits (10 code-words x 9bits).

    The encoded output is obtained by reading the third columnfrom top to bottom. The resulting compression ratio 1.42:1.

    (i.e. 128 bits /90 bits = 1.42).

  • 8/6/2019 Image Compression Senthil

    9/24

    Bit-Plane Coding

    Reduce an images inter-pixel redundancy by processingthe images bit planes individually.

    decompose a multilevel image into a series of binaryimages and compress each binary image via one of severalwell-known binary compression method.represent gray-level image in the form of base 2polynomial.

    the small gray level variations problem (i.e. small changesin gray levels affect all m bit planes)a pixel with intensity127 adjacent to a pixel with intensity 128.Sol: represent the image by an m-bit Gray code.

    Successive code words differ in only one bit (small changesare less likely to affect all m bit planes).

    Gray code bit planes are less complex than correspondingbinary bit planesGray code for 127 and 128 : 127(11000000) and

    128(01000000) .Binary code for 127 and 128 : 127(01111111) and128(10000000) .

    11

    1

    0121

    0

    0

    2

    2

    1

    1

    20

    :

    222:

    +

    =

    =

    +++

    mm

    lll

    mm

    m

    m

    m

    m

    ag

    mlaag

    ggggcodeGray

    aaascalegraybitm

  • 8/6/2019 Image Compression Senthil

    10/24

  • 8/6/2019 Image Compression Senthil

    11/24

  • 8/6/2019 Image Compression Senthil

    12/24

    One-dimensional run-length coding

    common approaches(1) specify the first run of each row.(2) assume that each run begins with a white run,

    whose run-length may in fact be zero.

    The black and white run lengths may be coded separatelyusing variable-length coding based on statistics. Theapproximate run-length entropy is

    Where 'H0' is the entropy of black run-length source and 'H

    1'

    is the entropy of white runs. The variables 'L0

    ' and 'L1

    ' denote

    the average values of black and white run lengthsrespectively.

    Additional compression can be realized by variablelength coding the run lengths, The above equation providesan estimate of the average number of bits per pixel required

    to encode the run length.

    10

    10

    LL

    HHHRL

    +

    +=

  • 8/6/2019 Image Compression Senthil

    13/24

    Two-dimensional run-length coding -RAC (Relative addresscoding)

    Track the binary transition that begin and end each blackand white run. Require the adoption for a convention fordetermining run values.

  • 8/6/2019 Image Compression Senthil

    14/24

    Lossy Compresssion

    Lossy encoding is based on the concept of compromisingthe accuracy of the reconstructed image in exchange forincreased compression.

    Lossy encoding is based on the concept of compromisingthe accuracy of the reconstructed image in exchange forincreased compression.

    Lossy Compression:

    1. Spatial domain methods2. Transform coding

    Transform Coding

    The goal of the transformation process is to decorrelate the

    pixels of each sub-image, or to pack as much information aspossible into the smallest number of transform coefficients .(1) Adaptive transform coding: adaptive to local content(2) Non-adaptive transform coding: fixed for sub-image

  • 8/6/2019 Image Compression Senthil

    15/24

    Depend on the reconstruction error that can be tolerated andthe computational resources available,

    Include Discrete and inverse discrete transform Fourier

    Walsh-Hadmard Discrete cosine transform

    Most transform coding systems are based on the DCTfor its information packing ability and computationalcomplexity.

    Forward kernel is Separable if:

    Forward kernel is Symmetric if:

    1,,1,0,),,,(),(),(

    1,,1,0,),,,(),(),(

    1

    0

    1

    0

    1

    0

    1

    0

    ==

    ==

    =

    =

    =

    =

    NyxvuyxhvuTyxf

    NvuvuyxgyxfvuT

    N

    u

    N

    v

    N

    u

    N

    v

    ),().,(),,,( 21 vyguxgvuyxg =

    ),().,(),,,( 1121 vyguxgvuyxggg ==

    Nvyuxj

    Nvyuxj

    evuyxh

    eN

    vuyxg

    /)(2

    /)(2

    ),,,(

    1),,,(

    +

    +

    =

    =

  • 8/6/2019 Image Compression Senthil

    16/24

    Walsh-Hadamard Transform (WHT):

    Discrete Cosin Transform (DCT):

    Steps Involved In Transform based Coding

    1. Dividing the image into sub-images of size 8x82. Representing each sub-image using one of the transforms3. Truncating 50% of the resulting coefficients4. Taking the inverse Transform of the truncated coefficients

    =

    ==

    +

    +=

    =

    1,,2,12

    01

    )(

    2

    )12(cos

    2

    )12(cos)()(

    ),,,(),,,(

    NuforN

    uforNuwhere

    N

    vy

    N

    uxvu

    vuyxhvuyxg

  • 8/6/2019 Image Compression Senthil

    17/24

    DFT

    r mse=1.28

    WHT

    r mse=0.86

    DCT

    r mse=0.68

  • 8/6/2019 Image Compression Senthil

    18/24

    DCT Advantages:

    1. Implemented in a single integrated circuit (IC)2. Packing the most information into the fewestcoefficients

    3. Minimizing the block-like appearance (blockingartifact).

    Sub-image size selectionImages are subdivided so that the correlation

    between sub-image is reduced to some acceptable

    level.As sub-image size increase, the level ofcompression and computational complexity increase.

  • 8/6/2019 Image Compression Senthil

    19/24

    Bit allocation Reconstruction error depends on the number and

    relative importance of the transformed coefficientsthat are discarded, as well as the precision.

    the process of truncating, quantizing, and coding thecoefficients of a transformed image: Zonal coding: the retained coefficients are selected

    based on maximum varianceThresholding coding: based on maximum

    magnitude The bit allocation process includes truncating,

    quantizing, and coding the coefficients of a transformed sub-image.

    (1) Zonal coding

    * Fixed number of bits / coefficientCoefficients are normalized by their standard deviations and

    uniformly quantized.*Fixed number of bits is distributed among the coefficientsunequally.* A quantizer such as an optimal Lloyed-Max is designed foreach coeff.:

    - DC coeff. Is modeled by Rayleigh density func.

    - The remaining coeff. Are modeled by Laplcianor Gaussian.

    (2) Threshold coding

    Single global thresholdDifferent threshold for each subimage (N-Largest coding)

    Threshold can be varied as a function of the location ofeach coeff.

  • 8/6/2019 Image Compression Senthil

    20/24

  • 8/6/2019 Image Compression Senthil

    21/24

    Wavelet Coding

    Figure: A Wavelet Coding System: (a) Encoder (b)

    Decoder

  • 8/6/2019 Image Compression Senthil

    22/24

    Figure:2-D Wavelet transform (a)Analysis Filter Bank

    Figure:2-D Wavelet transform (a)Analysis Filter Bank

  • 8/6/2019 Image Compression Senthil

    23/24

    Like transform coding, wavelets pack most of theimportant visual information into a small number ofcoefficients, the remaining coefficients can be quantizedcoarsely or truncated to zero with little image distortion.

    One or more of the lossless coding methods Huffman,arithmetic and bit-plane coding can be,incorporated into thefinal symbol coding step. Decoding is accomplished byinverting the encoding operations with the exception ofquantization, which cannot be reversed exactly.

    The principal difference between the wavelet-basedsystem and the transform coding system is the omission ofthe transform encoder's subimage processing stages.Because wavelet transforms are both computationallyefficient and inherently local.

    Wavelet selection impact directly the computational

    complexity of the transforms and the system's ability tocompress and reconstruct images of acceptable error. Themostly widely used expansion functions for wavelet-basedcompression are the Daubechies wavelets and biorthogonalwavelets.

    Decomposition level selection is the another factor

    affecting wavelet coding computational complexity andreconstruction error. Since a P-scale fast wavelet transforminvolves 'P' filter bank iterations, the number of operations inthe computation of the forward and inverse transformsincreases with number of decomposition levels.

  • 8/6/2019 Image Compression Senthil

    24/24

    Wavelet Selection

    Table: Wavelet transform filter taps and zeroed coefficientswhen the wavelet transforms below 1.5

    Decomposition Level Selection

    Table:Decomposition Level impact on wavelet coding the512x512 image.