Anda di halaman 1dari 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 has
grown exponentially over the decades. High-quality image
data requires large amounts of storage space and
transmission bandwidth, something which the current
technology is unable to handle technically and economically.
One of the possible solutions to this problem is to compress
the information so that the storage space and transmission
time can be reduced.
Error-Free Compression
The simplest approach to error-free image compression
is to reduce only coding redundancy. Coding redundancy
normally is present in any natural binary encoding of the
gray levels in an image. To do so requires construction of a
variable-length code that assigns the shortest possible code
words to the most probable gray levels.
Lossless compression
lossless compression for legal and medical
documents, computer programs.
exploit only code and inter-pixel redundancy.
Lossy compression
digital image and video where some errors or loss can
be tolerated.
exploit both code and inter-pixel redundancy and
sycho-visual perception properties.

Huffman Coding

Variable length code whose length is inversely proportional


to that characters frequency.

must satisfy non-prefix property to be uniquely decodable.

two pass algorithm


first pass accumulates the character frequency and
generate 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 their
frequencies.
3. remove the two free nodes and add the newly created
parent node to the list of free nodes.
4. repeat step2 and 3 until there is one free node left. It
becomes the root of tree.
Huffman Coding (Optimal Coding) -
Huffman Source reductions

Huffman Code assignment Procedure
Coding Efficiency = 0.973
symbol bits entropy
symbol bits
L
avg
/ 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
k r k avg
r p r l L



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 of
information units required to represent the interval
becomes larger.

Ex: a five-symbol sequence



Arithmetic coding Procedure

Arithmetic Coding Example

take in complete data stream and output one specific


codeword which is floating point number between 0
and 1.

two pass algorithm:


* first pass computes characters frequency and
constructs probability table with ranges assigned to
each entry of the table.
* second pass does actual compression
first character of input stream constrains output
number to its corresponding range, and the range
of next character of input stream further constrains
the number, and so on.

decoding is reverse of encoding.

achieve higher compression ratio than Huffman, but


computationally expensive.

LZW Coding (Lempel-Ziv-Welch)

Assign fixed-length code words to variable length


sequence of source symbols.

Requires no a priori knowledge of the probabilities of


occurrence 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 dictionary
are placed in algorithmically determined locations.
Unique feature: coding dictionary or code book is
created while the data are being encoded.
LZW decoder builds an identical decompress dictionary
as it decides simultaneously the encoded data
stream.
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

A 512- word dictionary with the following starting content is
assumed:
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
0
1
.
.
.
255
256
.
.
511
0
1
.
.
.
255
----
.
.
----

If the concatenated sequence is not found, the address of
the currently recognized sequence is output as the next
encoded value.
Nine additional code words are defined. At the end, the
dictionary contains 265 code words and the LZW algorithm
has successfully identified several repeating gray-level
sequences-reduce the 128 bit image (16 pixels x 8-bit) to 90
bits (10 code-words x 9bits).
The encoded output is obtained by reading the third column
from top to bottom. The resulting compression ratio 1.42:1.
(i.e. 128 bits /90 bits = 1.42).

Bit-Plane Coding

Reduce an images inter-pixel redundancy by processing


the images bit planes individually.

decompose a multilevel image into a series of binary


images and compress each binary image via one of several
well-known binary compression method.

represent gray-level image in the form of base 2


polynomial.

the small gray level variations problem (i.e. small changes


in gray levels affect all m bit planes)a pixel with intensity
127 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 changes
are less likely to affect all m bit planes).

Gray code bit planes are less complex than corresponding


binary bit planes

Gray code for 127 and 128 : 127(11000000) and


128(01000000) .

Binary code for 127 and 128 : 127(01111111) and


128(10000000) .
1 1
1
0 1 2 1
0
0
2
2
1
1
2 0
:
2 2 2 :

+


+ + +
m m
l l l
m m
m
m
m
m
a g
m l a a g
g g g g code Gray
a a a scale gray bit m




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 separately
using variable-length coding based on statistics. The
approximate run-length entropy is
Where 'H
0
' is the entropy of black run-length source and 'H
1
'
is the entropy of white runs. The variables 'L
0
' and 'L
1
' denote
the average values of black and white run lengths
respectively.
Additional compression can be realized by variable
length coding the run lengths, The above equation provides
an estimate of the average number of bits per pixel required
to encode the run length.
1 0
1 0
L L
H H
H
RL
+
+


Two-dimensional run-length coding -RAC (Relative address
coding)
Track the binary transition that begin and end each black
and white run. Require the adoption for a convention for
determining run values.

