Top Banner

of 24

Image Compression 2

May 30, 2018

Download

Documents

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/9/2019 Image Compression 2

    1/24

    Image Compression

    Lecture 9

    Sankalp [email protected]

  • 8/9/2019 Image Compression 2

    2/24

    Arithmetic Coding

    The arithmetic codes do not generate block codes. There is no one to one correspondence between the

    code word and the sequence of symbols.

    A random number selected from an interval is used to

    depict a symbol. The length of the symbol decides the interval length.

    1

    0 0

    0.2

    0.04

    0.08

    0.056

    0.072

    0.0624

    0.0688

    0.6752a4

    a3

    a2

    a1

    a4

    a3 a3

    a2

  • 8/9/2019 Image Compression 2

    3/24

    Arithmetic Coding

    The 3 decimal places are used to code thesequence.

    3/5 0.6 decimal digits / source.

    Bounds set by the noiseless coding theorem notmet due to message ending symbols getting

    added.

    Scaling and rounding.

  • 8/9/2019 Image Compression 2

    4/24

    LZW Coding

    Exploits interpixel redundancy and does not requirepriory knowledge of the probability.

    It assigns fixed length codes to variable length symbol

    sequences.

    It is a dictionary based code. For an L bit data sourcewith 2L possible symbols the first 2L symbols are allotted

    codes [0-2L

    ].

    Beyond which a dictionary word is allotted to the symbolsequences.

  • 8/9/2019 Image Compression 2

    5/24

    LZW Coding

    Each entry in the dictionary is a code word for arecognized symbol sequence.

    The decoder creates a dictionary as it parses the coded

    sequence.

    A problem with the practical implementation is dictionaryoverflow.

    Usually the dictionary is flushed and reinitialized.

    The compression ratio could be used as a threshold toreinitialize the dictionary.

  • 8/9/2019 Image Compression 2

    6/24

    Example: LZW Coding

    TOBEORNOTTOBEORTOBEORNOT#

  • 8/9/2019 Image Compression 2

    7/24

    Bit-Plane Coding

    The Bit planes of an image can be coded in order toexploit interpixel redundancy.

    Using gray code instead of binary code is a way to

    reduce the number of 0-1/1-0 transitions in adjacentpixels with adjacent pixel values.

    The higher order bit planes tend to have less

    randomness as compared to the lower bit planes.

    Each of the bit planes could be compressed individuallyby binary compression methods.

  • 8/9/2019 Image Compression 2

    8/24

    Constant Area Coding

    Areas of constant white or black are identified andassigned code words.

    The regions with mixed intensities are also identified andare appended with a prefix.

    The most probable of the region is assigned a one bitcode 1 the other two categories are given two bit codes

    10 and 11.

  • 8/9/2019 Image Compression 2

    9/24

    White Block Skipping

    Useful while compressing text.

    Solid white blocks are 0 black and other blocks arecoded by 1 followed by a bit pattern.

    There are slight variations in which the solid white linesare coded as 0 and mixed or black with 1 as a prefix.

    2D sub-blocks could be created an treated in a similarfashion. Completely white sub-blocks are coded with 0.

    Iteratively the sub-blocks get coded.

  • 8/9/2019 Image Compression 2

    10/24

    One Dimensional run-length coding

    The sequences of ones and zeros are encoded as runs[the lengths of the sequences] .

    Used in Fax.

    The common way to denote the runs

    1) is to give the value of the first run at every line

    2) assume the first run is white and the length could bebe zero.

  • 8/9/2019 Image Compression 2

    11/24

    One Dimensional Run Length Coding

    The variable length codes are usually used with the run lengthcodes to further compress the data.

    Symbol aj is used to represent a black run length code of length j.

    The probability of such a run could be calculated as [runs of size j] /

    [all runs].

    The entropy of the runs can be obtained from the probabilities.

    The entropy of the run lengths is given by

    10

    10

    LL

    HHH

    RL

  • 8/9/2019 Image Compression 2

    12/24

    2D Run Length Coding

    Relative Address Coding tracks the binary transitions.ec distance between consecutive transitions on the

    same line [current line]cc- distance between transitions of same type on

    consecutive lines [previous line]

    ec

    c cc

    e c

  • 8/9/2019 Image Compression 2

    13/24

    Contour Tracing and Coding

    Direct Contour Tracing

    Predictive Differential Quantizing

    Front and back contour are coded as differences in the start

    points on adjacent scan lines as well as the differences inlengths of the segment enclosed by the contour.

    Start and end messages are needed to signal the starting andending [merge] points on the contours.

    d1

    d2

  • 8/9/2019 Image Compression 2

    14/24

    Transform Coding

    The spatial domain is converted to a transform domain

    Followed by quantization in the transform domain.

    Constructnxn

    subimages

    ForwardTransform

    QuantizerSymbolEncoder

    Symboldecoder

    Inversetransform

    Mergenxn

    subimages

    InputImage

    NxN

    Compressedimage

    Compressed

    image

    Decompressed

    image

  • 8/9/2019 Image Compression 2

    15/24

    Transform Coding

    The image is divided into smaller subimages.

    The subimages are transformed into a transform domain.DFT and DCT are among the common transforms.

    Each transformed subimage has the coefficients with theleast information is quantized away.

    The quantized coefficients are then run length coded.

    The local characteristics of the image can be used tovary the quantization adaptively.

  • 8/9/2019 Image Compression 2

    16/24

    Transform Selection

    Some useful properties that transformsmay have when used for compression are

    1) separability

    2) symmetry

    3) energy compaction.

    4) fast transforms

    5) variance of the transform coefficents

    6) decorrelation

  • 8/9/2019 Image Compression 2

    17/24

    Transforms for Compression

    Has a fast transform.

    Can be implemented with circular convolution.

    Separable Symmetric and Periodic.

    Needs image sizes to be padded to powers of 2.

    Needs complex arithmetic.

    DFT

    DCT

    Fast.

    Has very high energy compaction for correlated data.

  • 8/9/2019 Image Compression 2

    18/24

    Fourier Transform Kernel

    The matrix elements of the Fourier Transform

  • 8/9/2019 Image Compression 2

    19/24

    Discrete Cosine Transform Kernel

    Kernel elements of Discrete Cosine Transform

  • 8/9/2019 Image Compression 2

    20/24

    Hadamard Transform Kernel

  • 8/9/2019 Image Compression 2

    21/24

    Walsh Transform

    The walsh transform is obtainable from the Hadamard transformby bit reversal permutation followed by gray code permutations.

  • 8/9/2019 Image Compression 2

    22/24

    Basis Functions

    Walsh basis functions DCT Basis Functions

  • 8/9/2019 Image Compression 2

    23/24

    Bit Allocation

    The process of transforming and truncating and encodingis called bit allocation.

    Two kinds of quantizations are called Thresholding and Zonal encoding.

    Thresholding is a coarse quantization of the coefficients on the basisof magnitude.

    Zonal Coding finds the regions or coefficients with the maximumVariance or information and keeps them while discarding the low entropyzones.

    The Zonal quantised coefiecients are coded in two possible ways1) same number of bits/coeff normalized by standard deviations and

    uniformly quantized.

  • 8/9/2019 Image Compression 2

    24/24

    Bit Allocation

    2) fixed No. of bits distributed unequally- the coefficents are modeled asrayleigh, gaussian , laplacian and the bitsallocated depend on the standard deviation.

    Threshold Coding uses a mask to quantize the coefficients with lowermagnitudes away. The coefficients that are retained are coded out ofsequence.

    Different ways of thresholding are

    1) to apply a global threshold2) to vary the threshold over the different positions of coefficients.3) N largest coefficients are retained .