33
IEE 5037 Multimedia Communications Lecture 6: Still Image Compression Dept. Electronics Engineering, National Chiao Tung University Adapted Prof. Hang’s and Chiang’s slides Reading:DVP 20

IEE 5037 Multimedia Communications Lecture 6: Still Image ...twins.ee.nctu.edu.tw/courses/multimedia_c_05spring/handout/MMC_07_Still image...5 JPEG-LS JPEG-LS is in the current ISO/ITU

  • Upload
    others

  • View
    0

  • Download
    0

Embed Size (px)

Citation preview

Page 1: IEE 5037 Multimedia Communications Lecture 6: Still Image ...twins.ee.nctu.edu.tw/courses/multimedia_c_05spring/handout/MMC_07_Still image...5 JPEG-LS JPEG-LS is in the current ISO/ITU

IEE 5037 Multimedia CommunicationsLecture 6: Still Image Compression

Dep

t. Electro

nics E

ng

ineerin

g,N

ational Chiao T

ung University Adapted Prof. Hang’s and Chiang’s slides

Reading:DVP 20

Page 2: IEE 5037 Multimedia Communications Lecture 6: Still Image ...twins.ee.nctu.edu.tw/courses/multimedia_c_05spring/handout/MMC_07_Still image...5 JPEG-LS JPEG-LS is in the current ISO/ITU

2

Outlines

Bi-level image compressionG3/G4, JBIG, JBIG2

JPEGJPEG-LSJPEG2000 (in other lectures)

Page 3: IEE 5037 Multimedia Communications Lecture 6: Still Image ...twins.ee.nctu.edu.tw/courses/multimedia_c_05spring/handout/MMC_07_Still image...5 JPEG-LS JPEG-LS is in the current ISO/ITU

3

Bi-level Image Compression Standards

ITU G3/G4: Most widely used image compression standards for FAXCannot efficiently deal with digital haltfone imageG3:

Non-adaptive, 1-D run length codingLast K-1 lines of each group of K lines can be optionally 2-D run-length coded.Compression ratio 15:1

G4:Only 2-D run length coding allowed 30% better compression by removing error recovery from G3

JBIG: 30% better than G4Digital Half toning 8:1 compressionDeal with digital halftonesAdaptive arithmetic CodingAdaptive templates for halftonesLossless binary and low precision gray level (< 6 bits per pixel)Progressive transmission (pyramid transmission)

offers progressive encoding/decoding capability, the resulting bitstream contains a set of progressively higher resolution images

one bit/pixel using bit-plane codingJBIG2

Allow lossy compressionModel-based coding

Page 4: IEE 5037 Multimedia Communications Lecture 6: Still Image ...twins.ee.nctu.edu.tw/courses/multimedia_c_05spring/handout/MMC_07_Still image...5 JPEG-LS JPEG-LS is in the current ISO/ITU

4

Color Image Compression

Intended to be blank

Page 5: IEE 5037 Multimedia Communications Lecture 6: Still Image ...twins.ee.nctu.edu.tw/courses/multimedia_c_05spring/handout/MMC_07_Still image...5 JPEG-LS JPEG-LS is in the current ISO/ITU

5

JPEG-LSJPEG-LS is in the current ISO/ITU standard for lossless or “near lossless" compression of continuous tone images.

It is part of a larger ISO effort aimed at better compression ofmedical images.

Uses the LOCO-I (LOw COmplexity LOssless Compression for Images) algorithm proposed by Hewlett-Packard.

Motivated by the observation that complexity reduction is often more important than small increases in compression offered by more complex algorithms.

Main Advantage: Low complexity!

Page 6: IEE 5037 Multimedia Communications Lecture 6: Still Image ...twins.ee.nctu.edu.tw/courses/multimedia_c_05spring/handout/MMC_07_Still image...5 JPEG-LS JPEG-LS is in the current ISO/ITU

6

JPEG-LSThe LOCO-I algorithm makes uses of context modeling.