Lossy Compresssion
Lossy encoding is based on the concept of compromising
the accuracy of the reconstructed image in exchange for
increased compression.
Lossy encoding is based on the concept of compromising
the accuracy of the reconstructed image in exchange for
increased compression.
Lossy Compression:
1. Spatial domain methods
2. 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 as
possible into the smallest number of transform coefficients .
(1) Adaptive transform coding: adaptive to local content
(2) Non-adaptive transform coding: fixed for sub-image

Depend on the reconstruction error that can be tolerated and
the computational resources available,
Include Discrete and inverse discrete transform
Fourier
Walsh-Hadmard
Discrete cosine transform
Most transform coding systems are based on the DCT
for its information packing ability and computational
complexity.
Forward kernel is Separable if:
Forward kernel is Symmetric if:
1 , , 1 , 0 , ) , , , ( ) , ( ) , (
1 , , 1 , 0 , ) , , , ( ) , ( ) , (
1
0
1
0
1
0
1
0



N y x v u y x h v u T y x f
N v u v u y x g y x f v u T
N
u
N
v
N
u
N
v

) , ( ). , ( ) , , , (
2 1
v y g u x g v u y x g
) , ( ). , ( ) , , , (
1 1 2 1
v y g u x g v u y x g g g
N vy ux j
N vy ux j
e v u y x h
e
N
v u y x g
/ ) ( 2
/ ) ( 2
) , , , (
1
) , , , (
+
+


Walsh-Hadamard Transform (WHT):
Discrete Cosin Transform (DCT):
Steps Involved In Transform based Coding
1. Dividing the image into sub-images of size 8x8
2. Representing each sub-image using one of the transforms
3. Truncating 50% of the resulting coefficients
4. Taking the inverse Transform of the truncated coefficients

'

]
]
]

+
]
]
]

1 , , 2 , 1
2
0
1
) (
2
) 1 2 (
cos
2
) 1 2 (
cos ) ( ) (
) , , , ( ) , , , (
N u for
N
u for
N
u where
N
v y
N
u x
v u
v u y x h v u y x g




DFT
r mse=1.28
WHT
r mse=0.86
DCT
r mse=0.68

DCT Advantages:
1. Implemented in a single integrated circuit (IC)
2. Packing the most information into the fewest
coefficients
3. Minimizing the block-like appearance (blocking
artifact).
Sub-image size selection
Images are subdivided so that the correlation
between sub-image is reduced to some acceptable
level.
As sub-image size increase, the level of
compression and computational complexity increase.

Bit allocation
Reconstruction error depends on the number and
relative importance of the transformed coefficients
that are discarded, as well as the precision.
the process of truncating, quantizing, and coding the
coefficients of a transformed image:
Zonal coding: the retained coefficients are selected
based on maximum variance
Thresholding 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 / coefficient
Coefficients are normalized by their standard deviations and
uniformly quantized.
*Fixed number of bits is distributed among the coefficients
unequally.
* A quantizer such as an optimal Lloyed-Max is designed for
each coeff.:
- DC coeff. Is modeled by Rayleigh density func.
- The remaining coeff. Are modeled by Laplcian
or Gaussian.
(2) Threshold coding
Single global threshold
Different threshold for each subimage (N-Largest coding)
Threshold can be varied as a function of the location of
each coeff.


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

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

Like transform coding, wavelets pack most of the
important visual information into a small number of
coefficients, the remaining coefficients can be quantized
coarsely 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 the
final symbol coding step. Decoding is accomplished by
inverting the encoding operations with the exception of
quantization, which cannot be reversed exactly.
The principal difference between the wavelet-based
system and the transform coding system is the omission of
the transform encoder's subimage processing stages.
Because wavelet transforms are both computationally
efficient and inherently local.
Wavelet selection impact directly the computational
complexity of the transforms and the system's ability to
compress and reconstruct images of acceptable error. The
mostly widely used expansion functions for wavelet-based
compression are the Daubechies wavelets and biorthogonal
wavelets.
Decomposition level selection is the another factor
affecting wavelet coding computational complexity and
reconstruction error. Since a P-scale fast wavelet transform
involves 'P' filter bank iterations, the number of operations in
the computation of the forward and inverse transforms
increases with number of decomposition levels.

Wavelet Selection
Table: Wavelet transform filter taps and zeroed coefficients
when the wavelet transforms below 1.5
Decomposition Level Selection
Table:Decomposition Level impact on wavelet coding the
512x512 image.

Anda mungkin juga menyukai