Sie sind auf Seite 1von 63

x =150

x =149
e = x x =
1

Lossy compression
Lossless compression usually gives a maximum
compression of 3:1 (for monochrome images)
Lossy compression can give compression up to 100:1
(for recognizable monochrome images) 50:1 for virtually
indistinguishable images
The popular JPEG (Joint Photographic Experts Group)
format uses lossy transform-based compression.

Delta Modulation (DM)


The basic idea in delta modulation is to
approximate the derivative of analog
signal rather than its amplitude.
The analog data is approximated by a
staircase function that moves up or down
by one quantization level at each sampling
time. output of DM is a single bit.
PCM preferred because of better SNR
characteristics.
Networks: Data Encoding

22

Delta Modulation

Networks: Data Encoding

DCC 6th Ed. W.Stallings

23

TRANSFORM CODING
A linear, reversible transform (such as the Fourier
transform) is used to map the image into a set of
transform co-efficients, which are then quantized and
coded.
For most natural images, a significant number of (high
frequency) coefficients have small magnitudes and can be
coarsely quantized with little image distortion
Other than the DFT, we have the Discrete Cosine
Transform (used in JPEG) and the Walsh Hadamard
Transform

Transform coding constitutes an integral


component of contemporary image/video
processing applications.
Transform coding relies on the premise that pixels
in an image exhibit a certain level of correlation
with their neighboring pixels.
Similarly in a video transmission system,
adjacent pixels in consecutive frames show very
high correlation.
Consequently, these correlations can be exploited
to predict the value of a pixel from its respective
neighbors.
A transformation is, therefore, defined to map

Energy Compaction
Efficacy of a transformation scheme can be
directly gauged by its ability to pack input
data into as few coefficients as possible.
This allows the quantizer to discard
coefficients with relatively small amplitudes
without introducing visual distortion in the
reconstructed image.
DCT exhibits excellent energy compaction for
highly correlated images.

The JPEG Standard


JPEG is an image compression
standard which was accepted as an
international standard in 1992.
Developed by the Joint Photographic
Expert Group of the ISO/IEC
For coding and compression of
color/gray scale images
Yields acceptable compression in the
10:1 range

The JPEG Standard


JPEG is a lossy compression
technique
Based on the DCT
JPEG is a general image compression
technique independent of

Image resolution
Image and pixel aspect ratio
Color system
Image compexity

A scheme for video compression based


on JPEG called Motion JPEG (MJPEG)
exists

The JPEG Standard


JPEG is effective because of the
following three observations
Image data usually changes slowly
across an image, especially within an
8x8 block
Therefore images contain much redundancy

Experiments indicate that humans are


not very sensitive to the high frequency
data images
Therefore we can remove much of this data
using transform coding

The JPEG Standard


Humans are much more sensitive to
brightness (luminance) information
than to color (chrominance)
JPEG uses chroma subsampling (4:2:0)

The following slide gives an overview


of the various steps in JPEG
compression

JPEG Encoding Overview

chroma subsampling

YPbPr analog component video


Main article: YPbPr
YPbPr component video out on a consumer electronics device.
Further types of component analog video signals do not use R, G, and B
components but rather a colorless component, termed luma, which provides
brightness information (as in black-and-white video). This combines with one or
more color-carrying components, termed chroma, that give only color information.
Both the S-Video component video output (two separate signals) and the YPbPr
component video output (three separate signals) seen on DVD players are
examples of this method.
Converting video into luma and chroma allows for chroma subsampling, a method
used by JPEG images and DVD players to reduce the storage requirements for
images and video. The YPbPr scheme is usually what is meant when people talk of
component video today. Many consumer DVD players, high-definition displays,
video projectors and other video devices use this form of color coding.
These connections are commonly and mistakenly labeled with terms like "YUV",
"Y/R-Y/B-Y" and Y, B-Y, R-Y. This is inaccurate since YUV, YPbPr, and Y B-Y R-Y differ in
their scale factors.[3]

JPEG:
Joint Photographic Experts Group
Step 1: block preparation,
Step 2: DCT (Discrete Cosine Transform)
transformation
Step 3: quantization,
Entropy Coding
Step 4: further compression via differential
compression,
Step 5: zig-zag scanning and run-length
coding compression,
Step 6: Huffman coding compression
9/1/16

42

Step 1: Block Preparation

9/1/16

43

Step 2: DCT Transformation

9/1/16

44

Step 2: DCT Transformation


P-matrix
20 30 40 50

30 40 50 60
40 50 60 70
50 60 70 80
60 70 80 90

T-matrix
60 720 -182 0 -19 0
70 -182 0
0
80 0
0
0
90 -19
0 0
100 0
0

0
0
0
0

0
0
0
0 0

Step 2: DCT Transformation


