Date post: | 03-Jan-2016 |
Category: |
Documents |
Upload: | destiny-hawkins |
View: | 33 times |
Download: | 6 times |
Chapter 8 – Compression
Aims: Outline the objectives of compression. Define the key methods used to compress data. Outline methods used to compress images, video
and audio.
Key factors in reducing the amount of data storage
• Getting rid of redundant data. This involves determining the parts of the data that are not required
• Identifying irrelevant data. This involves identifying the parts of the data which are perceived to be irrelevant.
• Converting the data into a different format. This will typically involve changing the way that the data is processed and stored
• Reducing the quality of the data. Often the user does not require the specified quality of the data.
RGB
0
16
32
48
64
80
96
112
128
144
160
176
192
208
224
240
256
0
16
32
48
64
80
96
112
128
144
160
176
192
208
224
240
256
0
16
32
48
64
80
96
112
128
144
160
176
192
208
224
240
256
Red Green Blue
0
16
32
48
64
80
96
112
128
144
160
176
192
208
224
240
256
0
16
32
48
64
80
96
112
128
144
160
176
192
208
224
240
256
0
16
32
48
64
80
96
112
128
144
160
176
192
208
224
240
256
Red Green Blue
#FF0000 (255,0,0)
#00FF00 (0,255,0)
#0000FF (0,0,255)
#FFFFFF (255,255,255)
#000000 (0,0,0)
#6496C8 (100,150,200)
#C89664 (200,150,100)
#64C896 (100,200,150)
Convertto Digital
Convertto Digital
MPEG-1or MPEG-2compression
MPEG-1or MPEG-2compression MPEG
movie
Convertto Digital
Convertto Digital
MPEG Audio(MP-3)
compression
MPEG Audio(MP-3)
compression MP-3sound file
WAV file
Convertto Digital
Convertto Digital
JPEG/GIFcompression
JPEG/GIFcompression JPEG/GIF
picture fileBMPfile
Red,Green,Blue
Compression reducesredundancy in the data
Convertto Digital
Convertto Digital
MPEG-1or MPEG-2compression
MPEG-1or MPEG-2compression MPEG
movie
Convertto Digital
Convertto Digital
MPEG Audio(MP-3)
compression
MPEG Audio(MP-3)
compression MP-3sound file
WAV file
Convertto Digital
Convertto Digital
JPEG/GIFcompression
JPEG/GIFcompression JPEG/GIF
picture fileBMPfile
Red,Green,Blue
Compression reducesredundancy in the data
Audio, image and video compression
• JPEG/GIF. The JPEG (Joint Photographic Expert Group) compression technique is well matched to what the human eye and the brain perceive.
• MPEG. MPEG (Motion Picture Experts Group) uses many techniques to reduce the size of the motion video data.
• MPEG (MP-3). The digital storage of audio allows for the data to be compressed.
Compression process
Data conversion
Animation
Sampling
Sound
VideoADC
Compression
DigitalStorage/
Transmission/Processing
DACFilter
DigitalStorage/
Transmission/Processing
Data conversion
Uncompression
Text
Compression/Data conversion
Uncompression/Data conversion
1011101010 1101
Error and number of conversion bits
Bits (N)
Quantization levels
Accuracy (%)
Bits (N)
Quantization levels
Accuracy (%)
1 2 25 8 256 0.2
2 4 12.5 12 4096 0.012
3 8 6.25 14 16384 0.003
4 16 3.125 16 65536 0.00076
N2
Scale Full.
2
1errorMax
Lossy and lossless compression
• Lossless compression. Where the data, once uncompressed, will be identical to the original uncompressed data. This will obviously be the case with computer-type data, such as data files, computer programs, and so on, as any loss of data may cause the file to be corrupted.
• Lossy compression. Where the data, once uncompressed, cannot be fully recovered. It normally involves analysing the data and determining which data has little effect on the perceived information.
Entropy and source coding
• Entropy coding. This does not take into account any of the characteristics of the data and treats all the bits in the same way. As it does not know which parts of the data can be lost, it produces lossless coding. Typical coding techniques are:– Statistical encoding. Analysing the occurrence and patterns
of data.– Suppressing repetitive sequences.
• Source encoding. This normally takes into account characteristics of the information.
Entropy coding
Normally, general data compression does not take into account the type of data which is being compressed and is lossless. As it is lossless it can be applied to computer data files, documents, images, and so on. The two main techniques are statistical coding and repetitive sequence suppression.
• Huffman. Huffman coding uses a variable length code for each of the elements within the data. This normally involves analysing the data to determine the probability of its elements. The most probable elements are coded with a few bits and the least probable coded with a greater number of bits. This could be done on a character-by-character basis, in a text file, or could be achieved on a byte-by-byte basis for other files.
• Lempel-Ziv. Around 1977, Abraham Lempel and Jacob Ziv developed the Lempel–Ziv class of adaptive dictionary data compression techniques (also known as LZ-77 coding), which are now some of the most popular compression techniques.
Huffman
Letter: ‘b’ ‘c’ ‘e’ ‘i’ ‘o’‘p’
No. of occurrences: 12 3 57 51 3320
‘e’ ‘i’ ‘o’ ‘p’ ‘b’ ‘c’57 51 33 20 12 3
‘e’ 57
‘i’ 51
‘o’ 33
‘p’ 20
‘b’ 12 [1]
‘c’ 3 [0]
‘e’ 57
‘i’ 51
‘o’ 33
‘p’ 20 [1]
15 [0]
‘e’ 57
‘i’ 57
35 [1]
‘o’ 33 [0]
68
‘e’ 57 [1]
‘i’ 51 [0]
108 [1]
68 [0]
‘e’ 11 ‘i’ 10‘o’ 00 ‘p’ 011‘b’ 0101 ‘c’ 0100
Huffman example (goals scored)
1 goal [34]
0 goals [21]
2 goals [15]
3 goals [14]
4 goals [5]
5 goals [2]
6 goals [1]
1
0
1 goal [34]
0 goals [21]
2 goals [15]
3 goals [14]
4 goals [5]
[3]
1
0
1 goal [34]
0 goals [21]
2 goals [15]
3 goals [14]
4 goals [8]
1 goal [34]
[22]
0 goals [21]
2 goals [15]1
0
1 goal [34]
[22]
0 goals [21]
2 goals [15]
[36]
1 goal [34]
[22]1
0
1
0
[56]
[36]
1
0Coding:0 goals 011 goal 112 goals 003 goals 1014 goals 10015 goals 100016 goals 10000
1 goal [34]
0 goals [21]
2 goals [15]
3 goals [14]
4 goals [5]
5 goals [2]
6 goals [1]
1
0
1 goal [34]
0 goals [21]
2 goals [15]
3 goals [14]
4 goals [5]
[3]
1
0
1 goal [34]
0 goals [21]
2 goals [15]
3 goals [14]
4 goals [8]
1 goal [34]
[22]
0 goals [21]
2 goals [15]1
0
1 goal [34]
[22]
0 goals [21]
2 goals [15]
[36]
1 goal [34]
[22]1
0
1
0
[56]
[36]
1
0Coding:0 goals 011 goal 112 goals 003 goals 1014 goals 10015 goals 100016 goals 10000
Huffman (cont.)
11000110100100110100
will be decoded as:
‘e’ ‘o’ ‘p’ ‘c’ ‘i’ ‘p’ ‘c’
‘e’ 11 ‘i’ 10‘o’ 00 ‘p’ 011‘b’ 0101 ‘c’ 0100
Lempel-Ziv
‘The receiver#9#3quires a#20#5pt for it. This is automatically sent wh#6#2 it #30#2#47#5ved.’
LZW
The Lempel–Ziv–Welsh (LZW) algorithm (also known LZ-78) builds a dictionary of frequently used groups of characters (or 8-bit binary values
A simple example is to use a six-character alphabet and a 16-entry dictionary, thus the resulting code word will have 4 bits. If the transmitted message is:
ababacdcdaaaaaaef
Then the transmitter and receiver would initially add the following to its dictionary:
0000 ‘a’ 0001 ‘b’0010 ‘c’ 0011 ‘d’0100 ‘e’ 0101 ‘f’0110–1111 empty
LZW (cont.)
0000 ‘a’ 0001 ‘b’0010 ‘c’ 0011 ‘d’0100 ‘e’ 0101 ‘f’0110–1111 empty
0000 ‘a’ 0001 ‘b’0010 ‘c’ 0011 ‘d’0100 ‘e’ 0101 ‘f’0110 ‘ab’ 0111–1111 empty
Statistical coding
• Statistical encoding is an entropy technique which identifies certain sequences within the data. These ‘patterns’ are then coded so that they have fewer bits. Frequently used patterns are coded with fewer bits than less common patterns. For example, text files normally contain many more ‘e’ characters than ‘z’ characters. Thus the ‘e’ character could be encoded with a few bits and the ‘z’ with many bits
a 00000
b 00001
c 00010
d 00011
e 00100
f 00101
g 00110
h 00111
i 01000
j 01001
k 01010
l 01011
m 01100
n 01101
o 01110
p 01111
q 10000
r 10001
s 10010
t 10011
u 10100
v 10101
w 10110
x 10111
y 11000
z 11001
SP 11010
a 01 b 1000
c 1010
d 100 e 0
f 0010
g 110 h 0000
i 00 j 0111
k 101 l 0100
m 11 n 10 o 111
p 0110
q 1101
r 010 s 000 t 1
u 001 v 0001
w 011 x 1001
y 1011
z 1100
SP 0011
Pure coding (example)
Morse coding
Repetitive character sequence suppression
• Repetitive sequence suppression involves representing long runs of a certain bit sequence with a special character. A special bit sequence is then used to represent that character, followed by the number of times it appears in sequence.
8.3200000000000
could be coded as:
8.32F11
where F is a special flag.
Source compression
• Source compression takes into account the type of information that is being compressed, and is typically used with image, video and audio information.
For example the following might be integer values for the samples:
321, 322, 324, 324, 320, 317, 310, 311
This could be coded as difference values as:
321, +1, +2, 0, –4, –3, –7, +1
Image compression
File Compression type
Max. resolutionor colours
TIFF
Huffman RLE and/or LZW
48-bit colour TIFF (tagged image file format) is typically used to transfer graphics from one computer system to another. It allows high resolutions and colours of up to 48 bits (16 bits for red, green and blue).
GIF LZW 65,563 65,536(24-bit colour, but only 256 displayable colours)
Standardized graphics file format which can be read by most graphics packages. It has similar graphics characteristics to PCX files and allows multiple images in a single file and interlaced graphics.
JPG JPEG compression(DCT, quantization and Huffman)
Depends on the compression
Excellent compression technique which produces lossy compression. It normally results in much greater compression than the methods outlined above.
Image compression
Type Size(B)
Compression (%)
BMP 308278 100.0 BMP, RBG encoded (640480, 256 colours)
BMP 301584 97.8 BMP, RLE encoded
GIF 124304 40.3 GIF, Version 89a, non-interlaced
GIF 127849 41.5 GIF, Version 89a, interlaced
TIF 136276 44.2 TIF, LZW compressed
TIF 81106 26.3 TIF, CCITT Group 3, MONOCHROME
JPG 28271 9.2 JPEG – JFIF Complaint (Standard coding)
JPG 26511 8.6 JPEG – JFIF Complaint (Progressive coding)
Type Size (B)
Compression (%)
BMP 750054
100.0 BMP, RBG encoded (500500, 16.7M colours)
BMP 7832 1.0 BMP, RLE encoded (256 colours)
PCX 31983 4.3 PCX, Version 5 (256 colours)
GIF 4585 0.6 GIF, Version 89a, non-interlaced (256 colours)
TIF 26072 3.5 TIF, LZW compressed (16.7M colours)
JPG 15800 2.1 JPEG (Standard coding, 16.7M colours)
JPG 12600 1.7 JPEG (Progressive coding, 16.7M colours)
Image witha good dealof repetition
Image witha good dealof changes
JPEG
• It is a compression technique for grey-scale or colour images and uses a combination of discrete cosine transform, quantization, run-length and Huffman coding.
The components are computed from the RGB components:
Y = 0.299R+0.587G+0.114BCb= 0.1687R–0.3313G+0.5BCr = 0.5R–0.4187G+0.0813B
F u v C u C v f x yx u y v
C z z
z
yx
( , ) ( ) ( ) ( , ) cos( )
cos( )
( )
1
4
2 1
16
2 1
16
1
20
1 0
0
7
0
7
where if
or if
MPEG
RGB to YUV
converter RGB to YUV
converter Block
matching Block
matching DCT transform
DCT transform Quantization Quantization Run
Length encoding
Run Length
encoding Huffman coding
Huffman coding
Images YUV Error terms
DCT terms
Quantized DCT terms
Zero suppressed
Variable length code
Reference frame
Reference frame
YUV
RGB to YUV
converter RGB to YUV
converter Block
matching Block
matching DCT transform
DCT transform Quantization Quantization Run
Length encoding
Run Length
encoding Huffman coding
Huffman coding
Images YUV Error terms
DCT terms
Quantized DCT terms
Zero suppressed
Variable length code
Reference frame
Reference frame
YUV
Segmentation
123456789101112131415161718
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
288 pixels
352 pixels
I, P and B-frames
• Intra frame (I-frame). An intra frame, or I-frame, is a complete image and does not require any extra information to be added to it to make it complete. As it is a complete frame, it cannot contain any motion estimation processing. It is typically used as a starting point for other referenced frames, and is usually the first frame to be sent.
• Predictive frame (P-frame). The predictive frame, or P-frame, uses the preceding I-frame as its reference and has motion estimation processing. Each macroblock in this frame is supplied as referenced to an I-frame as either a vector and difference, or if no match was found, as a completely encoded macroblock (called an intracoded macroblock). The decoder must thus retain all I-frame information to allow the P-frame to be decoded.
• Bidirectional frame (B-frame). The bidirectional frame, or B-frame, is similar to the P-frame except that it references frames to the nearest preceding or future I- or P-frame. When compressing the data, the motion estimation works on the future frame first, followed by the past frame. If this does not give a good match, an average of the two frames is used. If all else fails, the macroblock can be intracoded.
Audio compression
Digitized audio signal rate = 44.116 kbps = 705.6kbps
Sampler ADC
Storage/Transmission
Parallel-to-serial
Serial-to-parallel
Filter DAC
Phaselocked
loop (PLL)
Clockinformation
Audio outAudio out
Audio out
Clock
Serialbit stream