Image Coding Introduction

Image Coding
Introduction
„
„
What is image coding (compression)?
Image data can be compressed without
significant degradation of the visual
(perceptual) quality b/c image contain a
high degree of:
„
„
Spatial redundancy
Spectral redundancy Psycho-visual
redundancy
1
Why Standardization?
„
„
Compression is one of the technologies
that enable the multimedia revolution to
occur
However for technology to be effective
there has to be some degree of
standardization so that the equipment
designed by different vendors can talk to
each other
Type of still image compression
standards
„
(JPEG) Joint Photographic Experts
Group
„
„
„
„
„
Lossy compression of still images
Lossless compression of still images
(JBIG) Joint Bilevel Image Group
(GIF) Graphics Interchange Format. De
facto
(PNG) Portable Network Graphics. De
facto
2
JPEG-Background
„
„
„
„
„
„
JPEG = Joint Photographic Expert Group ,
Joint standards committee of ITU-T and ISO
Flexible standard for monochrome and color
image compression
Intraframe coding scheme, optimized for still
image
Flexible picture size
Variable compression ratio
Compression 24:1 for ITU-R 601 images
without loss of quality visually
JPEG-History
„
Since 1986, ITU and ISO called a joint
meeting to establish the standard for
multilevel color still image. In 1987 IEC
joined in.
„
Schedule
„
„
„
„
1988: select the DCT-based method
1988-1990: simulating, testing, and documenting
1991: draft
1992: international standard
3
JPEG
„
Official document
„
„
„
„
„
ISO/IEC 10918-1 (ITU-T Rec. T.81): Requirements and
guidelines
ISO/IEC 10918-2 (ITU Rec. T.83): Compliance testing
ISO/IEC 10918-3 (ITU-T Rec. T.84): Extensions
Also used to compress video frame by frame
(MJPEG)
Mode of operations:
„
„
„
„
Sequential DCT
Progressive DCT
Sequential Lossless
Hierarchical
Sequential v.s. Progressive
„
Sequential
„
„
„
Raster scan
left-to-right/top-to-bottom
Progressive
„
„
Multiple scan
Coarse-to-fine
4
JPEG : GOAL
„
„
„
„
„
„
Be as close as possible to the state of the art in
image compression
Allow applications to tradeoff easily between desired
compression ratio and image quality
Work independently of image types
Have modest computational complexity that would
allow software-only implementation even in low-end
computers
Allow both sequential (single scan) and progressive
(multiple scan) coding
Offers the option for hierarchical coding
5
Compression Scheme
„
„
Removal of redundancy based on
implicit assumption about the structure
in the data
Assignment of binary codewords to the
information deemed nonredundant.
Typical Image Compression
System
6
Transformer
„
„
Applies a one-to-one transformation to
the input image data
Output of the transformer is an image
representation which is more amenable
to efficient compression than the raw
image data
Quantizer
„
„
Generates a limited number of symbols
that can be used in the representation
of the compressed image
Quantization is a many-to-one mapping
which is irreversible
7
Coder
„
„
Coder assigns a cod word, a binary bit
stream , to each symbol at the output of
Quantization
Fixed-Length or Variable-Length codes.
VLC, also known as Entropy Coding
„
assigns a codeword in such a way as to
minimize the average length of the binary
representation of the symbols
Lossy Compression System
„
Lossy CS, which aim at obtaining the
best possible fidelity for a given bit-rate
(or minimizing the bit-rate to achieve a
given fidelity measure)
8
Lossless Compression
System
„
„
Lossless CS which aim at minimizing
the bit rate of the compressed output
without any distortion of the image
The decompressed bit-stream is
identical to original bit-stream
Basic Units of Encoder
9
JPEG Standard
„
JPEG refers to a wide variety of
possible image compression
approaches that have been collected to
a single standard that include:
„
„
„
Lossy component
Lossless component
Entropy coding
„
„
Huffman coding
Binary arithmetic coding
Huffman Coding
„
„
Huffman coding is based on the frequency of
the occurrence of a character (or a octet in
the case of images)
The principle is to use lower number of bits to
encode the character that occurs more
frequently. The codes are stored in a
codebook. The codebook maybe constructed
for every image or for a set of images.
10
Why JPEG is a common
standard?
„
„
„
„
JPEG allows multiple components for images.
Example color image.
It allows multiple components of a image to
be interleaved or noninterleaved.
JPEG defines sampling factors for the
horizontal and vertical dimensions of each
scan component
Individual portion of a image with multiple
components can be reconstructed with
minimum buffering
JPEG
„
„
Very popular image compression
Standard
JPEG
„
„
„
„
ISO/IEC
Joint Photographic Expert Group (JPEG)
International Standards committee
Compression ratio
„
1 MB image to approximate 50 KB (1:20)
11
Characteristics of JPEG
„
„
„
„
„
Lossy compression method
Not used for editing
Not good for compressing text or
graphics
Good for compressing photographs
Computationally intensive
Compression Modes
„
Sequential
„
„
„
„
Single scan
Huffman coding
Arithmetic coding
Progressive
Multiple scans
„ Used for networks
„ A rough idea about the image with small amount
of data
„
12
Compression Modes
„
Hierarchical
„
„
„
Similar to progressive
If low resolution is OK, there is no need to
down load the high resolution
Lossless
„
No reason to use because there are other
lossless ways to compress image.
Important Components
„
„
„
„
„
„
„
„
Color space (RGB->YCbCr)
Image is divided into 8x8 macro-blocks
DCT is applied to each macro-block
Quantization
Drop higher frequency coefficients
Entropy coding
Huffman coding
Write data in JFIF file (JPEG File Interchange
Format)
13
Compression
„
„
Higher frequency coefficients can be
ignored without sacrificing image
quality
Quality of compressed image is
acceptable
DCT Formula
„
DCT
„
IDCT
14
Effect of DCT and
Quantization
d
c
DCT
e
994
-49
149
58
-27
9
0
3
-34
17
35
8
5
41
2
-14
20
8
-37
-32
26
53
-1
-12
38
-17
-15
-3
6
8
-6
2
22
-4
1
-9
9
0
-2
-1
0
-1
3
-11
7
1
-3
-7
5
4
-1
2
8
-1
0
-5
-1
-2
-4
-4
0
2
1
-1
QUANTIZATION
(Step size = 30)
33
-2
5
2
-1
0
0
0
-1
1
1
0
0
1
0
0
1
0
-1
-1
1
2
0
0
1
-1
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
f
IQ, IDCT
Mean Square
Error = 38.75
DCT & IDCT
15
Average
16
Comments
„
„
„
„
By zeroing the last 4 values the
maximum error is 7 out of 255
Which is 2.7%
By compressing the data 50% we
introduce an error of 2.7%
Quality acceptable
YCbCr Color Mode
„
„
„
Y = 0.299*R + 0.587*G + 0.114*B
Cb = - 0.299*R - 0.587*G + 0.886*B
Cr = 0.701*R - 0.587*G - 0.114*B
17
JPEG Conversion Algorithm
„
„
„
Convert RGB to YCbCr
Divide image into 8x8 macro block
Compute the DCT of each macroblock
Quantization
„
Divide the DCT values such that many
values in the DCT becomes zero
18
Quantization Table
„
YQ50
Quantization Table
„
CbCrQ50
19
Image Macroblock
DCT
20
DCT Coefficients Divided by
Quantization Table
Discussion
„
„
A achieve higher compression at the
cost of lower image quality a different
table can be used
Table will contain higher numbers
21
YQ50 v.s. YQ30
An Example of JPEG Baseline
System
Original:
52
63
62
63
67
79
85
87
55
59
59
58
61
65
71
79
61 66 70 61
66 90 109 85
68 113 144 104
71 122 154 106
68 104 126 88
60 70 77 68
64 59 55 61
69 68 65 76
64
69
66
70
68
58
65
78
73
72
73
69
70
75
83
94
- 64
- 59
- 62
- 58
- 60
- 70
- 63
- 50
- 55
- 56
- 55
- 59
- 58
- 53
- 45
- 34
After level shift by -128:
- 76
- 65
- 66
- 65
- 61
- 49
- 43
- 41
- 73
- 69
- 69
- 70
- 67
- 63
- 57
- 49
- 67
- 62
- 60
- 57
- 60
- 68
- 64
- 59
- 62
- 38
- 15
-6
- 24
- 58
- 69
- 60
- 58
- 19
16
26
-2
- 51
- 73
- 63
- 67
- 43
- 24
- 22
- 40
- 65
- 67
- 52
22
An Example of JPEG Baseline
System
After DCT:
- 415 - 29 - 62 25 55 - 20 - 1 3
7 - 21 - 62
9 11 - 7 - 6 6
- 46
8 77 - 25 - 30 10 7 - 5
- 50 13 35 - 15 - 9
6 0 3
11 - 8 - 13 - 2 - 1
1 -4 1
- 10
1
3 -3 -1
0 2 -1
-4 -1
2 -1
2 -3 1 -2
-1 -1 -1 -2 -1 -1 0 -1
After quantization:
- 26
1
-3
-4
1
0
0
0
-3
-2
1
1
0
0
0
0
-6 2 2
-4 0 0
5 -1 -1
2 -1 0
0 0 0
0 0 0
0 0 0
0 0 0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
JPEG Quantization Map
23
Default Quantization Tables
Luminance Table:
16
12
14
14
18
24
49
72
11
12
13
17
22
35
64
92
10
14
16
22
37
55
78
95
16 24 40
19 26 58
24 40 57
29 51 87
56 68 109
64 81 104
87 103 121
98 112 100
18
21
26
66
99
99
99
99
24
26
56
99
99
99
99
99
47
66
99
99
99
99
99
99
51 61
60 55
69 56
80 62
103 77
113 92
120 101
103 99
Chrominance Table:
17
18
24
47
99
99
99
99
99
99
99
99
99
99
99
99
99
99
99
99
99
99
99
99
99
99
99
99
99
99
99
99
99
99
99
99
99
99
99
99
Quantization of DCT Coefficients
(a),(c),(e),
a),(c),(e), use the default
quantization matrix
(b),(d),(f)
b),(d),(f) use 4 times the
default quantization matrix
24
Zigzag Scan
„
„
Convert 2-D coefficients block to 1-D
coefficients
Scan order should be frequency
dependent for efficient run-length
coding
Zigzag Ordering
25
Zigzag Ordering
JPEG
„
„
„
„
„
„
Convert RGB to YCbCr
Divide image into 8x8 macroblock
Compute the DCT of each macroblock
Divide the DCT with the Quantization
Table
Apply Zigzag
Run length coding
26
JPEG Performance
Bits/pixel
Quality
Compression Ratio
>= 2
Indistinguishable
8-toto-1
1.5
Excellent
10.710.7-toto-1
0.75
Very Good
21.421.4-toto-1
0.5
Good
3232-toto-1
0.25
Fair
6464-toto-1
27
Motion JPEG
„
„
„
Code a video sequence as a series of
JPEG images, each corresponding to
one frame of video (intra-coded frame)
No attempt is made to exploit the
inherent temporal redundancy in a
moving video sequence
Poor compression compared with interframe CODEC
Motion JPEG
„
„
„
„
Low Complexity
Error Tolerance
Market Awareness
Suitable for high-bandwidth
communications
28