0% found this document useful (0 votes)
16 views

Module 5-Img

1) Image compression reduces the amount of data required to represent an image by removing redundant data. There are three main types of redundancy: coding, spatial/temporal, and irrelevant information. 2) An image compression system uses an encoder to compress an input image into a smaller representation, and a decoder to decompress the compressed image back into a reconstructed output image. 3) Common compression methods include Huffman coding, arithmetic coding, LZW coding, and run-length coding, which aim to reduce coding and interpixel redundancies through variable-length coding or predicting neighboring pixel values.

Uploaded by

DEVID ROY
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views

Module 5-Img

1) Image compression reduces the amount of data required to represent an image by removing redundant data. There are three main types of redundancy: coding, spatial/temporal, and irrelevant information. 2) An image compression system uses an encoder to compress an input image into a smaller representation, and a decoder to decompress the compressed image back into a reconstructed output image. 3) Common compression methods include Huffman coding, arithmetic coding, LZW coding, and run-length coding, which aim to reduce coding and interpixel redundancies through variable-length coding or predicting neighboring pixel values.

Uploaded by

DEVID ROY
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

1 IMAGE COMPRESSION Module 5

Module 5
IMAGE COMPRESSION
Image compression is the art and science of reducing amount of data required to represent
an image. Image compression is used in many applications like televideo conferencing, remote
sensing, document and medical imaging, and facsimile transmission (FAX).

Fundamentals:

The data compression refers to the process of reducing the amount of data required to
represent a given quantity of information. Here data and information are not the same, data are
the mean by which information is conveyed and various amounts of data can be used to represent
the same amount of information. The data can have irrelevant or repeated information are called
redundant data.

If we let b and b’ denote the number of bits in two representations of the same
information, the relative data redundancy R of the representation with b bits is

R = 1 – 1/C

Where C, commonly called the compression ratio, is defined as

C = b/b’

The principle types of data redundancy that can be identified as:

1. Coding redundancy: A code is a system of symbols used to represent a body of


information or set of events. Each piece of information or event is assigned a sequence of
code symbols, called a code word. The number of symbols in each code word is its

| |
2 IMAGE COMPRESSION Module 5

length. The 8-bit codes that are used to represent the intensities in most 2-D intensity
arrays contain more bits than are needed to represent the intensities.
2. Spatial and temporal redundancy: Because the pixels of most 2-D intensity arrays are
correlated specially,(i.e. each pixel is similar to or dependent on neighboring pixels
Information is unnecessarily replicated in the representations of the correlated pixels. In a
video sequence, temporally correlated pixels also duplicate information
3. Irrelevant information: Most 2-D intensity arrays contain information that is ignored by
human visual system and/or extraneous to the intended use of the image. It is redundant
in the sense that it is not used.

Coding Redundancy
Let us assume, that a discrete random variable rk in the interval [0,L-1] represent the gray
level of an M x N image and that each rk occurs with probabilities pr(rk):
Pr (rk) = nk / MN k=0,1,2,3…L-1.
Where L is the number of intensity values, and nk is the number of times that the kth intensity
appears in the image. If the number of bits used to represent each value of rk is l(rk), then the
average number of bits required to represent each pixel:

The total number bits required to code an MxN image:

| |
3 IMAGE COMPRESSION Module 5

Interpixel redundancy
Interpixel redundancy is defined as failure to identify and utilize data relationships
If a pixel value can be reasonably predicted from its neighboring (or preceeding / following)
pixels the image is said to contain interpixel redundancy. Interpixel redundancy depends on the
resolution of the image The higher the (spatial) resolution of an image, the more probable it is
that two neighboring pixels will depict the same object. The higher the frame rate in a video
stream, the more probable it is that the corresponding pixel in the following frame will depict the
same object these types of predictions are made more difficult by the presence of noise

Image Compression Model


The following figure shows an image compression system is composed of two distinct
functional components: an encoder and decoder. The encoder performs compression and
decoder performs the complementary operation of decompression. Both operations can be
performed in software.
Input image is fed into the encoder, which creates a compressed representation of the
input. When the compressed representation is presented to its complementary decoder, a
reconstructed image is generated.

| |
4 IMAGE COMPRESSION Module 5

 Mapper - transforms the image to a (non-visual) format designed to reduce interpixel


redundancies. The operation generally is reversible and may or may not reduce directly
the amount of data required to represent the image. In video applications, the mapper uses
previous video frames to facilitate the removal of temporal redundancy.
 Quantizer - reduces psychovisual redundancies by quantizing data deemed less
important for visual interpretation (omitted for lossless compression)
 Symbol encoder - codes the data efficiently (typically using some form of variable-
length coding scheme) and aims to reduce coding redundancies. It generates a fixed or
variable length code to represent the quantizer output and maps the output in accordance
with the code. In many cases, a variable –length code is used. The shortest code words
are assigned to the most frequently occurring quantizer output values- thus minimizing
coding redundancy.
• Future application requirements may be unknown

Some Basic Compression Methods


Huffman coding
Provides a data representation with the smallest possible number of code symbols per
source symbol (when coding the symbols of an information source individually)
Huffman code construction is done in two steps

| |
5 IMAGE COMPRESSION Module 5

1. Source reductions: Create a series of source reductions by ordering the probabilities


of the symbols and then combine the symbols of lowest probability to form new
symbols recursively. This step is sometimes referred to as “building a Huffman tree”
and can be done statistically

Figure: Huffman source reduction

2. Code assignment: When only two symbols remain, retrace the steps in 1) and assign a
code bit to the symbols in each step. Encoding and decoding is done using these
codes in a lookup table manner

