image processing architecture, © 2001-2004 oleh tretiakpage 1lecture 3 ece-c490 winter 2004 image...

46
Image Processing Architecture, © 2001-2004 Oleh Tretiak Page 1 Lecture 3 ECE-C490 Winter 2004 Image Processing Architecture Lecture 3, 1/13/2004 Lossless Coding Standards Oleh Tretiak Drexel University

Upload: berniece-thornton

Post on 04-Jan-2016

219 views

Category:

Documents


3 download

TRANSCRIPT

Page 1: Image Processing Architecture, © 2001-2004 Oleh TretiakPage 1Lecture 3 ECE-C490 Winter 2004 Image Processing Architecture Lecture 3, 1/13/2004 Lossless

Image Processing Architecture, © 2001-2004 Oleh Tretiak Page 1Lecture 3

ECE-C490 Winter 2004 Image Processing Architecture

Lecture 3, 1/13/2004

Lossless Coding StandardsOleh Tretiak

Drexel University

Page 2: Image Processing Architecture, © 2001-2004 Oleh TretiakPage 1Lecture 3 ECE-C490 Winter 2004 Image Processing Architecture Lecture 3, 1/13/2004 Lossless

Image Processing Architecture, © 2001-2004 Oleh Tretiak Page 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

Page 3: Image Processing Architecture, © 2001-2004 Oleh TretiakPage 1Lecture 3 ECE-C490 Winter 2004 Image Processing Architecture Lecture 3, 1/13/2004 Lossless

Image Processing Architecture, © 2001-2004 Oleh Tretiak Page 3Lecture 3

Review: Entropy Coding Conversion from ‘symbols’ to ‘codes’ Symbols from ‘alphabet’ with N distinct ‘letters’

Without encoding, bits are needed per symbollog2 N⎡ ⎤

With encoding, Information Theory tells us that we can compress to

bits per symbol

H = pi log2(1/pi )i=1

N∑

Page 4: Image Processing Architecture, © 2001-2004 Oleh TretiakPage 1Lecture 3 ECE-C490 Winter 2004 Image Processing Architecture Lecture 3, 1/13/2004 Lossless

Image Processing Architecture, © 2001-2004 Oleh Tretiak Page 4Lecture 3

Review: Coding Methods Huffman codes

Encode one symbol at a time Minimum of one bit per source symbol

Page 5: Image Processing Architecture, © 2001-2004 Oleh TretiakPage 1Lecture 3 ECE-C490 Winter 2004 Image Processing Architecture Lecture 3, 1/13/2004 Lossless

Image Processing Architecture, © 2001-2004 Oleh Tretiak Page 5Lecture 3

Code construction exampleSymbol Probability

? 0.10e 0.30k 0.05l 0.20r 0.20u 0.10w 0.05

ST 1e 0.30l 0.20r 0.20? 0.10u 0.10k 0.05w 0.05

ST 2e 0.30l 0.20r 0.20? 0.10u 0.10A 0.10

A=k,w

ST 3e 0.30l 0.20r 0.20B 0.20? 0.10

B=u,A

ST 4e 0.30C 0.30l 0.20r 0.20

C=B,?

ST 5D 0.40e 0.30C 0.30

D=l,r

ST 6D 0.40E 0.60

E=e,C

00 r01 l10 e1100 u11010 k11011 w111 ?

H = 2.55

? 111 3e 10 2k 11010 5l 01 2r 00 2u 1100 4w 11011 5

Lave = pilii=0

N∑

=0.10 ×3 + 0.30 ×2 +0.05 ×5 + ... +0.05 ×5=2.6

DEeClrB?uAkw010101001011

Page 6: Image Processing Architecture, © 2001-2004 Oleh TretiakPage 1Lecture 3 ECE-C490 Winter 2004 Image Processing Architecture Lecture 3, 1/13/2004 Lossless

Image Processing Architecture, © 2001-2004 Oleh Tretiak Page 6Lecture 3

Huffman and VLC

For a Huffman code, H ≤ Lave ≤ H + 1 also 1 ≤ Lave

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

Page 7: Image Processing Architecture, © 2001-2004 Oleh TretiakPage 1Lecture 3 ECE-C490 Winter 2004 Image Processing Architecture Lecture 3, 1/13/2004 Lossless