The idea of context modeling is to take advantage of the structure within the input source { the conditional probabilities}.

Example for context modelBinary source P(0) = 0.4, P(1) = 0.60th order entropy H(S) = -0.4log2(0.4) -0.6log2(0.6) = 0.97if previous symbol is 0, probability of current symbol being 0 is 0.8if previous symbol is 1, probability of current symbol being 0 is 0.1For context 0, H(S1) = -0.8log2(0.8) -0.2log2(0.2) = 0.72For context 1, H(S2) = -0.1log2(0.1) -0.9log(0.9) =0.47Avg bit rate = 0.4*0.72+0.6*0.47 = 0.57

JPEG-LS Context model

Page 7: IEE 5037 Multimedia Communications Lecture 6: Still Image ...twins.ee.nctu.edu.tw/courses/multimedia_c_05spring/handout/MMC_07_Still image...5 JPEG-LS JPEG-LS is in the current ISO/ITU

7

Why Do We Need Standards ?Image (and video) coding standards provide interoperability between codecs built by different manufacturers

Basis for most products in communication technologyStandards based products can be build with common software and hardware toolsOnly syntax and decoder specified

Standards provide state-of-the-art technology that is developed by a group of experts in the field

Actual performance depends on implementation of standard regarding error resilience, delay, displayEncoder is not standardized and its optimization is left to the manufacturer

Page 8: IEE 5037 Multimedia Communications Lecture 6: Still Image ...twins.ee.nctu.edu.tw/courses/multimedia_c_05spring/handout/MMC_07_Still image...5 JPEG-LS JPEG-LS is in the current ISO/ITU

8

The Scope of Picture and Video Coding Standardization

Only the Syntax and Decoder are standardized:Permits optimization beyond the obviousPermits complexity reduction for implementabilityProvides no guarantees of Quality

Pre-Processing EncodingSource

DestinationPost-Processing& Error Recovery

Decoding

Scope of Standard

Page 9: IEE 5037 Multimedia Communications Lecture 6: Still Image ...twins.ee.nctu.edu.tw/courses/multimedia_c_05spring/handout/MMC_07_Still image...5 JPEG-LS JPEG-LS is in the current ISO/ITU

9

JPEG

Joint Photographic Experts Group (ISO/JTC1/ SC2/WG10): Information Technology Still (color) image coding History: (Rao & Hwang, Chap. 8)

– Nov.1986: JPEG, joined by CCITT and ISO, was established– June 1987: 10 proposals were evaluated.Criteria : 3-stage progressive – .25 bpp, .75bpp, 4bpp

Three classes of algorithms selected: Adaptive DCT, Adaptive DPCM, Generalized block truncation coding

Page 10: IEE 5037 Multimedia Communications Lecture 6: Still Image ...twins.ee.nctu.edu.tw/courses/multimedia_c_05spring/handout/MMC_07_Still image...5 JPEG-LS JPEG-LS is in the current ISO/ITU

10

JPEG (cont.)

History: (cont.)– Jan.1988 : ADCT stood out in the second round contest

– Oct.1989 : Major technical points agreed – 1989 -1991: Refinement

– Feb. 1991: Committee draft finished– July 1992 : International Standard

(IS)10918-1 established

Page 11: IEE 5037 Multimedia Communications Lecture 6: Still Image ...twins.ee.nctu.edu.tw/courses/multimedia_c_05spring/handout/MMC_07_Still image...5 JPEG-LS JPEG-LS is in the current ISO/ITU

11

JPEG Operating ModesSequential (baseline)

JPEG Compatible : support at least base line

HierarchicalProgressiveLossless

Page 12: IEE 5037 Multimedia Communications Lecture 6: Still Image ...twins.ee.nctu.edu.tw/courses/multimedia_c_05spring/handout/MMC_07_Still image...5 JPEG-LS JPEG-LS is in the current ISO/ITU

12

JPEG FeaturesResolution independence

Multiple of 8 or Padding

PrecisionDCT operations restricted to 8 or 12 bit for input sampleLossless: 2~16 bpp