Figure: Huffman code assignment procedure

The average length of this code is: Lavg = (0.4)(1) + (0.3)(3) + (0.1)(4) + (0.06)(5) + (0.04)(5)
=2.2bits/pixels

Arithmetic coding
Provides a data representation where the entire symbol sequence is encoded as a single
arithmetic code word (which is represented as an interval of real numbers between 0 and 1)
Arithmetic code construction is done in 3 steps
1. Subdivide the half-open interval [0,1) based on the probabilities of the source symbols

| |
6 IMAGE COMPRESSION Module 5

2. For each source symbol recursively. Narrow the interval to the sub-interval designated by
the encoded symbol. Subdivide the new interval among the source symbols based on
probability
3. Append an end-of-message indicator. Encoding is done by choosing any number in the
interval to represent the data. Decoding is done by retracing the steps in the code
construction

Figure : Arithmetic coding procedure.

Figure : Arithmetic coding example.

Lempel-Ziv-Welch (LZW) coding


Provides a data representation where fixed-length code words are assigned to variable
length sequences of source symbols. LZW reduces both coding redundancies as well as
interpixel redundancies and requires no knowledge of the source symbol probabilities. LZW
code construction is done by constructing a dictionary which translates encountered source
symbol sequences to code symbols. This dictionary is created as the data stream is being
processed and can be flushed (reinitialized) when it is full or when coding ratios decline. The

| |
7 IMAGE COMPRESSION Module 5

size of the dictionary affects compression performance. Small dictionaries are less likely to
contain an encountered source symbol. Large dictionaries results in larger code words (lower
compression ratios)

Figure : LZW coing example

Run-length coding
Provides a data representation where sequences of symbol values of the same value are
coded as “run-lengths”
• 1D – the image is treated as a row-by-row array of pixels
• 2D – blocks of pixels are viewed as source symbols
Input data 222222222226666666666666699999999999999999

| |
8 IMAGE COMPRESSION Module 5

Code 2,11 6,14 9,17


Here compression is achieved by eliminating a simple form of spatial redundancy –
groups of identical intensities. When there are few runs of identical pixels, run length encoding
results in data expansion. The BMP file format uses a form of rum-length encoding In which
image data is represented in two different modes :
1. Encoded mode – A two byte RLE representation is used. The first byte specifies the
number of consecutive pixels that have the color index contained in the second byte. The
8 bit color index selects the run’s intensity from a table of 256 possible intensities.
2. Absolute mode – The first byte here is 0 and the second byte signals one of four possible
conditions, as shown in below table.

Figure : BMP absolute coding mode options. In this mode, the first byte of the BMP pair is 0

Transform Coding
In transform coding a linear transform is used to map the image data into a set of
transform coefficients (which are then quantized and coded). For reasons of computational
complexity the image is subdivided into smaller subimages before the transformation
computation. The goal of the transformation process is to decorrelate (minimize the variance)
the pixels of the subimages as much as possible. This will result in a localization of the image
information in a minimal number of transform coefficients - the transformation coefficients with
little data can then be more coarsely quantized or eliminated. The better information compaction,
the better reconstruction approximations.
The following figure shows a typical block transform coding system. The decoder
implements the inverse sequence of steps of the encoder, which performs four relatively
straightforward operations: subimage decomposition, transformation, quantization, and coding.
M x N input image is subdivided first into subimages of size n X n, which are then transformed
to generate MN/n2 subimage transform arrays, each of size n X n. The quatization stage then