Image Processing Architecture, © 2001-2004 Oleh Tretiak Page 7Lecture 3

This Lecture Arithmetic Coding Run-length encoding Predictive encoding Lossless encoding standards

Fax JBIG Lossless JPEG

Page 8: Image Processing Architecture, © 2001-2004 Oleh TretiakPage 1Lecture 3 ECE-C490 Winter 2004 Image Processing Architecture Lecture 3, 1/13/2004 Lossless

Image Processing Architecture, © 2001-2004 Oleh Tretiak Page 8Lecture 3

Huffman vs. Arithmetic Code Lowest Lave 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.

Page 9: Image Processing Architecture, © 2001-2004 Oleh TretiakPage 1Lecture 3 ECE-C490 Winter 2004 Image Processing Architecture Lecture 3, 1/13/2004 Lossless

Image Processing Architecture, © 2001-2004 Oleh Tretiak Page 9Lecture 3

Arithmetic Encoding Assume source alphabet has values 0 and 1, p0 = p , p1 = 1 – p.

A sequence of symbols s1, s2, … sm is represented by a probability interval found as follows:

Initialize, lo = 0; range = 1 For i = 0 to m

if si = 0 range = range*p

else // si = 1 lo = lo + range*p range = range*(1-p)

end end

Send binary fraction x such that lo ≤ x < hi. This will require log2 range⎡ ⎤ bits

Page 10: Image Processing Architecture, © 2001-2004 Oleh TretiakPage 1Lecture 3 ECE-C490 Winter 2004 Image Processing Architecture Lecture 3, 1/13/2004 Lossless

Image Processing Architecture, © 2001-2004 Oleh Tretiak Page 10Lecture 3

Arithmetic coding: example p0 = 0.2, source sequence is 1101

Number of bits = ceiling(-log2(0.1024)) = 4low2 =.01100010, (low+range)2 = .01111100Bits sent: 0111

symbol low range

0 1

1 0.2000 0.8000

1 0.3600 0.6400

0 0.3600 0.1280

1 0.3856 0.1024

Page 11: Image Processing Architecture, © 2001-2004 Oleh TretiakPage 1Lecture 3 ECE-C490 Winter 2004 Image Processing Architecture Lecture 3, 1/13/2004 Lossless

Image Processing Architecture, © 2001-2004 Oleh Tretiak Page 12Lecture 3

1

Review: Arithmetic encoding example

p0 = 0.2, source sequence is 1101

bit low high0 1

1 0.2 11 0.36 10 0.36 0.4881 0.3856 0.488

Number of bits = ceiling(-log2(0.1024)) = 4Binary code for low: .01100010...Binary code for high: .01111100...Code sent: 0111 = 0.4375

1

0 1 X

Page 12: Image Processing Architecture, © 2001-2004 Oleh TretiakPage 1Lecture 3 ECE-C490 Winter 2004 Image Processing Architecture Lecture 3, 1/13/2004 Lossless

Image Processing Architecture, © 2001-2004 Oleh Tretiak Page 13Lecture 3

Arithmetic Decoding We receive x, a binary fraction, p = prob(0)lo = 0; hi = 1; range = 1for i = 1 to m

if (x - lo) < p*rangesi = 0range = range*phi = lo + range

elsesi = 1lo = lo + range*prange = range*(1-p)

end

end

Page 13: Image Processing Architecture, © 2001-2004 Oleh TretiakPage 1Lecture 3 ECE-C490 Winter 2004 Image Processing Architecture Lecture 3, 1/13/2004 Lossless

Image Processing Architecture, © 2001-2004 Oleh Tretiak Page 14Lecture 3

Arithmetic decoding example Receive 0111 (0.4375), decode 4 bits, p0 = 0.2

p= 0.2

low high range low+p*range bit0 1 1 0.2 1

0.2 1 0.8 0.36 10.36 1 0.64 0.488 00.36 0.488 0.13 0.3856 1

x = 0.4375

Page 14: Image Processing Architecture, © 2001-2004 Oleh TretiakPage 1Lecture 3 ECE-C490 Winter 2004 Image Processing Architecture Lecture 3, 1/13/2004 Lossless

Image Processing Architecture, © 2001-2004 Oleh Tretiak Page 15Lecture 3

Arithmetic decoding example Receive 0111 (0.4375), decode 4 bits, p0 = 0.2

symbol low range

