CH 6
CH 6
Image compression
Image Compression
Compression Fundamentals
•Data compression refers to the process of reducing the amount of data required to
represent given quantity of information.
•Data refers to the means by which the information is conveyed.
•Various amounts of data can represent the same amount of information.
•Sometimes the given data contains some data which has no relevant information, or
restates/repeats the known information.
•It is thus said to contain data redundancy.
•Data redundancy is the central concept in image compression and can be
mathematically defined.
Image Compression
Compression Fundamentals
• Information versus Data
REDUNDANT
DATA
IMAGE
INFORMATION
•If n1 = n2 , then CR=1 and RD=0, indicating that the first representation of the information contains no
redundant data.
• A typical compression ratio around 10 or(10:1) indicates that 90% (RD=0.9) of the data in the first data set is
redundant.
Image Compression
Data Redundancy: There are three main data redundancies used in image compression.
•Coding redundancy
•Interpixel redundancy
•Psychovisual redundancy
•Coding Redundancy : A code is a system of symbols (i.e. bytes, bits) that represents information.
•Each piece of information is represented by a set of code symbols.
•The gray level histogram of an image can be used in construction of codes to reduce the data used to
represent it. Given the normalized histogram of a gray level image where,
n
pr (rk ) nk k 0,1, 2,...., L
1
•rk is the pixel values defined in the interval [0,1] and pr(k) is the probability of occurrence of rk.
• L is the number of gray levels. nk is the number of times that kth gray level appears and n is the total number of
Image Compression
•Coding Redundancy
•Average number of bits required to represent each pixel is given by:
L1
l(rk ) pr
Lavg k
k 1 (r )
•Where, l(rk) is the number of bits used to represent each value of rk.
•An 8 gray level image has the following gray level distribution.
•The average number of bits used for variable-length code in this particular example:
1
•The relative Data Redundancy: RD 0.099 ~
1 1.11 %10
Image Compression
•Coding Redundancy
•In this example the suggested variable-length coding gets rid of the ~10% redundant data of the fixed 3-bit code.
•The following graph shows the relationship between the histogram of an image, pr(rk) and l2(rk) which are inversely
proportional.
•The shortest code words are assigned to the most frequent (high probability) gray levels
•The longest code words are assigned to the least frequent (low probability) gray levels
•Data compression is achieved by assigning fewer bits to more probable gray levels than the less probable gray levels.
Image Compression
•Interpixel Redundancy
•This type of redundancy is related with the interpixel correlations within an image.
•Much of the visual contribution of a single pixel is redundant and can be guessed from the values of its
neighbors.
run-length.
•Total of 11 bits (1 bit for thresholded value and 10 bit for the run length)
C R (1024)(343)(1) 2.63
(12166)
(11)
Determined by thresholding each line and counting the run-length regions
1
RD
1 2.63 0.62
•The relative redundancy is %62 obtained only by using correlation among the pixels (interpixel
•Certain information has relatively less importance for the quality of image perception.
•Unlike coding and interpixel redundancies, the psychovisual redundancy is related with the real/quantifiable
visual information.
• Its elimination results a loss of quantitative information. However psychovisually the loss is negligible.
•Removing this type of redundancy is a lossy process and the lost information cannot be recovered.
•The method used to remove this type of redundancy is called quantization which means the mapping of a
8-bit image 4-bit image Uniform quantization 4-bit image IGS quantization No
Undesired contouring effect contouring effect
Image Compression
•Psychovisual Redundancy
•The improved gray-scale quantization (IGS) is one of the possible quantization procedures
and summarized in the following table.
Add
Add
•If the MSN of a given 8-bit pixel is 11112 than add zero instead.
•Declare the Most Significant Nibble of the sum to be the 4-bit IGS code.
Image Compression
•Quality Measure of a Compressed Image (Fidelity Criteria):
•The removal of psychovisual redundancy removes real/quantitative information and provides lossy image
compression.
•The quality of such images can be evaluated by objective and subjective methods.
•The objective quality measures:
•The mean-square-error between 2 images (original versus the compressed)
2
(2 B 1)2
PSNR 10 B is the number of bits used for
log1 0 eMSE each pixel. (i.e.8 bits)
SNRms M 1 N
fˆ(x, y)2
1
ˆf (x, y) f (x,
x0 y0
x0 y0
y) 2
Image Compression
• Subjective evaluations used for Image quality rating.
• Human observers can be used to provide subjective evaluations.
Image Compression Models
•The Source Encoder and Decoder:
•The Source Encoder reduces/eliminates any coding, interpixel or psychovisual redundancies. It contains 3 processes:
• Mapper: Transforms the image into array of coefficients reducing interpixel redundancies. This is a reversible
statistical model of the image generation process. The information content (entropy) can be estimated based on this model.
•The information per source (symbol or pixel), which is also referred as entropy is calculated by:
J
E P(a j ) log
P(aprobabilities.
•Where P(aj) refers to the source symbol/pixel j) J refers to the number of symbols or different
pixel values. j 1
•For example, given the following Image segment:
•Error-free compression is generally composed of two relatively independent operations: (1) reduce the interpixel
redundancies and (2) introduce a coding method to reduce the coding redundancies.
•The coding redundancy can be minimized by using a variable-length coding method where the shortest codes are assigned
symbols into a single symbol and replace in the next source reduction.
• 2) Code each reduced source starting with the smallest source and working back to the original source. Use 0 and 1 to
Last code
Image Compression
Error-Free Compression
• Huffman Coding: Note that the shortest codeword (1) is given for the symbol/pixel with the highest
probability (a2). The longest codeword (01011) is given for the symbol/pixel with the lowest probability (a5).
•The average length of the code is given by:
compression ratios ranging between 10:1 to 50:1 can be achieved with visually indistinguishable from the
original. The error-free methods rarely give results more than 3:1.
•Transform Coding: Transform coding is the most popular lossy image compression method which operates
depends on the amount of the reconstruction error that can be tolerated and computational resources available.
Image Compression
DCT-based JPEG (Joint Photographic Expert Group) Standard
Original Compressed
image image
8X8 Coefficients-to-Symbols Entropy
Quantizer
DCT Map Coder
Encoder
Image Compression
DCT-based JPEG Standard
Consider the following 8-bit image with size 512 x 512 pixels.
I m a ge C ompression
I ma ge osl -e
Hihgest frequency
DCT
69 71 74 76 89 106 111 122 717.6 0.2 0.4 -19.8 -2.1 -6.2 -5.7 -7.6
59 70 61 61 68 76 88 94 -99.0 -35.8 27.4 19.4 -2.6 -3.8 9.0 2.7
82 70 77 67 65 63 57 70 51.8 -60.8 3.9 -11.8 1.9 4.1 1.0 6.4
97 99 87 83 72 72 68 63 30.0 -25.1 -6.7 6.2 -4.4 -10.7 -4.2 -8.0
91 105 90 95 85 84 79 75 22.6 2.7 4.9 3.4 -3.6 8.7 -2.7 0.9
92 110 101 106 100 94 87 93 15.6 4.9 -7.0 1.1 2.3 -2.2 6.6 -1.7
89 113 115 124 113 105 100 110 0.0 5.9 2.3 0.5 5.8 3.1 8.0 4.8
104 110 124 125 107 95 117 116 -0.7 -2.3 -5.2 -1.0 3.6 -0.5 5.1 -0.1
ompression
DCT-based JPEG Standard
Step 2:Quantization Procedure
Quantization Matrix
717.6 0.2 0.4 -19.8 -2.1 -6.2 -5.7 -7.6 16 11 10 16 24 40 51 61
12 12 14 19 26 58 60 55
-99.0 -35.8 27.4 19.4 -2.6 -3.8 9.0 2.7
14 13 16 24 40 57 69 56
51.8 -60.8 3.9 -11.8 1.9 4.1 1.0 6.4
14 17 22 29 51 87 80 62
30.0 -25.1 -6.7 6.2 -4.4 -10.7 -4.2 -8.0
18 22 37 56 68 109 103 77
22.6 2.7 4.9 3.4 -3.6 8.7 -2.7 0.9
24 35 55 64 81 104 113 92
15.6 4.9 -7.0 1.1 2.3 -2.2 6.6 -1.7
49 64 78 87 103 121 120 101
0.0 5.9 2.3 0.5 5.8 3.1 8.0 4.8
72 92 95 98 112 100 103 99
-0.7 -2.3 -5.2 -1.0 3.6 -0.5 5.1 -0.1
45 0 0 -1 0 0 0 0
-8 -3 2 1 0 0 0 0
4 -5 0 0 0 0 0 0
2 -1 0 0 0 0 0 0
Quantized
1 0 0 0 0 0 0 0
1 0 0 0 0 0 0 0 8x8 block
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
I m a ge C ompression
I ma ge osl -e
45 0 0 -1 0 0 0 0
-8 -3 2 1 0 0 0 0
4 -5 0 0 0 0 0 0
2 -1 0 0 0 0 0 0
1 0 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
Result = 45,0,-8,4,-3,0,-1,2,-5,2,1,-1,0,1,0,0,0,0,0,0,1,EOB
•Once the encoded file is received the decoding is the inverse process given below.
Compressed
image
Inverse Merging Decompressed
Symbol decoder 8x8 subimages
DCT image
Decoder
I m a ge C
I ma ge osl -e
ompression
DCT-based JPEG Standard
•Compressed image examples for changing compression ratios.