1 Image Compression. 2 GIF: Graphics Interchange Format Basic mode Dynamic mode A LZW method.

27
1 Image Compression Image Compression

Transcript of 1 Image Compression. 2 GIF: Graphics Interchange Format Basic mode Dynamic mode A LZW method.

Page 1: 1 Image Compression. 2 GIF: Graphics Interchange Format Basic mode Dynamic mode A LZW method.

1

Image CompressionImage Compression

Page 2: 1 Image Compression. 2 GIF: Graphics Interchange Format Basic mode Dynamic mode A LZW method.

2

GIF: Graphics Interchange FormatGIF: Graphics Interchange FormatBasic mode

Dynamic mode

A LZW method

Page 3: 1 Image Compression. 2 GIF: Graphics Interchange Format Basic mode Dynamic mode A LZW method.

3

GIF Interlaced ModeGIF Interlaced Mode

Page 4: 1 Image Compression. 2 GIF: Graphics Interchange Format Basic mode Dynamic mode A LZW method.

4

TIFF: Tagged Image File FormatTIFF: Tagged Image File Format

Supports pixel resolution up to 48 bits (16x3) Intended for transfer both images and digitized

documents Code #1: uncompressed format Code # 2, 3, 4: digitized document Code # 5: LZW-comprfessed

Page 5: 1 Image Compression. 2 GIF: Graphics Interchange Format Basic mode Dynamic mode A LZW method.

5

Digitized DocumentsDigitized Documents

FAX: T4(Group 3) T6 (Group 4) for ISDN Use modified Huffman codes See Fig 3.11

Page 6: 1 Image Compression. 2 GIF: Graphics Interchange Format Basic mode Dynamic mode A LZW method.

6

JPEGJPEG

Page 7: 1 Image Compression. 2 GIF: Graphics Interchange Format Basic mode Dynamic mode A LZW method.

7

What is the JPEG? What is the JPEG? JPEG: Joint Photographic Experts Group

general-purpose compression standard of for continuous-tone still image (gray scale and color)

jointly developed by ITU-T and ISO

Encoding modes Lossless mode Sequential DCT-based mode (baseline mode) Progressive DCT-based mode Hierarchical mode

Page 8: 1 Image Compression. 2 GIF: Graphics Interchange Format Basic mode Dynamic mode A LZW method.

8

JPEG EncodingJPEG Encoding

Sequential (baseline) mode

Progressive mode

Hierarchical mode

Page 9: 1 Image Compression. 2 GIF: Graphics Interchange Format Basic mode Dynamic mode A LZW method.

9

Progressive ModeProgressive Mode Each image component is encoded in multiple

scans Successive refinement on a rough image untill

reaching the requested quality

Bit rate is same with that of sequential mode a kind of data re-ordering

Preview image can be generated without he need to completely decode the image

Page 10: 1 Image Compression. 2 GIF: Graphics Interchange Format Basic mode Dynamic mode A LZW method.

10

Hierarchical ModeHierarchical Mode A progressive presentation Encodes an image at multiple resolutions For a low resolution display device a ‘best’ image is

available Hierarchical mode : without receiving unnecessary data for

higher resolution Progressive mode : only after the total transmission time for the

full-resolution Hierarchical mode is more effective in network

environment

Page 11: 1 Image Compression. 2 GIF: Graphics Interchange Format Basic mode Dynamic mode A LZW method.

11

Major Steps of Image CompressionMajor Steps of Image Compression Picture (Image) Preparation

analogue-to-digital conversion through sampling A picture is divided into blocks of 8x8 pixels

Picture (Image) Processing: source coding forward DCT

Quantization: lossy mapping of the real numbers into integers

Entropy Encoding: lossless Run length coding Huffman coding or Arithmetic coding

Picture Preparation

Picture Preparation

Picture Processing

Picture Processing QuantizationQuantization Entropy

Encoding

EntropyEncoding

UncompressedPicture

CompressedPicture

Page 12: 1 Image Compression. 2 GIF: Graphics Interchange Format Basic mode Dynamic mode A LZW method.

12

JPEG Encoder SchematicJPEG Encoder Schematic

Page 13: 1 Image Compression. 2 GIF: Graphics Interchange Format Basic mode Dynamic mode A LZW method.

13

Image PreparationImage Preparation

Separation of source image into color components 1 ~ 255 components (or plane)

e.g.) 1 component for gray-scale image, 3 components for RGB, or YCbCr

Each component may have different horizontal resolution e.g.) YUV: 4:2:0 format

Subdivision of components into 8x8 pixel blocks noninterleaved date ordering: component by component interleaved data ordering

Page 14: 1 Image Compression. 2 GIF: Graphics Interchange Format Basic mode Dynamic mode A LZW method.

14

Image/Block PreparationImage/Block Preparation

Block preparation