0 1

1 0.2000 0.8000

1 0.3600 0.6400

0 0.3600 0.1280

1 0.3856 0.1024

Page 15: Image Processing Architecture, © 2001-2004 Oleh TretiakPage 1Lecture 3 ECE-C490 Winter 2004 Image Processing Architecture Lecture 3, 1/13/2004 Lossless

Image Processing Architecture, © 2001-2004 Oleh Tretiak Page 16Lecture 3

Magic Features of ArithmeticCoding

Remember I (information) = - log2p 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)

Page 16: Image Processing Architecture, © 2001-2004 Oleh TretiakPage 1Lecture 3 ECE-C490 Winter 2004 Image Processing Architecture Lecture 3, 1/13/2004 Lossless

Image Processing Architecture, © 2001-2004 Oleh Tretiak Page 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

SignalPreprocessorEntropy CoderData

Page 17: Image Processing Architecture, © 2001-2004 Oleh TretiakPage 1Lecture 3 ECE-C490 Winter 2004 Image Processing Architecture Lecture 3, 1/13/2004 Lossless

Image Processing Architecture, © 2001-2004 Oleh Tretiak Page 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

Page 18: Image Processing Architecture, © 2001-2004 Oleh TretiakPage 1Lecture 3 ECE-C490 Winter 2004 Image Processing Architecture Lecture 3, 1/13/2004 Lossless

Image Processing Architecture, © 2001-2004 Oleh Tretiak Page 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, ...

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 00 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 00 0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 00 0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 00 0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 00 0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 00 0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 00 0 0 1 1 1 1 1 1 1 0 0 0 0 1 1 1 1 0 00 0 0 0 1 1 1 1 1 1 0 0 1 1 1 0 1 1 0 00 0 0 0 1 1 0 0 1 1 1 0 1 1 0 0 1 1 0 00 0 0 0 1 1 0 0 1 1 1 0 0 0 0 1 1 1 0 00 0 0 0 1 1 0 0 1 1 1 0 0 1 1 1 1 1 0 00 0 0 0 1 1 0 0 1 1 1 0 1 1 1 0 1 1 0 00 0 0 1 1 1 0 0 1 1 1 0 1 1 1 0 1 1 1 00 0 0 1 1 1 0 0 1 1 1 0 0 1 1 1 1 1 1 00 0 0 1 1 1 0 0 1 1 1 0 0 0 1 0 0 1 0 00 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 00 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

20x18

array

Page 19: Image Processing Architecture, © 2001-2004 Oleh TretiakPage 1Lecture 3 ECE-C490 Winter 2004 Image Processing Architecture Lecture 3, 1/13/2004 Lossless

Image Processing Architecture, © 2001-2004 Oleh Tretiak Page 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)

Page 20: Image Processing Architecture, © 2001-2004 Oleh TretiakPage 1Lecture 3 ECE-C490 Winter 2004 Image Processing Architecture Lecture 3, 1/13/2004 Lossless

Image Processing Architecture, © 2001-2004 Oleh Tretiak Page 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.

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 00 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 00 0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 00 0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 00 0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 00 0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 00 0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 00 0 0 1 1 1 1 1 1 1 0 0 0 0 1 1 1 1 0 00 0 0 0 1 1 1 1 1 1 0 0 1 1 1 0 1 1 0 00 0 0 0 1 1 0 0 1 1 1 0 1 1 0 0 1 1 0 00 0 0 0 1 1 0 0 1 1 1 0 0 0 0 1 1 1 0 00 0 0 0 1 1 0 0 1 1 1 0 0 1 1 1 1 1 0 00 0 0 0 1 1 0 0 1 1 1 0 1 1 1 0 1 1 0 00 0 0 1 1 1 0 0 1 1 1 0 1 1 1 0 1 1 1 00 0 0 1 1 1 0 0 1 1 1 0 0 1 1 1 1 1 1 00 0 0 1 1 1 0 0 1 1 1 0 0 0 1 0 0 1 0 00 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 00 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

20x18

array

