36
T.Sharon-A.Frank 1 Multimedia Image Compression

T.Sharon-A.Frank 1 Multimedia Image Compression 2 T.Sharon-A.Frank Coding Techniques – Hybrid

Embed Size (px)

Citation preview

Page 1: T.Sharon-A.Frank 1 Multimedia Image Compression 2 T.Sharon-A.Frank Coding Techniques – Hybrid

T.Sharon-A.Frank1

Multimedia

Image Compression

Page 2: T.Sharon-A.Frank 1 Multimedia Image Compression 2 T.Sharon-A.Frank Coding Techniques – Hybrid

2T.Sharon-A.Frank

Coding Techniques – Hybrid

Run-length

HuffmanEntropy coding

Arithmetic

Prediction (relative)DPCM, ADPCMDM, MC

TransformationFFTDCT

Layered (progressive)Bit positionSubsamplingSub-band coding

Source coding

Vector quantizationJPEG, MJPEGMPEG

Hybrid codingH.261

Page 3: T.Sharon-A.Frank 1 Multimedia Image Compression 2 T.Sharon-A.Frank Coding Techniques – Hybrid

3T.Sharon-A.Frank

Hybrid coding

• Images:– JPEG

• Video/Audio– MJPEG

– MPEG (1, 2, 4)

– Other codings

– H.26x

Page 4: T.Sharon-A.Frank 1 Multimedia Image Compression 2 T.Sharon-A.Frank Coding Techniques – Hybrid

4

• Image files may be too big for network transmission, even at low resolutions.

• Use more sophisticated data representation or discard information to reduce data size.

• Effectiveness of compression will depend on actual image data.

• For any compression scheme, there will always be some data for which 'compressed' version is actually bigger than the original.

Image Compression

Page 5: T.Sharon-A.Frank 1 Multimedia Image Compression 2 T.Sharon-A.Frank Coding Techniques – Hybrid

5T.Sharon-A.Frank

Compression Steps

1. Preparation: analog to digital conversion.2. Processing: transform data into a domain

easier to compress.3. Quantization: reduce precision at which the

output is stored.4. Entropy encoding: remove redundant

information in the resulting data stream.

PicturePreparation

PictureProcessing

Quanti-zation

EntropyEncodingImage

UncompressedImage

Compressed

Page 6: T.Sharon-A.Frank 1 Multimedia Image Compression 2 T.Sharon-A.Frank Coding Techniques – Hybrid

6T.Sharon-A.Frank

JPEG

Goals:• Support still images• True color/grayscale• Continuous-tone

pictures• Usually lossy

Subjects:• Quality• Steps• Modes

Joint Photographic Experts Group

Page 7: T.Sharon-A.Frank 1 Multimedia Image Compression 2 T.Sharon-A.Frank Coding Techniques – Hybrid

7T.Sharon-A.Frank

JPEG Picture Quality

• 0.25 – 0.5 bits/pixel

Moderate to good quality.• 0.5 – 0.75 bits/pixel

Good to very good quality.• 0.75 – 1.5 bits/pixel

Excellent quality. • 1.5 – 2.0 bits/pixel

Usually indistinguishable

from the original.

Page 8: T.Sharon-A.Frank 1 Multimedia Image Compression 2 T.Sharon-A.Frank Coding Techniques – Hybrid

8

• Lossy technique, well suited to photographs, images with fine detail and continuous tones.

• Consider image as a spatially varying signal that can be analysed in the frequency domain.

• Experimental fact: people do not perceive the effect of high frequencies in images very accurately.

• Hence, high frequency information can be discarded without perceptible loss of quality.

JPEG Compression

Page 9: T.Sharon-A.Frank 1 Multimedia Image Compression 2 T.Sharon-A.Frank Coding Techniques – Hybrid

9T.Sharon-A.Frank

Stage 1: Image Preparation

C1

C2

Cn

* * * ** * * ** **

Yj

Xi

Samples

Left Right

Line

1<= n <=255, usually 3

Top

Bottom

Components

Page 10: T.Sharon-A.Frank 1 Multimedia Image Compression 2 T.Sharon-A.Frank Coding Techniques – Hybrid

10T.Sharon-A.Frank

3 components having the same resolution

A1 A2

An

Y

X

B1 B2

Bn

Y

X

C1 C2

Cn

Y

X

Page 11: T.Sharon-A.Frank 1 Multimedia Image Compression 2 T.Sharon-A.Frank Coding Techniques – Hybrid

11T.Sharon-A.Frank

A1 A2

An

Y

X

B1 B2

Bn/2

Y

X/2

C1 C2

Cn/2

Y

X/2

3 components having different resolution

Page 12: T.Sharon-A.Frank 1 Multimedia Image Compression 2 T.Sharon-A.Frank Coding Techniques – Hybrid

12

• If image resolution < output device resolution, must interpolate extra pixels– Always leads to loss of quality.