No bit rate targetRD tradeoff by quantization

Luminance-Chrominance separabilityYou can recover luminance only image

ExtensibleNo bounds on # of progressive stages or low resolution stages

Page 13: IEE 5037 Multimedia Communications Lecture 6: Still Image ...twins.ee.nctu.edu.tw/courses/multimedia_c_05spring/handout/MMC_07_Still image...5 JPEG-LS JPEG-LS is in the current ISO/ITU

13

Common Mode of Operations DCT based processSource image: 8-bit for each color componentSequential operationsHuffman coding

2 AC and 2 DC tables

Decoders process scans with 1, 2, 3, 4 componentsE.g. CMYK

Interleaved and non-interleaved scansNon-interleaved scans

One 16x16 Y, 8x8 Cr, 8x8 CbY1, Y2, Y3 … Y16, Cr1, Cr2, Cr3, Cr4, Cb1, Cb2, Cb3, Cb4

Interleaved scansY1, Y2, Y3, Y4, Cr1, Cb1, Y5, Y6, Y7, Y8, Cr2, Cb2

Page 14: IEE 5037 Multimedia Communications Lecture 6: Still Image ...twins.ee.nctu.edu.tw/courses/multimedia_c_05spring/handout/MMC_07_Still image...5 JPEG-LS JPEG-LS is in the current ISO/ITU

14

JPEG Baseline Coder

Sequential DCT coding<Encoder>

<Decoder>

FDCT QDPCM

Zig-zagscan

DCHuffman

ACHuffman

8*8block

Quantmatrices

DC

AC

Codebooks

Codes

Codebooks

DC inv-Huffman

AC inv-Huffman

IDPCM

IQ IDCT

DC

AC

Quantmatrices

8*8recons

block

DC offset

DC offset

Page 15: IEE 5037 Multimedia Communications Lecture 6: Still Image ...twins.ee.nctu.edu.tw/courses/multimedia_c_05spring/handout/MMC_07_Still image...5 JPEG-LS JPEG-LS is in the current ISO/ITU

15

Main Steps of JPEG BaselineInput data is 8-bitsDC offset

Level shift by substracting 2n-1

For 8-bit, subtract 128 to remove DC levelOnly affects DC value, shift a neural gray intensity to zero

DCTPrecision of DCT is unspecifiedIDCT precision: IEEE 1180.1 (withdrawed now)DCT on 8x8 blocks

Using blocks has the effect of isolating each block from its neighboring context. This is why JPEG images look choppy “blocky” when a high compression ratio

QuantizationQuantized DCT coefficients are restricted 11 bits

Zigzag scanVLC

DC: DPCMAC: VLC

Page 16: IEE 5037 Multimedia Communications Lecture 6: Still Image ...twins.ee.nctu.edu.tw/courses/multimedia_c_05spring/handout/MMC_07_Still image...5 JPEG-LS JPEG-LS is in the current ISO/ITU

16

Differential DC and Zig-zag Scan