Original

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 00 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 00 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 00 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 00 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 00 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 00 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 00 0 0 1 0 0 0 0 0 0 1 0 0 0 1 0 0 0 1 00 0 0 0 1 0 0 0 0 0 1 0 1 0 0 1 1 0 1 00 0 0 0 1 0 1 0 1 0 0 1 1 0 1 0 1 0 1 00 0 0 0 1 0 1 0 1 0 0 1 0 0 0 1 0 0 1 00 0 0 0 1 0 1 0 1 0 0 1 0 1 0 0 0 0 1 00 0 0 0 1 0 1 0 1 0 0 1 1 0 0 1 1 0 1 00 0 0 1 0 0 1 0 1 0 0 1 1 0 0 1 1 0 0 10 0 0 1 0 0 1 0 1 0 0 1 0 1 0 0 0 0 0 10 0 0 1 0 0 1 0 1 0 0 1 0 0 1 1 0 1 1 00 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 00 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

Predicted

Page 21: Image Processing Architecture, © 2001-2004 Oleh TretiakPage 1Lecture 3 ECE-C490 Winter 2004 Image Processing Architecture Lecture 3, 1/13/2004 Lossless

Image Processing Architecture, © 2001-2004 Oleh Tretiak Page 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

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 00 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 00 0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 00 0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 00 0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 00 0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 00 0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 00 0 0 1 1 1 1 1 1 1 0 0 0 0 1 1 1 1 0 00 0 0 0 1 1 1 1 1 1 0 0 1 1 1 0 1 1 0 00 0 0 0 1 1 0 0 1 1 1 0 1 1 0 0 1 1 0 00 0 0 0 1 1 0 0 1 1 1 0 0 0 0 1 1 1 0 00 0 0 0 1 1 0 0 1 1 1 0 0 1 1 1 1 1 0 00 0 0 0 1 1 0 0 1 1 1 0 1 1 1 0 1 1 0 00 0 0 1 1 1 0 0 1 1 1 0 1 1 1 0 1 1 1 00 0 0 1 1 1 0 0 1 1 1 0 0 1 1 1 1 1 1 00 0 0 1 1 1 0 0 1 1 1 0 0 0 1 0 0 1 0 00 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 00 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

20x18

array

Original

c ba x

x - sample being predicted, a - previous sample, b, c - previous line.

Prediction rule: majority value.

Page 22: Image Processing Architecture, © 2001-2004 Oleh TretiakPage 1Lecture 3 ECE-C490 Winter 2004 Image Processing Architecture Lecture 3, 1/13/2004 Lossless

Image Processing Architecture, © 2001-2004 Oleh Tretiak Page 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…

Page 23: Image Processing Architecture, © 2001-2004 Oleh TretiakPage 1Lecture 3 ECE-C490 Winter 2004 Image Processing Architecture Lecture 3, 1/13/2004 Lossless

Image Processing Architecture, © 2001-2004 Oleh Tretiak Page 24Lecture 3

Fax Standards Bilevel (binary) documents Both graphics and pictures (halftone)

Halftone Graphic(line art)

Page 24: Image Processing Architecture, © 2001-2004 Oleh TretiakPage 1Lecture 3 ECE-C490 Winter 2004 Image Processing Architecture Lecture 3, 1/13/2004 Lossless

Image Processing Architecture, © 2001-2004 Oleh Tretiak Page 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

Page 25: Image Processing Architecture, © 2001-2004 Oleh TretiakPage 1Lecture 3 ECE-C490 Winter 2004 Image Processing Architecture Lecture 3, 1/13/2004 Lossless

Image Processing Architecture, © 2001-2004 Oleh Tretiak Page 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!

Page 26: Image Processing Architecture, © 2001-2004 Oleh TretiakPage 1Lecture 3 ECE-C490 Winter 2004 Image Processing Architecture Lecture 3, 1/13/2004 Lossless

Image Processing Architecture, © 2001-2004 Oleh Tretiak Page 27Lecture 3

JBIG: Progressive Coding Id — full resolution image, each layer reduces resolution by 2

C0 — code for base layer image, used to reconstruct I0

Id is reconstructed from Id–1 and Cd (bottom-up)

Advantage: Full resolution image may be of graphics arts quality, cannot be displayed on monitor.

Sometimes only base layer encoder is used.Diff.

LayerEncoder

Diff.Layer

Encoder

BaseLayer

Encoder

. . .I0Id Id −1 Id−2

C0

Cd

Cd−1

Page 27: Image Processing Architecture, © 2001-2004 Oleh TretiakPage 1Lecture 3 ECE-C490 Winter 2004 Image Processing Architecture Lecture 3, 1/13/2004 Lossless