Page 15: 1 Image Compression. 2 GIF: Graphics Interchange Format Basic mode Dynamic mode A LZW method.

15

JPEG Compression/DecompressionJPEG Compression/DecompressionCompression Steps

Decompression Steps

Page 16: 1 Image Compression. 2 GIF: Graphics Interchange Format Basic mode Dynamic mode A LZW method.

16

Discrete Cosine TransformDiscrete Cosine Transform

One-dimensional DCT: used in audio Two-dimensional DCT: used in image

Spatial or temporal domain frequency domain Each 8x8 block of samples is transformed

Intuition Sampled values usually vary slightly from point to point

Coefficient of the low frequency high value Coefficient of high frequencies small or zero

Human eyes is highly sensitive at low-intensity levels, whereas its sensitivity is greatly reduced at high-intensity levels A reduction of the number of high-frequency DCT coefficients

weakly affects image quality

Page 17: 1 Image Compression. 2 GIF: Graphics Interchange Format Basic mode Dynamic mode A LZW method.

17

Forward DCT (1)Forward DCT (1) In theory, DCT is lossless.

In practice, information is lost because of truncation errors in calculation

Forward DCT

,16

)12((cos

16

)12(cos],[)()(

4

1],[

7,...,1,0,7,...,1,07

0

7

0

x y

jyixyxPjCiCjiF

ji

otherwise

jiforjCiCwhere

,1

0, ,21)()(

Page 18: 1 Image Compression. 2 GIF: Graphics Interchange Format Basic mode Dynamic mode A LZW method.

18

Forward DCT(2)Forward DCT(2)

Page 19: 1 Image Compression. 2 GIF: Graphics Interchange Format Basic mode Dynamic mode A LZW method.

19

Forward DCT (3)Forward DCT (3)

FDCT

x

y

u

v64 DCTcoefficients

Spatial domain Frequency domain

Page 20: 1 Image Compression. 2 GIF: Graphics Interchange Format Basic mode Dynamic mode A LZW method.

20

QuantizationQuantization 64 DCT coefficients are

quantized according to an quantization table specified by application.

Lossy Quantization levels are

different for each frequency more precise level for low

freq. determined by experiments

Quantization matrices are suggested by JPEG

Page 21: 1 Image Compression. 2 GIF: Graphics Interchange Format Basic mode Dynamic mode A LZW method.

21

Entropy EncodingEntropy Encoding

DC coefficients from consecutive DCT blocks Differential encoding

AC coefficients Run-length encoding

Then, Huffman encoding is used

Page 22: 1 Image Compression. 2 GIF: Graphics Interchange Format Basic mode Dynamic mode A LZW method.

22

Vectoring using zig-zag scanVectoring using zig-zag scan

Data reordering: zigzag sequence low frequency comes first (larger values come first)

Page 23: 1 Image Compression. 2 GIF: Graphics Interchange Format Basic mode Dynamic mode A LZW method.

23

Differential EncodingDifferential Encoding

DC coefficients in consecutive quantized blocks 12, 13, 11, 11, 10, … 12, 1, -2, 0, -1, … Encoded in the form (SSS, value), where SSS: # of

bits needed to encode the value

Page 24: 1 Image Compression. 2 GIF: Graphics Interchange Format Basic mode Dynamic mode A LZW method.

24

Run-length EncodingRun-length Encoding

Remaining 63 AC coefficients in the vector may contain long strings of zeros Use RLE: (skip, value),

where skip: # of zeros in the run, value: next nonzero coefficient

(0,6)(0,7)(0,3)(0,3)(0,3)(0,2)(0,2)(0,2)(0,2)(0,0)(0,0) indicates the end of the string for this block

The value field is encoded in the form SSS/value

Page 25: 1 Image Compression. 2 GIF: Graphics Interchange Format Basic mode Dynamic mode A LZW method.

25

Huffman EncodingHuffman Encoding

JPEG provides the Huffman code tables used with DC and AC coefficients for both luminance and chrominance Arithmetic encoding is also specified in JPEG, but

protected by patent

Page 26: 1 Image Compression. 2 GIF: Graphics Interchange Format Basic mode Dynamic mode A LZW method.

26

Frame BuildingFrame Building

Frame header contains Width and height of a

complete image/picture Number and type of

components (CLUT, RGB, YCbCr)

Digitization format (4:2:2, 4:2:0, etc)

Scan: contains a component

Scan header contains Identity of components

(R/G/B) # of bits used to digitize

each component Quantization table

Page 27: 1 Image Compression. 2 GIF: Graphics Interchange Format Basic mode Dynamic mode A LZW method.

27

JPEG DecodingJPEG Decoding

In progressive mode, first the DC and low-frequency coefficients of each block are sent

In hierarchical mode, the total image is first sent using a low resolution – i.e. 320x240 – then at high resolution 640x480