| |
9 IMAGE COMPRESSION Module 5

selectively eliminates or more coarsely quantizes the coefficients that carry the least amount of
information in a predefined sense. The encoding process terminates by coding the quantized
coefficients. Transformation coding can be
• Adaptive – each subimage is treated in an individual manner
• Non-adaptive – all subimages are treated in the same way

Figure : A block transform coding system i. encoder ii. Decoder.

Subimage size selection


Both transform coding reconstruction error and computational complexity are functions
of the subimage size. Usually a (integer power of two) size is chosen that will reduce the
correlation. The following figure illustrates the graphically the impact of subimage size on
transform coding reconstruction error. between adjacent subimages in the reconstructed image.

Bit allocation
The process of truncating, quantizing and coding the coefficients of the transformed
subimage is referred to as bit allocation. The reconstruction error in a decompressed image is a
function of
• The number of coefficients discarded
• The precision used to store the remaining coefficients
• The relative importance of these coefficients

| |
10 IMAGE COMPRESSION Module 5

Most transform coding systems select which coefficients to retain


• On the basis of maximum variance – zonal coding
• On the basis of maximum magnitude – threshold coding
Zonal coding - transform coefficients are selected using a fix filter mask, which has been
formed to fit the maximum variance of an average image. Knowing which
transform coefficients that are going to be retained makes it possible to
optimize the transform computation – only the selectedtransform
coefficients need to be computed.
Threshold coding - coefficients are selected with respect to their magnitude. There are several
ways of implementing threshold coding
• Global thresholding – use the same (global) threshold value for all
images
• Adaptive thresholding – the threshold value is based on the coefficients
• Local thresholding – the threshold value is based on the location of the
coeff
• N-largest – the N largest coefficients are retained (requires ordering)
Note that some thresholding coding schemes result in a predefined reconstruction error rather
than a specified compression rate

| |
11 IMAGE COMPRESSION Module 5

Predictive coding
Provides a data representation where code words express source symbol deviations from
predicted values (usually values of neighboring pixels). Predictive coding efficiently reduces
interpixel redundancies
• 1D & 2D – pixels are predicted from neighboring pixels
• 3D – pixels are predicted between frames as well
Works well for all images with a high degree of interpixel redundancies. Works in the presence
of noise (just not as efficiently)
Input data 222222222226666666666666699999999999999999
Code 200000000004000000000000030000000000000000
Predictive coding can be used in both lossless and lossy compression schemes

Lossless predictive coding


The following figure shows the basic components of lossless predictive coding system.
The system consist of an encoder and decoder, each containing an identical predictor. As
successive samples of discrete time input signal, f(n), are introduced to the encoder, the predictor
generates the anticipated value of each sample based on a specified number of past samples. The
output of the predictor is then rounded to the nearest integer, The prediction error

Figure : A lossless predictive coding model: i. encoder ii. Decoder.

| |
12 IMAGE COMPRESSION Module 5

The decoder shown in second part of the figure reconstruct e(n) from the received
variable-length code words and performs the inverse operation to decompress or recreate the
original input sequence.

Lossy predictive coding


In this lossy predictive coding, we add quantizer to the lossless predictive coding model
introduced earlier and examine the trade –off between reconstruction accuracy and compression
performance within the context of spatial predictors.
As it shown in following figure the quantizer, which replaces the nearest integer function
of the error-free encoder, is inserted between the symbol encoder and the point at which the
prediction error is formed. It maps the prediction error into a limited range of outputs, denoted
e(n) , which establish the amount of compression and distortion that occurs. For a lossy
encoder’s predictor within the feedback loop,

The second part of the figure shows the lossy decoder.

Figure : A lossy predictive coding model: i. encoder ii. Decoder

| |
13 IMAGE COMPRESSION Module 5

Wavelet coding
Like transform coding, wavelet coding is based on the premise that using a linear
transform (here a wavelet transform) will result in transform coefficients that can be stored more
efficiently than the pixels themselves. Due to the facts that wavelets are computationally efficient
and that the wavelet basis functions are limited in duration, subdivision of the original image is
Unnecessary. Wavelet coding typically produces a more efficient compression than DCTbased
systems
• Objectively – the mean square error of wavelet-based reconstructions are typically
lower
• Subjectively - the blocking artifacts (characteristic of DCT-based systems at high
compression ratios) are not present in wavelet reconstructions
The choice of wavelet to use greatly affects the compression efficiency

Figure : A wavelet coding system i. Encoder ii. Decoder

| |
14 IMAGE COMPRESSION Module 5

| |

You might also like