Image Processing Architecture, © 2001-2004 Oleh Tretiak Page 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 Id and Id–1 to generate Cd

C0

TypicalPredictionAdaptive

TemplatesModel

TemplatesAdaptiveArithmeticEncoder

I0

Page 28: Image Processing Architecture, © 2001-2004 Oleh TretiakPage 1Lecture 3 ECE-C490 Winter 2004 Image Processing Architecture Lecture 3, 1/13/2004 Lossless

Image Processing Architecture, © 2001-2004 Oleh Tretiak Page 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 210 entries for baselayer and 212 entries for interlayer.

Example of context in baselayer encoder:

ContextpixelsPixelbeing

predicted

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.

Page 29: Image Processing Architecture, © 2001-2004 Oleh TretiakPage 1Lecture 3 ECE-C490 Winter 2004 Image Processing Architecture Lecture 3, 1/13/2004 Lossless

Image Processing Architecture, © 2001-2004 Oleh Tretiak Page 30Lecture 3

JBIG Arithmetic Coding Encoder

Differences between predicted and actual bits are sent to an arithmetic encoder.

The JBIG arithmetic encoder is adaptive: p1 is determined by the values of recently encoded bits.

Only 112 possible values of p1 are used.

Decoder The value of p1 in the decoder is computed from the bits already

decoded (past bits) with the same algorithm as that in the encoder. The decoder p1 varies from bit to bit, just as in the encoder!

Page 30: Image Processing Architecture, © 2001-2004 Oleh TretiakPage 1Lecture 3 ECE-C490 Winter 2004 Image Processing Architecture Lecture 3, 1/13/2004 Lossless

Image Processing Architecture, © 2001-2004 Oleh Tretiak Page 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.

Page 31: Image Processing Architecture, © 2001-2004 Oleh TretiakPage 1Lecture 3 ECE-C490 Winter 2004 Image Processing Architecture Lecture 3, 1/13/2004 Lossless

Image Processing Architecture, © 2001-2004 Oleh Tretiak Page 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

Page 32: Image Processing Architecture, © 2001-2004 Oleh TretiakPage 1Lecture 3 ECE-C490 Winter 2004 Image Processing Architecture Lecture 3, 1/13/2004 Lossless

Image Processing Architecture, © 2001-2004 Oleh Tretiak Page 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.

Page 33: Image Processing Architecture, © 2001-2004 Oleh TretiakPage 1Lecture 3 ECE-C490 Winter 2004 Image Processing Architecture Lecture 3, 1/13/2004 Lossless

Image Processing Architecture, © 2001-2004 Oleh Tretiak Page 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

Page 34: Image Processing Architecture, © 2001-2004 Oleh TretiakPage 1Lecture 3 ECE-C490 Winter 2004 Image Processing Architecture Lecture 3, 1/13/2004 Lossless

Image Processing Architecture, © 2001-2004 Oleh Tretiak Page 35Lecture 3

Lossless Coding of Grey-Value

Images Not much compression

Rule of thumb: 50% compression Lossy compression used much more

Page 35: Image Processing Architecture, © 2001-2004 Oleh TretiakPage 1Lecture 3 ECE-C490 Winter 2004 Image Processing Architecture Lecture 3, 1/13/2004 Lossless

Image Processing Architecture, © 2001-2004 Oleh Tretiak Page 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

Page 36: Image Processing Architecture, © 2001-2004 Oleh TretiakPage 1Lecture 3 ECE-C490 Winter 2004 Image Processing Architecture Lecture 3, 1/13/2004 Lossless

Image Processing Architecture, © 2001-2004 Oleh Tretiak Page 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:

abcxpreviously coded lines

previously coded sample on current line

x — pixel being predicted

Page 37: Image Processing Architecture, © 2001-2004 Oleh TretiakPage 1Lecture 3 ECE-C490 Winter 2004 Image Processing Architecture Lecture 3, 1/13/2004 Lossless

Image Processing Architecture, © 2001-2004 Oleh Tretiak Page 38Lecture 3

JPEG: Predictor Choices The same prediction choice is used for each group of several

lines, and is transmitted in a header.

Selection Value

Prediction for x

0 no prediction1 a2 b3 c4 a+b-c5 a+((b-c)/2)6 b+((a-c)/2)7 (a+b)/2