• If image resolution > output device resolution, must downsample (discard pixels):– Quality will often be better than that of an image at

device resolution (uses more information).– Image sampled at a higher resolution than that of

intended output device is over sampled.

Changing Resolution

Page 13: T.Sharon-A.Frank 1 Multimedia Image Compression 2 T.Sharon-A.Frank Coding Techniques – Hybrid

13T.Sharon-A.Frank

Block Preparation

(a ) . ) ( RGB input data b After block preparation.

Page 14: T.Sharon-A.Frank 1 Multimedia Image Compression 2 T.Sharon-A.Frank Coding Techniques – Hybrid

14T.Sharon-A.Frank

Non Interleaved Order of Data Units

Left Right

Top

* * * * * * * ** * * * * * * ** * * * * * * ** * * * * * * ** * * * * * * *

Bottom

MCU = Minimum Coded Unit

Page 15: T.Sharon-A.Frank 1 Multimedia Image Compression 2 T.Sharon-A.Frank Coding Techniques – Hybrid

15T.Sharon-A.Frank

Interleaved Data Units

* ** *

* ** *

* ** *

* ** *

* ** *

* ** *

0 1 2 3 4 5

0

1

2

3

* * 0 1 2 3 4 5

0

1

* * * ** * * * * *

0 1 2

0

1

2

3

**

**

**

**

**

**

0 1 2

0

1

* * ** * *

Page 16: T.Sharon-A.Frank 1 Multimedia Image Compression 2 T.Sharon-A.Frank Coding Techniques – Hybrid

16T.Sharon-A.Frank

Stage 2: Image Processing

• Using DCT (Discrete Cosine Transform)

• Convert from Spatial to Frequency Domain

• Input : 8x8 matrix of 64 values

• Output: – 1 DC value (basic color of block = average color)– 63 AC values

• low frequency coefficients, have high values

• high frequency coefficients – represent sharp edges, have low values

Page 17: T.Sharon-A.Frank 1 Multimedia Image Compression 2 T.Sharon-A.Frank Coding Techniques – Hybrid

17T.Sharon-A.Frank

Discrete Cosine Transform (DCT)

• A Fourier-related transform similar to the Discrete Fourier Transform (DFT), but using only real numbers.

• Often used in signal and image processing.• Maps values from spatial domain to frequency

domain – image areas with low frequency (large blocks of single color) are compressed more efficiently.

• Used in JPEG, MJPEG, MPEG, and DV Compression.

Page 18: T.Sharon-A.Frank 1 Multimedia Image Compression 2 T.Sharon-A.Frank Coding Techniques – Hybrid

18

• Analyses a signal into its frequency components.

• Takes array of pixel values, produces an array of coefficients of frequency components in the image.

• Computationally expensive process – time proportional to square of number of pixels.

• Usually applied to 8x8 blocks of pixels.

DCT Dynamics

Page 19: T.Sharon-A.Frank 1 Multimedia Image Compression 2 T.Sharon-A.Frank Coding Techniques – Hybrid

19T.Sharon-A.Frank

JPEG: DCT-Based Encoder

8x8 blocks

CompressedImage Data

QuantizerEntropyEncoder

FDCT

TableSpecification

TableSpecification

SourceImage Data

Page 20: T.Sharon-A.Frank 1 Multimedia Image Compression 2 T.Sharon-A.Frank Coding Techniques – Hybrid

20T.Sharon-A.Frank

Blocki-1 Blocki

DCiDCi-1

DIFF=DCi-DCi-1

Preparation of DC Coefficients

Page 21: T.Sharon-A.Frank 1 Multimedia Image Compression 2 T.Sharon-A.Frank Coding Techniques – Hybrid

21T.Sharon-A.Frank

(a) One block of the Y matrix. (b) The DCT coefficients.

DCT Transformation

Page 22: T.Sharon-A.Frank 1 Multimedia Image Compression 2 T.Sharon-A.Frank Coding Techniques – Hybrid

22T.Sharon-A.Frank

Preparation of AC Coefficients

AC07AC01DC

AC77AC70

Zig-Zag Sequence

Page 23: T.Sharon-A.Frank 1 Multimedia Image Compression 2 T.Sharon-A.Frank Coding Techniques – Hybrid

23T.Sharon-A.Frank

Probability Distribution of DCT Coefficients

Probabilityof being nonzero

0.0 8 16 24 32 40 48 56 77

1.0

0.5

Zigzag index

Page 24: T.Sharon-A.Frank 1 Multimedia Image Compression 2 T.Sharon-A.Frank Coding Techniques – Hybrid

24T.Sharon-A.Frank

Next Stages

• Stage 3: Quantization

Based on quantization table:– Quantization table: values from 1 to 255– DCT coefficient/Table value– If value > 0, keep DCT coefficient

else, don’t keep DCT coefficient

• Stage 4: Entropy Encoding

Page 25: T.Sharon-A.Frank 1 Multimedia Image Compression 2 T.Sharon-A.Frank Coding Techniques – Hybrid

25

• Applying DCT does not reduce data size– Array of coefficients is same size as array of pixels.

• Allows information about high frequency components to be identified and discarded.

• Use fewer bits (distinguish fewer different values) for higher frequency components.

• Number of levels for each frequency coefficient may be specified separately in a quantization matrix.

JPEG Quantization

Page 26: T.Sharon-A.Frank 1 Multimedia Image Compression 2 T.Sharon-A.Frank Coding Techniques – Hybrid

26T.Sharon-A.Frank

Computation of the quantized DCT coefficients

Page 27: T.Sharon-A.Frank 1 Multimedia Image Compression 2 T.Sharon-A.Frank Coding Techniques – Hybrid

27T.Sharon-A.Frank

Order in which the quantized values are transmitted

Page 28: T.Sharon-A.Frank 1 Multimedia Image Compression 2 T.Sharon-A.Frank Coding Techniques – Hybrid

28

• After quantization, there will be many zero coefficients.– Use RLE on zig-zag sequence (maximizes runs).

• Use Huffman coding of other coefficients (best use of available bits).

JPEG Entropy Encoding

Page 29: T.Sharon-A.Frank 1 Multimedia Image Compression 2 T.Sharon-A.Frank Coding Techniques – Hybrid

29T.Sharon-A.Frank

Steps of JPEG Compression

PicturePreparation

Pixel

Block, MCU

PictureProcessing

Predictor

FDCT

Quantization

EntropyEncoding

Run-Length

Huffman

Arithmetic

Steps taking into account the different JPEG modes

Page 30: T.Sharon-A.Frank 1 Multimedia Image Compression 2 T.Sharon-A.Frank Coding Techniques – Hybrid

30

• Expand runs of zeros and decompress Huffman- encoded coefficients to reconstruct array of frequency coefficients.

• Use Inverse Discrete Cosine Transform to take data back from frequency to spatial domain.

• Data discarded in quantization step of compression procedure cannot be recovered.

• Reconstructed image is an approximation (usually very good) to the original image.

JPEG Decompression

Page 31: T.Sharon-A.Frank 1 Multimedia Image Compression 2 T.Sharon-A.Frank Coding Techniques – Hybrid

31T.Sharon-A.Frank

JPEG: DCT-Based Decoder

DequantizerEntropyEncoder

IDCT

TableSpecification

TableSpecification

Reconstructed Image Data

Compressed Image Data

Page 32: T.Sharon-A.Frank 1 Multimedia Image Compression 2 T.Sharon-A.Frank Coding Techniques – Hybrid

32T.Sharon-A.Frank

JPEG Modes of Operation

• Lossless Encoding: the image is encoded to guarantee exact recovery of every source image sample value (low compression ratio).

• Sequential Encoding: each image is encoded in a single left-to-right, top-to-bottom scan.

• Progressive Encoding: the image is encoded in multiple scans for applications in which transmission time is long.

• Hierarchical Encoding: the image is encoded at multiple resolutions.

Page 33: T.Sharon-A.Frank 1 Multimedia Image Compression 2 T.Sharon-A.Frank Coding Techniques – Hybrid

33T.Sharon-A.Frank

Sequential Presentation

Page 34: T.Sharon-A.Frank 1 Multimedia Image Compression 2 T.Sharon-A.Frank Coding Techniques – Hybrid

34T.Sharon-A.Frank

Progressive Presentation

Page 35: T.Sharon-A.Frank 1 Multimedia Image Compression 2 T.Sharon-A.Frank Coding Techniques – Hybrid

35T.Sharon-A.Frank

Types of image processing in DCT

Image display Bits per sample Entropy codingSequential 8 Huffman coding

Sequential 8 Arithmetic coding

Sequential 12 Huffman coding

Sequential 12 Arithmetic coding

Progressive successive 8 Huffman coding

Progressive spectral 8 Huffman coding

Progressive successive 8 Arithmetic coding

Progressive spectral 8 Arithmetic coding

Progressive successive 12 Huffman coding

Progressive spectral 12 Huffman coding

Progressive successive 12 Arithmetic coding

Progressive spectral 12 Arithmetic coding

Page 36: T.Sharon-A.Frank 1 Multimedia Image Compression 2 T.Sharon-A.Frank Coding Techniques – Hybrid

36T.Sharon-A.Frank

Hybrid Coding Examples

• JPEG – image compression using a discrete cosine

transform, then quantization, then Huffman coding. • JPEG 2000

– image compression using wavelets, then quantization, then entropy coding.

• MP3– A part of the MPEG-1 standard for sound and

music compression, using subbanding and MDCT, perceptual modeling, quantization, and Huffman coding.