(0,0) Coefficient is DC Coefficient
(represents brightness)
Other (i,j) coordinates are AC
Coefficients represent color
information

Step 2: DCT Transformation


Case 1: all Ps are same => image of
single color with no variation at all,
AC coefficients are all zeros.
Case 2: little variation in Ps =>
many, not all, AC coefficients are
zeros.
Case 3: large variation in Ps => a
few AC coefficients are zeros.

Step 2: DCT Transformation


P-matrix
T-matrix
20 30 40 50 60 720 -182 0 -19 0

30 40 50 60 70 -182 0
0 0 0
40 50 60 70 80 0
0
0 0 0
50 60 70 80 90 -19
0 0 0 0
60 70 80 90 100 0
0 0 0 0

Uniform color change and little fine


detail, easier to compress after DCT

Step 2: DCT Transformation


P-matrix T-matrix
100 150 50 100 100 835 15 -17 59
5
200 10 110 20 200 46 -60 -36 11 14
10 200 130 30 200 -32 -9 130 105 -37
100 10 90 190 120 59 -3 27 -12 30
10 200 200 120 90 50 -71 -24 -56 -40
. .
Large color change, difficult to compress
after DCT

Step 3: Quantization
Quantization: Provides a way of
ignoring small differences in an
image that may not be perceptible.

Step 3: Quantization

Computation of the quantized DCT coefficients


LOSSY COMPRESSION
(0,0) Coefficient is DC Coefficient (represents brightness
Other (i,j) coordinates are AC Coefficients (represent
color information
9/1/16

52

Quantization
Quantization in JPEG aims at
reducing the total number of bits in
the compressed image
Divide each entry in the frequency
space block by an integer, then round
Use a quantization matrix Q(u, v)

Quantization
Use larger entries in Q for the higher
spatial frequencies
These are entries to the lower right part
of the matrix
The following slide shows the default
Q(u, v) values for luminance and
chrominance
Based on psychophysical studies intended to
maximize compression ratios while
minimizing perceptual distortion
Since after division the entries are smaller,
we can use fewer bits to encode them

Quantization

Quantization
Can we recover by multiplying the
elements with 10?
If the loss is minimal, the vision
system may not notice.
Dividing T-elements by the same
number is not practical, may result in
too much loss.
Retain the effects of lower spatial
frequencies as much as possible
less subtle features noticed if

Quantization
Upper left elements to be divided
with smaller values
Lower right elements higher spatial
frequencies, finer details - to be
divided with larger values

Quantization
Multiple quantization matrices can be
used (perhaps by scaling the
defaults), allowing the user to choose
how much compression to use
Trades off quality vs. compression ratio
More compression means larger entries
in Q

Compression ratios

An example of JPEG coding and


decoding on one image block is
shown next

Original and DCT coded


block

Quantized and Reconstructed


Blocks

Step 4: Differential Compression for DC


DCT Coefficients
Differential compression means
we consider similar blocks in the image
and encode only the first block and for
the rest of the similar blocks, we encode
only differences between the previous
block and current block.

9/1/16

63

Coding of DC Coefficients
Now we handle the DC coefficients
1 DC per block
DC coefficients may vary greatly over
the whole image, but slowly from one
block to its neighbor (once again, zigzag
order)
So apply Differential Pulse Code
Modulation (DPCM) for the DC
coefficients
If the first five DC coefficients are 150,
155, 149, 152, 144, we come up with
DPCM code- 150, 5, -6, 3, -8

Step 5: Zig-Zag Organization


(from matrix to vector)

9/1/16

65

Run-Length Coding
We now do run-length coding
The AC and DC components are treated
differently
Since after quantization we have many 0
AC components, RLC is a good idea
Note that most of the zero components
are towards the lower right corner (high
spatial frequencies)
To take advantage of this, use zigzag
scanning to create a 64-vector

Zigzag Scan in JPEG

Run-Length Coding
Now the RLC step replaces values in a 64vector (previously an 8x8 block) by a pair
(RUNLENGTH, VALUE), where RUNLENGTH
is the number of zeroes in the run and
VALUE is the next non-zero value
From the first example we have (32, 6, -1, -1,
0, -1, 0, 0, 0, -1, 0, 0, 1, 0, 0, , 0)
This becomes (0,6) (0,-1) (0,-1)(1,-1)(3,-1)(2,1)
(0,0) - Note that DC coefficient is ignored

Run-Length Coding

Step 6: Huffman Coding


Take the Zig-zag vector, apply RLE
and then apply Huffman coding on
the values in the vector

9/1/16

70

JPEG compression

DCT(x128)

Zig-Zag Scan

JPEG
file

Entropy Coding

Quantizatio
n

JPEG Encoding Overview

Das könnte Ihnen auch gefallen