1 M. Carli - 2005 Image Compression Image Compression But life is short and information endless... Abbreviation is a necessary evil and the abbreviator’s business is to make the best of a job which, although intrinsically bad, is still better than nothing. Aldous Huxley M. Carli - 2005 Image Compression • Reduction of the amount of data ⇒ removal removal of redundant data of redundant data • Math.: Transforming a 2-D pixel array into a statistically uncorrelated data set What’s Image Compression?
47
Embed
CM 05 Image compression - Comlab · Image Compression • • In digital image compression there exist three basic data redundancies: 1. Coding redundancy 2. Interpixel redundancy
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
1
M. Carli - 2005
Image Compression
Image Compression
But life is short and information endless...Abbreviation is a necessary evil and the abbreviator’s business is to make the best of a job which, although intrinsically bad, is still better than nothing.
Aldous Huxley
M. Carli - 2005
Image Compression
• Reduction of the amount of data ⇒ removal removal of redundant dataof redundant data
• Math.: Transforming a 2-D pixel array into a statistically uncorrelated data set
What’s Image Compression?
2
M. Carli - 2005
Image Compression
• Important in data storagedata storage and data transmissiondata transmission• Examples:
– Progressive transmission of images/videos (Internet)– Video coding (HDTV, teleconferencing)– Digital libraries and image databases– Remote sensing– Medical imaging
Why Compression?
M. Carli - 2005
Image Compression
Digital image
• A digital image is a two-dimensional sequence of samples
• Color images: three values per sample location, (red, green and blue)
xr [n1, n2], xg[n1, n2] xb[n1, n2]
4
M. Carli - 2005
Image Compression
• A color image represented with 8 bits/channel/pixel requires
• With a compression standard like JPEG, it is possible to represent it with a much smaller number of bits!
Example: JPEG Standard
500 500×
500 500 8 3 6M bits× × × =
M. Carli - 2005
Image Compression
• Compression techniques
•• Lossless (or informationLossless (or information--preserving) compressionpreserving) compression: Images can be compressed and restored without any loss of information (e.g., medical imaging, satellite imaging)
•• LossyLossy compressioncompression: Perfect recovery not possible;larger data compression (e.g., TV signals, teleconferencing)
Lossless vs. Lossy Compression
{losslesslossless
lossylossy
5
M. Carli - 2005
Image Compression
• Data are the means by which information is conveyed
• Various amounts of data may be used to represent the same amount of information
• Data redundancy: if n1 and n2 denote the number of information-carrying units in two data sets that represent the same information, the relative data redundancyrelative data redundancy of the first data set with respect to the second is
Data and Information
11DR
RC
= − 1
2R
nCn
=where compression compression ratioratio
M. Carli - 2005
Image Compression
• Case 1:
• Case 2:
• Case 3:
11DR
RC
= −11DR
RC
= −Examining
2 1n n=
2 1n n
2 1n n
1and 0R DC R= =
0 andR DC R→ →−∞
and 1R DC R→∞ →
the first data set contains no redundant information
highly redundant data significant compression
(undesirable) data expansion
6
M. Carli - 2005
Image Compression
•
• In digital image compression there exist three basic data redundancies:
• This means that the first dataset needs 10 information-carrying units (e.g., bits) whereas the second dataset just needs 1!
• The corresponding redundancy is which says that 90% of the data in the first set is redundant
Example
10 (or 10 :1)RC =
0.9DR =
7
M. Carli - 2005
Image Compression
• Let be a discrete random variable representing the gray levels (L) in an image
• Its probability is represented by
• Let be the total number of bits used to represent each value of
• The average number of bits required to represent each pixel is
Coding Redundancy
( ) , 0,1, , 1kr k
np r k Ln
= = −…
[0,1]kr ∈
kr( )kl r
1
0( ) ( )
L
avg k r kk
L l r p r−
== ∑
M. Carli - 2005
Image Compression
Coding
• The average lenght of the code words assigned tothe various gray-level values: the sum of the product of the number of bits used to representeach gray level and the probability that the graylevel occurs.
• Total number of bits to code an MxN image isMNLavg
• Usually l(rk) = m bits (constant). ⇒ Lavg = ∑k mpr (rk)=m
8
M. Carli - 2005
Image Compression
Coding
• It makes sense to assign fewer bits to those rk for which pr(rk) are large in order to reduce the sum.
• ⇒ achieves data compression and results in a variable length code.
• More probable gray levels will have fewer number of bits.
1
0( ) ( )
L
avg k r kk
L l r p r−
== ∑
M. Carli - 2005
Image Compression
Example: Variable-Length Coding
Code 1:
Code 2:
3avgL bits=
2.7avgL bits=
3 1.112.7RC = =
11 0.0991.11DR = − =
natural binary code
variable-lengthcode
Gray-level distribution
2(0.19)+2(0.25)+...
9
M. Carli - 2005
Image Compression
Example: Rationale Behind Variable-Length Coding
• Assign shortest codewords to the most probable gray levels and longest codewords to the least probable
probability codeword length
M. Carli - 2005
Image Compression
Interpixel Redundancy
( )( )(0)
A nnA
γ ∆∆ =
autocorrelation autocorrelation coefficients along one coefficients along one line of each imageline of each image
1
0
1( ) ( , ) ( , )N n
yA n f x y f x y n
N n
− −∆
=∆ = + ∆
−∆ ∑
x
y
“Same2 histograms
trimodal
10
M. Carli - 2005
Image Compression
• Second image shows high correlation between pixels 45 and 90 samples apart
• Adjacent pixels of both images are highly correlated•• InterpixelInterpixel (or spatial) redundancy(or spatial) redundancy: the value of any
given pixel can be reasonably predicted from the values of its neighbors; as a consequence, any pixel carries a small amount of information
• Interpixel redundancy can be reduced through mappings mappings (e.g., differences between adjacent pixels)(e.g., differences between adjacent pixels)
Interpixel Redundancy
M. Carli - 2005
Image Compression
Example: Run-Length Coding
1024 343 1 2.6312,166 11RC ⋅ ⋅
= =⋅
11 0.622.63DR = − =
11 bits are necessary to represent each run-length pair
number of runs
11
M. Carli - 2005
Image Compression
• The eye does not respond with equal sensitivity to all visual information
• Certain information has less relative importance than other information in normal visual processing (psychovisually redundant)
• It can be eliminated without significantly impairing the quality of image perception
Psychovisual Redundancy
M. Carli - 2005
Image Compression
Irrelevance in Color Imagery
• Human visual system has much lower acuity for color hue and saturation than for brightness
• Use color transform to facilitate exploiting that property
• Channel encoder: Channel encoder: increases the noise immunity of the source encoder’s output
M. Carli - 2005
Image Compression
Typical structured compression system
15
M. Carli - 2005
Image Compression
Source Encoder and Source Decoder Model
M. Carli - 2005
Image Compression
•• MapperMapper: designed to reduce interpixelinterpixel redundancyredundancy; e.g.:– Run-length encoding– Transform encoding (e.g., DCT in JPEG standard)
•• QuantizerQuantizer: reduces psychovisualpsychovisual redundanciesredundancies (it cannot be used in lossless compression)
•• Symbol EncoderSymbol Encoder: creates a fixed/variable length code;it reduces coding redundanciescoding redundancies
Source Encoder
16
M. Carli - 2005
Image Compression
Quantizer
• Goal: reduce the number of possible amplitude values for coding
• Simple scalar quantizerwith four output indices
M. Carli - 2005
Image Compression
• The channel encoder adds ““controlled controlled redundancyredundancy”” to the data to protect it from channel noise
•• Hamming encoding:Hamming encoding: based on appending enough bits to the data to ensure that some minimum number of bits must change between valid code words thereby providing resiliency against transmission errors
The Channel Encoder and Decoder
17
M. Carli - 2005
Image Compression
• Information can be modeled as a probabilistic process that can be measured in a manner which agrees with intuition
• A random event E that occurs with probability P(E) is said to contain
units of information• I(E) is often called selfself--informationinformation
Measuring Information
1( ) log log ( )( )
I E P EP E
= = −
M. Carli - 2005
Image Compression
• If , (no information)
• If the base of the logarithm is 2, the unit of information is called a “bit”
• If ,Example: flipping a coin and communicating the result requires one bit of information
• 1 bit is the amount of information conveyed
Self-Information
( ) 1P E = ( ) 0I E =
( ) 1/ 2P E = 2( ) log (1/ 2) 1 bitI E = − =
18
M. Carli - 2005
Image Compression
Entropy
{ }1 2, , , La a a…information information sourcesource
• Let be the probability of each symbol
• Then the entropy (or uncertainty) of the sourceentropy (or uncertainty) of the sourceis given by
• In some applications, error-free (lossless)compression is the only acceptable means of data reduction (e.g., medical and business documents, satellite data)
• Applicable to both binary and gray-scale images
• Consist of two operations:1. Alternative image representation to reduce
interpixel redundancies2. Coding the representation to eliminate coding
redundancies
Error-Free (or Lossless) Compression
20
M. Carli - 2005
Image Compression
• Devised by Huffman in 1952 for removing coding redundancy
• Property: If the symbols of an information source are coded individually, the Huffman coding yields the smallest possible number of code symbols per source symbol
Huffman (Variable-Length) Coding
M. Carli - 2005
Image Compression
• Method: create a series of source reductions by ordering the probabilities of the symbols under consideration and combining the lowest probability symbols into a single symbol that replaces them in the next source reduction
• Rationale: To assign the shortest possible codewords to the most probable symbols
Huffman Coding
21
M. Carli - 2005
Image Compression
Example: Huffman Source Reductions
symbols are ordered according to decreasing probability
threshold coding is adaptive: the locations of the coefficients to keep depend on subimages
1:= keep
0:=discard
M. Carli - 2005
Image CompressionThreshold Coding vs. Zonal Coding
Threshold Threshold CodingCoding
Zonal Zonal CodingCoding
Approximations obtained by using 12.5% of the 8x8 DCT coefficients
38
M. Carli - 2005
Image Compression
• Is a compression standard for still images• It defines three different coding systems:
1. A lossylossy baseline coding systembaseline coding system based on DCT (adequate for most compression applications)
2. An extended coding system extended coding system for greater compression, higher precision, or progressive reconstruction applications
3. A lossless independent coding systemlossless independent coding system for reversible compression
JPEG (Joint Photographic Experts Group)
M. Carli - 2005
Image Compression
39
M. Carli - 2005
Image Compression
M. Carli - 2005
Image Compression
1.1. Computing the DCTComputing the DCT: the image is divided into 8X8 blocks; each pixel is level shifted by subtracting the quantity 2n-1 where 2n is the maximum number of gray levels in the image. Then, the DCT of each block is computed. The precision of input and output data is restricted to 8 bits whereas the DCT values are represented with 11 bits
2.2. QuantizationQuantization: The DCT coefficients are thresholded and coded using a quantization matrix, and the recorded using zig-zag scanning to form a 1-D sequence
3.3. CodingCoding: The non-zero AC coefficients are Huffman coded. The DC coefficients of each block are DPCM coded relative to the DC coefficient of the previous block
JPEG – Baseline Coding System
40
M. Carli - 2005
Image Compression
Example: Implementing the JPEG Baseline Coding System with Matlab