abcx

Transmitted value: x - predicted valueOur book: prediction value - x. Who is right?

Page 38: Image Processing Architecture, © 2001-2004 Oleh TretiakPage 1Lecture 3 ECE-C490 Winter 2004 Image Processing Architecture Lecture 3, 1/13/2004 Lossless

Image Processing Architecture, © 2001-2004 Oleh Tretiak Page 39Lecture 3

Example: DPCM prediction This example: Selection-value = 1 (previous pixel)

Sample 20 21 22 23 24 25 26 27

Image Value 40 41 40 26 24 29 35 35

Predicted Value 40 41 40 26 24 29 35

Difference 1 -1 -14 -2 5 6 0

Page 39: Image Processing Architecture, © 2001-2004 Oleh TretiakPage 1Lecture 3 ECE-C490 Winter 2004 Image Processing Architecture Lecture 3, 1/13/2004 Lossless

Image Processing Architecture, © 2001-2004 Oleh Tretiak Page 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 2k bit number, the last k bits of the 1’s complement value of the residual.

Example: residual = 5 (1012)Category = 3, code = 101

Example: residual = -10, (-10102)Category = 4, code = 0101

The category is Huffman-encoded, andthe code is used without encoding.

Category Prediction Residual0 01 -1,12 -3,-2,2,33 -7,…,-4,4,…,74 -15,…,-8,8,…,15

et cetera

Page 40: Image Processing Architecture, © 2001-2004 Oleh TretiakPage 1Lecture 3 ECE-C490 Winter 2004 Image Processing Architecture Lecture 3, 1/13/2004 Lossless

Image Processing Architecture, © 2001-2004 Oleh Tretiak Page 41Lecture 3

JPEG Encoding: Continued Predictive encoding, Selection Value = 1

Sample 20 21 22 23 24 25 26 27

Image Value 40 41 40 26 24 29 35 35

Predicted Value 40 41 40 26 24 29 35

Difference 1 -1 -14 -2 5 6 0

Category 1 1 4 2 3 3 0

Code 1 0 0001 00 101 110 -

Page 41: Image Processing Architecture, © 2001-2004 Oleh TretiakPage 1Lecture 3 ECE-C490 Winter 2004 Image Processing Architecture Lecture 3, 1/13/2004 Lossless

Image Processing Architecture, © 2001-2004 Oleh Tretiak Page 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)/2y = (100+191)/2 = 145residual = 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 = 145residual = 100-145 = -45 = -101101

Category = 6, code = 010010 (1’s complement of 1001101)

Page 42: Image Processing Architecture, © 2001-2004 Oleh TretiakPage 1Lecture 3 ECE-C490 Winter 2004 Image Processing Architecture Lecture 3, 1/13/2004 Lossless

Image Processing Architecture, © 2001-2004 Oleh Tretiak Page 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

Page 43: Image Processing Architecture, © 2001-2004 Oleh TretiakPage 1Lecture 3 ECE-C490 Winter 2004 Image Processing Architecture Lecture 3, 1/13/2004 Lossless

Image Processing Architecture, © 2001-2004 Oleh Tretiak Page 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)

Page 44: Image Processing Architecture, © 2001-2004 Oleh TretiakPage 1Lecture 3 ECE-C490 Winter 2004 Image Processing Architecture Lecture 3, 1/13/2004 Lossless

Image Processing Architecture, © 2001-2004 Oleh Tretiak Page 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.

y =(mina,b) c ≥ (maxa,b)(maxa,b) c ≤ (mina,b)

a +b−c otherwise

⎨ ⎪

⎩ ⎪

Page 45: Image Processing Architecture, © 2001-2004 Oleh TretiakPage 1Lecture 3 ECE-C490 Winter 2004 Image Processing Architecture Lecture 3, 1/13/2004 Lossless

Image Processing Architecture, © 2001-2004 Oleh Tretiak Page 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).

Page 46: Image Processing Architecture, © 2001-2004 Oleh TretiakPage 1Lecture 3 ECE-C490 Winter 2004 Image Processing Architecture Lecture 3, 1/13/2004 Lossless

Image Processing Architecture, © 2001-2004 Oleh Tretiak Page 47Lecture 3

JPEG 2000 New approach Wavelet encoding, both lossy and lossless Later