Download presentation
Presentation is loading. Please wait.
Published byBerniece Thornton Modified over 9 years ago
2
Image Processing Architecture, © 2001-2004 Oleh TretiakPage 1Lecture 3 ECE-C490 Winter 2004 Image Processing Architecture Lecture 3, 1/13/2004 Lossless Coding Standards Oleh Tretiak Drexel University
3
Image Processing Architecture, © 2001-2004 Oleh TretiakPage 2Lecture 3 Announcements Meeting room change: Tu, Th 11-12:20 in Curtis 328-B Homework 1 due today Homework 2 due on 20 January
4
Image Processing Architecture, © 2001-2004 Oleh TretiakPage 3Lecture 3 Review: Entropy Coding Conversion from ‘symbols’ to ‘codes’ Symbols from ‘alphabet’ with N distinct ‘letters’ Without encoding, bits are needed per symbol With encoding, Information Theory tells us that we can compress to bits per symbol
5
Image Processing Architecture, © 2001-2004 Oleh TretiakPage 4Lecture 3 Review: Coding Methods Huffman codes Encode one symbol at a time Minimum of one bit per source symbol
6
Image Processing Architecture, © 2001-2004 Oleh TretiakPage 5Lecture 3 Code construction example A=k,w B=u,A C=B,? D=l,r E=e,C H = 2.55
7
Image Processing Architecture, © 2001-2004 Oleh TretiakPage 6Lecture 3 Huffman and VLC For a Huffman code, H ≤ L ave ≤ H + 1 also 1 ≤ L ave Codes used in pactice are variable length tree codes, and are called Variable Length Codes (VLC) A VLC may not be as good as a Huffman code, but may have other good properties Reduced max code word length Simpler implementation
8
Image Processing Architecture, © 2001-2004 Oleh TretiakPage 7Lecture 3 This Lecture Arithmetic Coding Run-length encoding Predictive encoding Lossless encoding standards Fax JBIG Lossless JPEG
9
Image Processing Architecture, © 2001-2004 Oleh TretiakPage 8Lecture 3 Huffman vs. Arithmetic Code Lowest L ave for Huffman codes is 1. Suppose H << 1? One option: use one code symbol for several source symbols Another option: Arithmetic code. Idea behind arithmetic code: Represent the probability of a sequence by a binary number.
10
Image Processing Architecture, © 2001-2004 Oleh TretiakPage 9Lecture 3 Arithmetic Encoding Assume source alphabet has values 0 and 1, p 0 = p, p 1 = 1 – p. A sequence of symbols s 1, s 2, … s m is represented by a probability interval found as follows: Initialize, lo = 0; range = 1 For i = 0 to m if s i = 0 range = range*p else // s i = 1 lo = lo + range*p range = range*(1-p) end end Send binary fraction x such that lo ≤ x < hi. This will require
11
Image Processing Architecture, © 2001-2004 Oleh TretiakPage 10Lecture 3 Arithmetic coding: example p 0 = 0.2, source sequence is 1101 Number of bits = ceiling(-log 2 (0.1024)) = 4 low 2 =.01100010, (low+range) 2 =.01111100 Bits sent: 0111
12
Image Processing Architecture, © 2001-2004 Oleh TretiakPage 11Lecture 3 Arithmetic Encoding Assume source alphabet has values 0 and 1, p 0 = p, p 1 = 1 – p. A sequence of symbols s 1, s 2, … s m is represented by a probability interval found as follows: Initialize, lo = 0; hi = 1; range = 1 For i = 0 to m if s i = 0 range = range*p 0 hi = lo + range else lo = lo + range*p 0 range = range*p 1 end Send binary fraction x such that lo ≤ x < hi. This will require ceiling(log 2 range) bits. Note that this is equal to
13
Image Processing Architecture, © 2001-2004 Oleh TretiakPage 12Lecture 3 Review: Arithmetic encoding example p 0 = 0.2, source sequence is 1101 Number of bits = ceiling(-log2(0.1024)) = 4 Binary code for low:.01100010... Binary code for high:.01111100... Code sent: 0111 = 0.4375 X
14
Image Processing Architecture, © 2001-2004 Oleh TretiakPage 13Lecture 3 Arithmetic Decoding We receive x, a binary fraction, p = prob(0) lo = 0; hi = 1; range = 1 for i = 1 to m if (x - lo) < p*range s i = 0 range = range*p hi = lo + range else s i = 1 lo = lo + range*p range = range*(1-p) end
15
Image Processing Architecture, © 2001-2004 Oleh TretiakPage 14Lecture 3 Arithmetic decoding example Receive 0111 (0.4375), decode 4 bits, p 0 = 0.2
16
Image Processing Architecture, © 2001-2004 Oleh TretiakPage 15Lecture 3 Arithmetic decoding example Receive 0111 (0.4375), decode 4 bits, p0 = 0.2
17
Image Processing Architecture, © 2001-2004 Oleh TretiakPage 16Lecture 3 Magic Features of Arithmetic Coding Remember I (information) = - log 2 p p = 0.5, I = 1 p = 0.125, I = 3 p = 0.99, I = 0,0145 (wow!) High p symbol, less than 1 code bit per symbol! In encoder, hi - lo = ∑ I(symbols)
18
Image Processing Architecture, © 2001-2004 Oleh TretiakPage 17Lecture 3 Review: Typical Encoder System Reasons for pre-processing Signal samples are independent, but the entropy coder (e. g. Huffman coder) cannot code them efficiently (match samples to coder) Signal samples are statistically dependent. Pre-processing produces a sequence of new symbols that are statistically independent and can be coded more efficiently
19
Image Processing Architecture, © 2001-2004 Oleh TretiakPage 18Lecture 3 Run-length Encoding Idea Pre-processing method, good when one symbol occurs with high probability or when symbols are dependent Count how many repeated symbol occur Source ‘letter’ = length of run
20
Image Processing Architecture, © 2001-2004 Oleh TretiakPage 19Lecture 3 Run Length Encoding Example Example source produces ‘one’s and ‘zeros’, zeros Run length coding: 23, 3, 15, 3, 17, 3,17, 3, 17, 7, 4, 4, 6,... 20x18 array
21
Image Processing Architecture, © 2001-2004 Oleh TretiakPage 20Lecture 3 Predictive Coding Example Idea, at transmitter predict the pixel value on the basis of past pixels Send ‘0’ if prediction is correct, ‘1’ if prediction is not correct 1-D example, binary picture Prediction rule: previous value. If previous value = 0, predict 0; if previous value = 1, predict 1 Sequence 00011110000111 (14 symbols, 7 zeros, 7 ones, p = 0.5, H = 1) Coded sequence 00010001000100 (10 symbols, 11 zeros, 3 ones, H = 0.75)
22
Image Processing Architecture, © 2001-2004 Oleh TretiakPage 21Lecture 3 2-D Predictive Coding Image is 2-D array of 0’s and 1’s Scan left to right, top to bottom Previous sample prediction. 20x18 array Original Predicted
23
Image Processing Architecture, © 2001-2004 Oleh TretiakPage 22Lecture 3 2-D Predictive Coding Image is 2-D array of 0’s and 1’s Scan left to right, top to bottom Predict on past sample and past line 20x18 array Original x - sample being predicted, a - previous sample, b, c - previous line. Prediction rule: majority value.
24
Image Processing Architecture, © 2001-2004 Oleh TretiakPage 23Lecture 3 Lossless Encoding Standards Importance of Standards Intercommunication Complexity of Standards Many parts of standards are not implemented Some standards are very successful! Some don’t get mentioned much at all…
25
Image Processing Architecture, © 2001-2004 Oleh TretiakPage 24Lecture 3 Fax Standards Bilevel (binary) documents Both graphics and pictures (halftone) Halftone Graphic (line art)
26
Image Processing Architecture, © 2001-2004 Oleh TretiakPage 25Lecture 3 ITU Standard Fax Methods International standards, vintage ~1980 Both analog and digital standards, only digital in use now ITU-T, Rec. T.4 (Group 3) Code uses special symbols to indicate end-of-line, to recover from transmission errors. MH (modified Huffman): run length coding, pre-defined code tables. Different tables for runs of ‘1’s and ‘0’s. MR (modified read): run length measured from either previous line or current line. Most common method used in practice ITU-T, Rec. T.6 (Group 5). MMR (modified modified read): same as MR, except not robustified
27
Image Processing Architecture, © 2001-2004 Oleh TretiakPage 26Lecture 3 JBIG: ISO Bilevel Standard Prepared by Joint Bilevel Image Group in ~ 1992 Features Progressive (multiresolution) coding Adaptive Model Templates Adaptive Arithmetic Coding Better compression than MMR 2-3 longer running time on conventional computers than MMR Complex!
28
Image Processing Architecture, © 2001-2004 Oleh TretiakPage 27Lecture 3 JBIG: Progressive Coding I d — full resolution image, each layer reduces resolution by 2 C 0 — code for base layer image, used to reconstruct I 0 I d is reconstructed from I d–1 and C d (bottom-up) Advantage: Full resolution image may be of graphics arts quality, cannot be displayed on monitor. Sometimes only base layer encoder is used.
29
Image Processing Architecture, © 2001-2004 Oleh TretiakPage 28Lecture 3 JBIG: Encoder Structure The baselayer encoder is shown below. It consists of prediction algorithms followed by entropy coding with an adaptive arithmetic encoder The interlayer encoder is similar, except that it form its prediction from I d and I d–1 to generate C d
30
Image Processing Architecture, © 2001-2004 Oleh TretiakPage 29Lecture 3 JBIG and Prediction Each pixel is predicted on the basis of a context. The context is 10 bits for baselayer coding and 12 bits in interlayer coding. The predictor consists of a table lookup into a table, indexed by the context. The table consists of 2 10 entries for baselayer and 2 12 entries for interlayer. Example of context in baselayer encoder: Templates: fixed and adaptive. The context is compared to a template. The coder can estimate templates from image data. This allows the detection of periodicities in a half-tone image.
31
Image Processing Architecture, © 2001-2004 Oleh TretiakPage 30Lecture 3 JBIG Arithmetic Coding Encoder Differences between predicted and actual bits are sent to an arithmetic encoder. The JBIG arithmetic encoder is adaptive: p 1 is determined by the values of recently encoded bits. Only 112 possible values of p 1 are used. Decoder The value of p 1 in the decoder is computed from the bits already decoded (past bits) with the same algorithm as that in the encoder. The decoder p 1 varies from bit to bit, just as in the encoder!
32
Image Processing Architecture, © 2001-2004 Oleh TretiakPage 31Lecture 3 JBIG: context decoding The decoder has the same set of context values (previously decoded pixels) as the encoder. It performs the same context- based prediction. If the bit from the arithmetic decoder is 0, the predicted value is used. If the bit from the arithmetic decoder is 1, the predicted value is complemented.
33
Image Processing Architecture, © 2001-2004 Oleh TretiakPage 32Lecture 3 JBIG Coding Performance Comparison with MMR (fax standard), business-type documents Compression for letter (graphics) document MMR: 33,JBIG: 48 Compression for halftone document MMR: 1.5,JBIG: 5.2 JBIG is much better than MMR for high-resolution images JBIG has the advantage of progressive coding
34
Image Processing Architecture, © 2001-2004 Oleh TretiakPage 33Lecture 3 New Work JBIG 2 is on the way! Visit the web site: http://www.jpeg.org/jbigpt2.html “JBIG2 is a format for bi-level (black/white) image compression that offers significant advantages over other compression formats: large increases in compression performance (typically 3-5 times smaller than Group 4/MMR, 2-4 times smaller than JBIG1) special compression methods for text, halftones, and other binary image content lossy and lossless compression multi-page document compression flexible format, designed for easy embedding in other image file formats, such as TIFF high-performance decompression: using some coding modes, images can be decompressed at over 250 million pixels/second in software” JBIG 2 document is on course web site.
35
Image Processing Architecture, © 2001-2004 Oleh TretiakPage 34Lecture 3 JPEG Sources ISO standards cost money (not distributed on web) Excellent book: William B Pennbaker and Joan L. Mitchell, JPEG Still Image Compression Standard, Van Nostrand Reinhold, 1993. Includes ISO DIS 10918 -1 Requirements and Guidelines (JPEG standard) ISO standard, in PDF is available on our web site
36
Image Processing Architecture, © 2001-2004 Oleh TretiakPage 35Lecture 3 Lossless Coding of Grey-Value Images Not much compression Rule of thumb: 50% compression Lossy compression used much more
37
Image Processing Architecture, © 2001-2004 Oleh TretiakPage 36Lecture 3 JPEG: Overview Standards for color image compression (also usable for monochrome) Four modes Sequential DCT (Discrete Cosine Transform) —lossy Most common JPEG method Progressive DCT (lossy), low resolution images sent first, then higher resolution Lossless mode Hierarchical (pyramid) mode. Like JPEG progressive Baseline: low resolution image Subsequent layers: difference between low resolution and higher resolution. Layers sent with lossy or lossless modes
38
Image Processing Architecture, © 2001-2004 Oleh TretiakPage 37Lecture 3 JPEG: Lossless Mode Entropy coding of image gray values usually offers very little compression Encode difference between predicted values and actual gray values Prediction context: previously coded lines previously coded sample on current line x — pixel being predicted
39
Image Processing Architecture, © 2001-2004 Oleh TretiakPage 38Lecture 3 JPEG: Predictor Choices The same prediction choice is used for each group of several lines, and is transmitted in a header. Transmitted value: x - predicted value Our book: prediction value - x. Who is right?
40
Image Processing Architecture, © 2001-2004 Oleh TretiakPage 39Lecture 3 Example: DPCM prediction This example: Selection-value = 1 (previous pixel)
41
Image Processing Architecture, © 2001-2004 Oleh TretiakPage 40Lecture 3 JPEG: Encoding the Residuals Residuals (difference between pixel value and prediction) are encoded into one of 17 categories, as indicated in the table below The residual is encoded as a (category, value), except for category 0 the value is omitted. For category k the value is represented by a 2 k bit number, the last k bits of the 1’s complement value of the residual. Example: residual = 5 (101 2 ) Category = 3, code = 101 Example: residual = -10, (-1010 2 ) Category = 4, code = 0101 The category is Huffman-encoded, and the code is used without encoding.
42
Image Processing Architecture, © 2001-2004 Oleh TretiakPage 41Lecture 3 JPEG Encoding: Continued Predictive encoding, Selection Value = 1
43
Image Processing Architecture, © 2001-2004 Oleh TretiakPage 42Lecture 3 DPCM Lossless JPEG - More Example: a =100, b = 191, c =100, x = 180. Assume we are using selection value 7 prediction value = y = (a + b)/2 y = (100+191)/2 = 145 residual = 180-145 = 35 = 100011 Category = 6, code = 100011 Assume that the Huffman code for 6 is 1110. The full code value for x is 111010011 Same a, b, c, but x = 100 y = (100+191)/2 = 145 residual = 100-145 = -45 = -101101 Category = 6, code = 010010 (1’s complement of 1001101)
44
Image Processing Architecture, © 2001-2004 Oleh TretiakPage 43Lecture 3 Gray Value Encoding in JBIG Encode each bit plane with JBIG On the right, we show a gray-value (8 bit) image, and its top three bit planes Typically, lossless JPEG is more efficient than JBIG for images with more than 6 bits
45
Image Processing Architecture, © 2001-2004 Oleh TretiakPage 44Lecture 3 New Work in JPEG JPEG-LS, (lossless and near lossless methods) Influenced by JBIG Features: Context modeling Run-length coder nonlinear predictor Golomb-Rice entropy coder Context modeling: Compute signature from gray value neighbors of point to be coded. 364 contexts (signature values)
46
Image Processing Architecture, © 2001-2004 Oleh TretiakPage 45Lecture 3 New Work in JPEG Run-mode coder: encode constant values in image with run length (not much value in lossless version). Run-lengths are coded with Golomb-Rice method. Predictor: nonlinear predictor that automatically selects formula (edge detector) Error coding: use Golomb-Rice Code, the parameter k depends on the context, and is adapted to the average absolute value of residuals.
47
Image Processing Architecture, © 2001-2004 Oleh TretiakPage 46Lecture 3 JPEG-LS performance Compression is about 10% better than JPEG-H (original lossless JPEG. Arithmetic coding has been considered, but it seems to offer an advantage only in compound documents (mixture of grayscale and line art).
48
Image Processing Architecture, © 2001-2004 Oleh TretiakPage 47Lecture 3 JPEG 2000 New approach Wavelet encoding, both lossy and lossless Later
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.