where ‘s are quantized values.- ZigZag scan to produce long run of zeros

),1()()( −−=− iDCiDCiDiffDC

)(⋅DC

Page 17: IEE 5037 Multimedia Communications Lecture 6: Still Image ...twins.ee.nctu.edu.tw/courses/multimedia_c_05spring/handout/MMC_07_Still image...5 JPEG-LS JPEG-LS is in the current ISO/ITU

17

Quantization

Custom quantization table: Visibility threshold{Q (u, v )}, user specified, range [1 ~ 255]

Quantized coeffs.: (11 bits: [-128 x 8, 127 x 8])

Fq (u, v) = round ;

InverseR(u, v) = Fq (u, v) Q(u, v)

⎥⎦

⎤⎢⎣

⎡),(

),(

vuQ

vuF

Page 18: IEE 5037 Multimedia Communications Lecture 6: Still Image ...twins.ee.nctu.edu.tw/courses/multimedia_c_05spring/handout/MMC_07_Still image...5 JPEG-LS JPEG-LS is in the current ISO/ITU

18

Psychovisual AspectsSmall variation in intensity is more visible in flat areaMore visible in luminance

Page 19: IEE 5037 Multimedia Communications Lecture 6: Still Image ...twins.ee.nctu.edu.tw/courses/multimedia_c_05spring/handout/MMC_07_Still image...5 JPEG-LS JPEG-LS is in the current ISO/ITU

19

Examples of Quantization TableISO / IEC 10918-1 Annex K

Luminance table Chrominance table16 11 10 16 24 40 51 61 17 18 24 47 99 99 99 9912 12 14 19 26 58 60 55 18 21 26 66 99 99 99 9914 13 16 24 40 57 69 56 24 26 56 99 99 99 99 9914 17 22 29 51 87 80 62 47 66 99 99 99 99 99 9918 22 37 56 68 109 103 77 99 99 99 99 99 99 99 9924 35 55 64 81 104 113 92 99 99 99 99 99 99 99 9949 64 78 87 103 121 120 101 99 99 99 99 99 99 99 9972 92 95 98 112 100 103 99 99 99 99 99 99 99 99 99

Page 20: IEE 5037 Multimedia Communications Lecture 6: Still Image ...twins.ee.nctu.edu.tw/courses/multimedia_c_05spring/handout/MMC_07_Still image...5 JPEG-LS JPEG-LS is in the current ISO/ITU

20

Baseline Huffman Coding

Page 21: IEE 5037 Multimedia Communications Lecture 6: Still Image ...twins.ee.nctu.edu.tw/courses/multimedia_c_05spring/handout/MMC_07_Still image...5 JPEG-LS JPEG-LS is in the current ISO/ITU

21

Huffman DC Coding

Each DiffDC produces 2 pieces of information — size& amplitude.

DiffDC value (amplitude) : 12 bits (-2047,2047)DiffDC size : number of bits ( including sign) of the DiffDCvalue (amplitude) — 12 categories

Size is coded using variable-length-coding (VLC) —prefix Huffman codes. (Example is given in Annex K.)

Page 22: IEE 5037 Multimedia Communications Lecture 6: Still Image ...twins.ee.nctu.edu.tw/courses/multimedia_c_05spring/handout/MMC_07_Still image...5 JPEG-LS JPEG-LS is in the current ISO/ITU

22

Symbol-1 Structure

Page 23: IEE 5037 Multimedia Communications Lecture 6: Still Image ...twins.ee.nctu.edu.tw/courses/multimedia_c_05spring/handout/MMC_07_Still image...5 JPEG-LS JPEG-LS is in the current ISO/ITU

23

Huffman DC Coding (cont.)Amplitude

coded using variable-length-integer (VLI) — simply a shifted binary representation of the size bits (1’s Complement form)Size = 0, no additional bits are required

Huffman table for DC can be user specified or defaultIf user specified, transmit the table in the file header

Page 24: IEE 5037 Multimedia Communications Lecture 6: Still Image ...twins.ee.nctu.edu.tw/courses/multimedia_c_05spring/handout/MMC_07_Still image...5 JPEG-LS JPEG-LS is in the current ISO/ITU

24

Huffman AC Coding

31, 5, -3, 0, 0, 2, -1, 0, …, 0Example: runlength EOB (1010 for Y, 00 for Chroma)

Each non-zero AC coeff produces 3 pieces of information: { runlength, amplitude, and size}Runlength: Run of zero before this nonzero AC.

Values are restricted to 0 -15 (4 bits);>=16: use multiple runlength codes. R/S = x’F0’ (15 zero and

1 zero value), and count againAmplitude: value of AC coeff —11 bits (-1023,1023)

Page 25: IEE 5037 Multimedia Communications Lecture 6: Still Image ...twins.ee.nctu.edu.tw/courses/multimedia_c_05spring/handout/MMC_07_Still image...5 JPEG-LS JPEG-LS is in the current ISO/ITU

25

Huffman AC Coding (cont.)

Size: number of bits of the amplitude (11 categories)Before coding, merge runlength and size information together. Then, (runlength, size) is coded using VLC. (Example in Annex F)

RLC (runlength, size) = [#-zeros-to-skip , next non-zero value]

Amplitude is coded using VLI.

Page 26: IEE 5037 Multimedia Communications Lecture 6: Still Image ...twins.ee.nctu.edu.tw/courses/multimedia_c_05spring/handout/MMC_07_Still image...5 JPEG-LS JPEG-LS is in the current ISO/ITU

26

JPEG Default AC Huffman Table (for Luminance) Symbol 1

Page 27: IEE 5037 Multimedia Communications Lecture 6: Still Image ...twins.ee.nctu.edu.tw/courses/multimedia_c_05spring/handout/MMC_07_Still image...5 JPEG-LS JPEG-LS is in the current ISO/ITU

27

Symbol 2

Page 28: IEE 5037 Multimedia Communications Lecture 6: Still Image ...twins.ee.nctu.edu.tw/courses/multimedia_c_05spring/handout/MMC_07_Still image...5 JPEG-LS JPEG-LS is in the current ISO/ITU

28

Examples

After DCT and quantization

⎥⎥⎥⎥⎥⎥⎥

⎢⎢⎢⎢⎢⎢⎢

−−−−−

−−

0

0

00001001

00011111

00012123

012313520

[20,5,-3,-1,-2,-3,1,1,-1,-1,0,0,1,2,3,-2,1,1,0,0,0,0,0,0,1,1,0,1,EOB] 29: previous DC -9 (0,5) (0,-3) (0,-1) (0,-2) (0,-3) (0,1) (0,1) (0,1) (0,-1) (0,-1) (2,1) (0,2) (0,3) (0,-2) (0,1) (0,1) (6,1) (0,1) (0,1) (1,1) EOB

Zigzag scan

Run levelDPCM (101 0110/100 101/01 00/ …/1010)

Page 29: IEE 5037 Multimedia Communications Lecture 6: Still Image ...twins.ee.nctu.edu.tw/courses/multimedia_c_05spring/handout/MMC_07_Still image...5 JPEG-LS JPEG-LS is in the current ISO/ITU

29

Additional JPEG Coding ModesSequential DCT mode — BaselineProgressive DCT mode

Spectral selection — Low freq components of all blocks are transmitted first; then, higher freq. components.Successive approximation — The most significant (ms) 1-bits of every coeff is transmitted; then, the next ms bit.

Hierarchical mode: Using up- and down-sampling to increase/decrease spatial resolution.Lossless: DPCM — Prediction errors are coded using VLC.

Arithmetic coding are used in other modes than baselineMore complex, but extra 5 ~ 10% bit rate reduction

Page 30: IEE 5037 Multimedia Communications Lecture 6: Still Image ...twins.ee.nctu.edu.tw/courses/multimedia_c_05spring/handout/MMC_07_Still image...5 JPEG-LS JPEG-LS is in the current ISO/ITU

30

Transmission of DCT Coefficients

Page 31: IEE 5037 Multimedia Communications Lecture 6: Still Image ...twins.ee.nctu.edu.tw/courses/multimedia_c_05spring/handout/MMC_07_Still image...5 JPEG-LS JPEG-LS is in the current ISO/ITU

31

Transmission of DCT Coefficients

Page 32: IEE 5037 Multimedia Communications Lecture 6: Still Image ...twins.ee.nctu.edu.tw/courses/multimedia_c_05spring/handout/MMC_07_Still image...5 JPEG-LS JPEG-LS is in the current ISO/ITU

32

Hierarchical Coding

Page 33: IEE 5037 Multimedia Communications Lecture 6: Still Image ...twins.ee.nctu.edu.tw/courses/multimedia_c_05spring/handout/MMC_07_Still image...5 JPEG-LS JPEG-LS is in the current ISO/ITU

33

Loseless Coding (Replaced by JPEG-LS)

2:1 compression