Top Banner
Outline Introduction Images and Compression Walkthrough of JPEG Compression Steps Complete Compression Process Results and Conclusion JPEG Compression Ian Snyder December 11, 2009 Ian Snyder JPEG Compression
45

JPEG Compression - College of the Redwoods · Images and Compression Walkthrough of JPEG Compression Steps Complete Compression Process Results and Conclusion Discrete Cosine Transform

Aug 14, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: JPEG Compression - College of the Redwoods · Images and Compression Walkthrough of JPEG Compression Steps Complete Compression Process Results and Conclusion Discrete Cosine Transform

OutlineIntroduction

Images and CompressionWalkthrough of JPEG Compression Steps

Complete Compression ProcessResults and Conclusion

JPEG Compression

Ian Snyder

December 11, 2009

Ian Snyder JPEG Compression

Page 2: JPEG Compression - College of the Redwoods · Images and Compression Walkthrough of JPEG Compression Steps Complete Compression Process Results and Conclusion Discrete Cosine Transform

OutlineIntroduction

Images and CompressionWalkthrough of JPEG Compression Steps

Complete Compression ProcessResults and Conclusion

Introduction

Images and Compression

Walkthrough of JPEG Compression Steps

Complete Compression Process

Results and Conclusion

Ian Snyder JPEG Compression

Page 3: JPEG Compression - College of the Redwoods · Images and Compression Walkthrough of JPEG Compression Steps Complete Compression Process Results and Conclusion Discrete Cosine Transform

OutlineIntroduction

Images and CompressionWalkthrough of JPEG Compression Steps

Complete Compression ProcessResults and Conclusion

JPEG Image Compression Standard

I Need for a standard

I History, develpoment and adoption of JPEG’s standard

I Widespread use

Ian Snyder JPEG Compression

Page 4: JPEG Compression - College of the Redwoods · Images and Compression Walkthrough of JPEG Compression Steps Complete Compression Process Results and Conclusion Discrete Cosine Transform

OutlineIntroduction

Images and CompressionWalkthrough of JPEG Compression Steps

Complete Compression ProcessResults and Conclusion

JPEG Image Compression Standard

I Need for a standard

I History, develpoment and adoption of JPEG’s standard

I Widespread use

Ian Snyder JPEG Compression

Page 5: JPEG Compression - College of the Redwoods · Images and Compression Walkthrough of JPEG Compression Steps Complete Compression Process Results and Conclusion Discrete Cosine Transform

OutlineIntroduction

Images and CompressionWalkthrough of JPEG Compression Steps

Complete Compression ProcessResults and Conclusion

JPEG Image Compression Standard

I Need for a standard

I History, develpoment and adoption of JPEG’s standard

I Widespread use

Ian Snyder JPEG Compression

Page 6: JPEG Compression - College of the Redwoods · Images and Compression Walkthrough of JPEG Compression Steps Complete Compression Process Results and Conclusion Discrete Cosine Transform

OutlineIntroduction

Images and CompressionWalkthrough of JPEG Compression Steps

Complete Compression ProcessResults and Conclusion

Image Compression

Definition: The compression of graphics for storage and/ortransmission.

Ian Snyder JPEG Compression

Page 7: JPEG Compression - College of the Redwoods · Images and Compression Walkthrough of JPEG Compression Steps Complete Compression Process Results and Conclusion Discrete Cosine Transform

OutlineIntroduction

Images and CompressionWalkthrough of JPEG Compression Steps

Complete Compression ProcessResults and Conclusion

Compression Methods

I Lossless Compression: Compression that does not remove anydata from the original file.

I Lossy Compression: Compression that deletes information inorder to achieve a better compression ratio.

Ian Snyder JPEG Compression

Page 8: JPEG Compression - College of the Redwoods · Images and Compression Walkthrough of JPEG Compression Steps Complete Compression Process Results and Conclusion Discrete Cosine Transform

OutlineIntroduction

Images and CompressionWalkthrough of JPEG Compression Steps

Complete Compression ProcessResults and Conclusion

Compression Methods

I Lossless Compression: Compression that does not remove anydata from the original file.

I Lossy Compression: Compression that deletes information inorder to achieve a better compression ratio.

Ian Snyder JPEG Compression

Page 9: JPEG Compression - College of the Redwoods · Images and Compression Walkthrough of JPEG Compression Steps Complete Compression Process Results and Conclusion Discrete Cosine Transform

OutlineIntroduction

Images and CompressionWalkthrough of JPEG Compression Steps

Complete Compression ProcessResults and Conclusion

Bitmap Images

A bitmap image is represented by an array of bits that correspondto pixel colors.

Ian Snyder JPEG Compression

Page 10: JPEG Compression - College of the Redwoods · Images and Compression Walkthrough of JPEG Compression Steps Complete Compression Process Results and Conclusion Discrete Cosine Transform

OutlineIntroduction

Images and CompressionWalkthrough of JPEG Compression Steps

Complete Compression ProcessResults and Conclusion

Image Types

There are three general types of bitmap images:

I Intensity Images

I Indexed (256-color) Images

I RGB (Truecolor) Images

Ian Snyder JPEG Compression

Page 11: JPEG Compression - College of the Redwoods · Images and Compression Walkthrough of JPEG Compression Steps Complete Compression Process Results and Conclusion Discrete Cosine Transform

OutlineIntroduction

Images and CompressionWalkthrough of JPEG Compression Steps

Complete Compression ProcessResults and Conclusion

RGB Example Image

Ian Snyder JPEG Compression

Page 12: JPEG Compression - College of the Redwoods · Images and Compression Walkthrough of JPEG Compression Steps Complete Compression Process Results and Conclusion Discrete Cosine Transform

OutlineIntroduction

Images and CompressionWalkthrough of JPEG Compression Steps

Complete Compression ProcessResults and Conclusion

Seal Image

This is the intensity image that was compressed step by step.

Ian Snyder JPEG Compression

Page 13: JPEG Compression - College of the Redwoods · Images and Compression Walkthrough of JPEG Compression Steps Complete Compression Process Results and Conclusion Discrete Cosine Transform

OutlineIntroduction

Images and CompressionWalkthrough of JPEG Compression Steps

Complete Compression ProcessResults and Conclusion

JPEG Compression Steps

I The Discrete Cosine Transform

I Quantization

I Reordering

I Huffman Coding

Ian Snyder JPEG Compression

Page 14: JPEG Compression - College of the Redwoods · Images and Compression Walkthrough of JPEG Compression Steps Complete Compression Process Results and Conclusion Discrete Cosine Transform

OutlineIntroduction

Images and CompressionWalkthrough of JPEG Compression Steps

Complete Compression ProcessResults and Conclusion

Block Division of Image Matrix

When an image is JPEG compressed, it it first sliced into 8× 8matrix blocks of pixel entries.

Ian Snyder JPEG Compression

Page 15: JPEG Compression - College of the Redwoods · Images and Compression Walkthrough of JPEG Compression Steps Complete Compression Process Results and Conclusion Discrete Cosine Transform

OutlineIntroduction

Images and CompressionWalkthrough of JPEG Compression Steps

Complete Compression ProcessResults and Conclusion

Example Image Matrix

This is the matrix taken from the top left corner of the ‘Seal’image:

O =

182 181 176 178 176 177 173 175182 184 177 176 179 174 176 173176 176 176 180 178 174 171 168182 174 176 180 177 169 168 168180 172 181 178 171 170 173 172181 170 171 170 170 178 174 174176 174 170 170 171 182 179 166176 173 170 176 173 181 179 168

Ian Snyder JPEG Compression

Page 16: JPEG Compression - College of the Redwoods · Images and Compression Walkthrough of JPEG Compression Steps Complete Compression Process Results and Conclusion Discrete Cosine Transform

OutlineIntroduction

Images and CompressionWalkthrough of JPEG Compression Steps

Complete Compression ProcessResults and Conclusion

Discrete Cosine Transform

I The discrete cosine transform converts an image matrix fromits spatial domain into a frequency domain.

I Greater changes in luminosity across the image arerepresented by higher frequencies.

I The greatest frequencies are concentrated in the upper left ofthe matrix.

Ian Snyder JPEG Compression

Page 17: JPEG Compression - College of the Redwoods · Images and Compression Walkthrough of JPEG Compression Steps Complete Compression Process Results and Conclusion Discrete Cosine Transform

OutlineIntroduction

Images and CompressionWalkthrough of JPEG Compression Steps

Complete Compression ProcessResults and Conclusion

Discrete Cosine Transform

I The discrete cosine transform converts an image matrix fromits spatial domain into a frequency domain.

I Greater changes in luminosity across the image arerepresented by higher frequencies.

I The greatest frequencies are concentrated in the upper left ofthe matrix.

Ian Snyder JPEG Compression

Page 18: JPEG Compression - College of the Redwoods · Images and Compression Walkthrough of JPEG Compression Steps Complete Compression Process Results and Conclusion Discrete Cosine Transform

OutlineIntroduction

Images and CompressionWalkthrough of JPEG Compression Steps

Complete Compression ProcessResults and Conclusion

Discrete Cosine Transform

I The discrete cosine transform converts an image matrix fromits spatial domain into a frequency domain.

I Greater changes in luminosity across the image arerepresented by higher frequencies.

I The greatest frequencies are concentrated in the upper left ofthe matrix.

Ian Snyder JPEG Compression

Page 19: JPEG Compression - College of the Redwoods · Images and Compression Walkthrough of JPEG Compression Steps Complete Compression Process Results and Conclusion Discrete Cosine Transform

OutlineIntroduction

Images and CompressionWalkthrough of JPEG Compression Steps

Complete Compression ProcessResults and Conclusion

DCT Equation

Cuv = αuαv

M−1∑m=0

N−1∑n=0

Amncosπ(2m + 1)u

2Mcos

π(2n + 1)v

2N

0 ≤ u ≤ M − 1, 0 ≤ v ≤ N − 1

Ian Snyder JPEG Compression

Page 20: JPEG Compression - College of the Redwoods · Images and Compression Walkthrough of JPEG Compression Steps Complete Compression Process Results and Conclusion Discrete Cosine Transform

OutlineIntroduction

Images and CompressionWalkthrough of JPEG Compression Steps

Complete Compression ProcessResults and Conclusion

DCT Equation Continued

αu =

{1/√

M, if p = 0,√2/M, if 1 ≤ p ≤ M − 1

αv =

{1/√

M, if p = 0,√2/M, if 1 ≤ p ≤ M − 1

Ian Snyder JPEG Compression

Page 21: JPEG Compression - College of the Redwoods · Images and Compression Walkthrough of JPEG Compression Steps Complete Compression Process Results and Conclusion Discrete Cosine Transform

OutlineIntroduction

Images and CompressionWalkthrough of JPEG Compression Steps

Complete Compression ProcessResults and Conclusion

DCT Matrix

The previous equation produces this DCT matrix ‘C’:

C =

.353 .353 .353 .353 .353 .353 .353 .353

.490 .415 .277 .097 −.097 −.277 −.415 −.490

.461 .191 −.191 −.461 −.461 −.191 .191 .461

.415 −.097 −.490 −.277 .277 .490 .097 −.415

.353 −.353 −.353 .353 .353 −.353 −.353 .353

.277 −.490 .097 .415 −.415 −.097 .490 −.277

.191 −.461 .461 −.191 −.191 .461 −.461 .191

.097 −.277 .415 −.490 .490 −.415 .277 −.097

Ian Snyder JPEG Compression

Page 22: JPEG Compression - College of the Redwoods · Images and Compression Walkthrough of JPEG Compression Steps Complete Compression Process Results and Conclusion Discrete Cosine Transform

OutlineIntroduction

Images and CompressionWalkthrough of JPEG Compression Steps

Complete Compression ProcessResults and Conclusion

Applying the DCT

Matrix ‘C’ is then applied to each 8× 8 block matrix ‘A’ as follows:

D = CACT

Ian Snyder JPEG Compression

Page 23: JPEG Compression - College of the Redwoods · Images and Compression Walkthrough of JPEG Compression Steps Complete Compression Process Results and Conclusion Discrete Cosine Transform

OutlineIntroduction

Images and CompressionWalkthrough of JPEG Compression Steps

Complete Compression ProcessResults and Conclusion

DCT Applied to the Example Matrix

The DCT is now applied to the example 8× 8 matrix:

D =

376.12 13.58 −.99 10.16 .37 6.70 .54 −2.069.64 9.97 −1.75 −7.70 6.32 −6.77 −2.98 1.775.24 −6.02 2.05 7.20 −7.09 −3.05 −3.76 −4.34.48 −2.14 8.93 −.52 −.65 .10 5.10 .051

1.12 3.51 −1.91 −4.79 4.37 2.96 .92 −.19−3.62 .35 −2.44 3.88 .042 −.70 .32 −1.94−2.03 −3.09 −1.01 .22 2.80 .22 2.94 −2.40−.34 −9.40 −3.36 −2.92 −3.73 1.89 .15 −.24

Ian Snyder JPEG Compression

Page 24: JPEG Compression - College of the Redwoods · Images and Compression Walkthrough of JPEG Compression Steps Complete Compression Process Results and Conclusion Discrete Cosine Transform

OutlineIntroduction

Images and CompressionWalkthrough of JPEG Compression Steps

Complete Compression ProcessResults and Conclusion

Quantization

I Quantization is where compression really happens in JPEG’sprocess.

I Information is discarded from the image at this point, and itcannot be recovered.

Ian Snyder JPEG Compression

Page 25: JPEG Compression - College of the Redwoods · Images and Compression Walkthrough of JPEG Compression Steps Complete Compression Process Results and Conclusion Discrete Cosine Transform

OutlineIntroduction

Images and CompressionWalkthrough of JPEG Compression Steps

Complete Compression ProcessResults and Conclusion

Quantization

I Quantization is where compression really happens in JPEG’sprocess.

I Information is discarded from the image at this point, and itcannot be recovered.

Ian Snyder JPEG Compression

Page 26: JPEG Compression - College of the Redwoods · Images and Compression Walkthrough of JPEG Compression Steps Complete Compression Process Results and Conclusion Discrete Cosine Transform

OutlineIntroduction

Images and CompressionWalkthrough of JPEG Compression Steps

Complete Compression ProcessResults and Conclusion

Quantization Process

I The quantization process takes DCT matrix D and divideseach entry in that matrix by each entry in a quantizationmatrix Q, resulting in the quantized matrix R.

I

R = round

(Dij

Qij

)

Ian Snyder JPEG Compression

Page 27: JPEG Compression - College of the Redwoods · Images and Compression Walkthrough of JPEG Compression Steps Complete Compression Process Results and Conclusion Discrete Cosine Transform

OutlineIntroduction

Images and CompressionWalkthrough of JPEG Compression Steps

Complete Compression ProcessResults and Conclusion

Quantization Process

I The quantization process takes DCT matrix D and divideseach entry in that matrix by each entry in a quantizationmatrix Q, resulting in the quantized matrix R.

I

R = round

(Dij

Qij

)

Ian Snyder JPEG Compression

Page 28: JPEG Compression - College of the Redwoods · Images and Compression Walkthrough of JPEG Compression Steps Complete Compression Process Results and Conclusion Discrete Cosine Transform

OutlineIntroduction

Images and CompressionWalkthrough of JPEG Compression Steps

Complete Compression ProcessResults and Conclusion

Quantization Matrix

This is the standard JPEG quatization matrix for the luminancecoefficients:

Q =

16 11 10 16 24 40 51 6112 12 14 19 26 58 60 5514 13 16 24 40 57 69 5614 17 22 29 51 87 80 6218 22 37 56 68 109 103 7724 35 55 64 81 104 113 9249 64 78 87 103 121 120 10172 92 95 98 112 100 103 99

Ian Snyder JPEG Compression

Page 29: JPEG Compression - College of the Redwoods · Images and Compression Walkthrough of JPEG Compression Steps Complete Compression Process Results and Conclusion Discrete Cosine Transform

OutlineIntroduction

Images and CompressionWalkthrough of JPEG Compression Steps

Complete Compression ProcessResults and Conclusion

Quantized Image Matrix

This is the result of quantizing the example matrix:

R =

24 1 0 1 0 0 0 01 1 0 0 0 0 0 00 0 0 0 0 0 0 00 0 0 0 0 0 0 00 0 0 0 0 0 0 00 0 0 0 0 0 0 00 0 0 0 0 0 0 00 0 0 0 0 0 0 0

Ian Snyder JPEG Compression

Page 30: JPEG Compression - College of the Redwoods · Images and Compression Walkthrough of JPEG Compression Steps Complete Compression Process Results and Conclusion Discrete Cosine Transform

OutlineIntroduction

Images and CompressionWalkthrough of JPEG Compression Steps

Complete Compression ProcessResults and Conclusion

Reordering

I The matrix is now transformed into a vector and reordered.

I This allows a long string of zero entries to be eliminated.

Ian Snyder JPEG Compression

Page 31: JPEG Compression - College of the Redwoods · Images and Compression Walkthrough of JPEG Compression Steps Complete Compression Process Results and Conclusion Discrete Cosine Transform

OutlineIntroduction

Images and CompressionWalkthrough of JPEG Compression Steps

Complete Compression ProcessResults and Conclusion

Reordering

I The matrix is now transformed into a vector and reordered.

I This allows a long string of zero entries to be eliminated.

Ian Snyder JPEG Compression

Page 32: JPEG Compression - College of the Redwoods · Images and Compression Walkthrough of JPEG Compression Steps Complete Compression Process Results and Conclusion Discrete Cosine Transform

OutlineIntroduction

Images and CompressionWalkthrough of JPEG Compression Steps

Complete Compression ProcessResults and Conclusion

Reordering Sequence

Ian Snyder JPEG Compression

Page 33: JPEG Compression - College of the Redwoods · Images and Compression Walkthrough of JPEG Compression Steps Complete Compression Process Results and Conclusion Discrete Cosine Transform

OutlineIntroduction

Images and CompressionWalkthrough of JPEG Compression Steps

Complete Compression ProcessResults and Conclusion

Reordered Matrix

This is result of the reordering sequence performed on thequantized image matrix:

V = [24 1 1 0 1 0 1 0 0 0 0 0 ...] (1)

Ian Snyder JPEG Compression

Page 34: JPEG Compression - College of the Redwoods · Images and Compression Walkthrough of JPEG Compression Steps Complete Compression Process Results and Conclusion Discrete Cosine Transform

OutlineIntroduction

Images and CompressionWalkthrough of JPEG Compression Steps

Complete Compression ProcessResults and Conclusion

Full Image Compression

I All 8× 8 blocks are DCTed, quantized, and reordered using aspreviously shown.

I The reordered strings of entries are now shortened byeliminating all zeros following the last non-zero entry.

I An ‘End of Block’ marker is place at the end of each string,and all reordered “blocks” are placed in one long line.

Ian Snyder JPEG Compression

Page 35: JPEG Compression - College of the Redwoods · Images and Compression Walkthrough of JPEG Compression Steps Complete Compression Process Results and Conclusion Discrete Cosine Transform

OutlineIntroduction

Images and CompressionWalkthrough of JPEG Compression Steps

Complete Compression ProcessResults and Conclusion

Full Image Compression

I All 8× 8 blocks are DCTed, quantized, and reordered using aspreviously shown.

I The reordered strings of entries are now shortened byeliminating all zeros following the last non-zero entry.

I An ‘End of Block’ marker is place at the end of each string,and all reordered “blocks” are placed in one long line.

Ian Snyder JPEG Compression

Page 36: JPEG Compression - College of the Redwoods · Images and Compression Walkthrough of JPEG Compression Steps Complete Compression Process Results and Conclusion Discrete Cosine Transform

OutlineIntroduction

Images and CompressionWalkthrough of JPEG Compression Steps

Complete Compression ProcessResults and Conclusion

Full Image Compression

I All 8× 8 blocks are DCTed, quantized, and reordered using aspreviously shown.

I The reordered strings of entries are now shortened byeliminating all zeros following the last non-zero entry.

I An ‘End of Block’ marker is place at the end of each string,and all reordered “blocks” are placed in one long line.

Ian Snyder JPEG Compression

Page 37: JPEG Compression - College of the Redwoods · Images and Compression Walkthrough of JPEG Compression Steps Complete Compression Process Results and Conclusion Discrete Cosine Transform

OutlineIntroduction

Images and CompressionWalkthrough of JPEG Compression Steps

Complete Compression ProcessResults and Conclusion

Huffman Coding

I Huffman coding allows redundancies in the values of thestring of entries to be exploited, compressing the image fileeven more.

I The original symbols (in this case, pixel values) are mapped tounique strings of bits based on their relative frequency in thesample.

Ian Snyder JPEG Compression

Page 38: JPEG Compression - College of the Redwoods · Images and Compression Walkthrough of JPEG Compression Steps Complete Compression Process Results and Conclusion Discrete Cosine Transform

OutlineIntroduction

Images and CompressionWalkthrough of JPEG Compression Steps

Complete Compression ProcessResults and Conclusion

Example Huffman Tree

Ian Snyder JPEG Compression

Page 39: JPEG Compression - College of the Redwoods · Images and Compression Walkthrough of JPEG Compression Steps Complete Compression Process Results and Conclusion Discrete Cosine Transform

OutlineIntroduction

Images and CompressionWalkthrough of JPEG Compression Steps

Complete Compression ProcessResults and Conclusion

Final Storage

I The final string of bits produced by the Huffman Coding willbe stored as a JPEG file.

I When the file is read, it will be decompressed through theinverse steps.

Ian Snyder JPEG Compression

Page 40: JPEG Compression - College of the Redwoods · Images and Compression Walkthrough of JPEG Compression Steps Complete Compression Process Results and Conclusion Discrete Cosine Transform

OutlineIntroduction

Images and CompressionWalkthrough of JPEG Compression Steps

Complete Compression ProcessResults and Conclusion

Final Storage

I The final string of bits produced by the Huffman Coding willbe stored as a JPEG file.

I When the file is read, it will be decompressed through theinverse steps.

Ian Snyder JPEG Compression

Page 41: JPEG Compression - College of the Redwoods · Images and Compression Walkthrough of JPEG Compression Steps Complete Compression Process Results and Conclusion Discrete Cosine Transform

OutlineIntroduction

Images and CompressionWalkthrough of JPEG Compression Steps

Complete Compression ProcessResults and Conclusion

Compression Results

I The final results of compressing the Seal image yielded abouta 10:1 compression ratio.

I Original image size: 1769 kilobytes

I Compressed image size: 158 kilobytes

Ian Snyder JPEG Compression

Page 42: JPEG Compression - College of the Redwoods · Images and Compression Walkthrough of JPEG Compression Steps Complete Compression Process Results and Conclusion Discrete Cosine Transform

OutlineIntroduction

Images and CompressionWalkthrough of JPEG Compression Steps

Complete Compression ProcessResults and Conclusion

Compressed Seal Image

Ian Snyder JPEG Compression

Page 43: JPEG Compression - College of the Redwoods · Images and Compression Walkthrough of JPEG Compression Steps Complete Compression Process Results and Conclusion Discrete Cosine Transform

OutlineIntroduction

Images and CompressionWalkthrough of JPEG Compression Steps

Complete Compression ProcessResults and Conclusion

Original Image

Ian Snyder JPEG Compression

Page 44: JPEG Compression - College of the Redwoods · Images and Compression Walkthrough of JPEG Compression Steps Complete Compression Process Results and Conclusion Discrete Cosine Transform

OutlineIntroduction

Images and CompressionWalkthrough of JPEG Compression Steps

Complete Compression ProcessResults and Conclusion

Conclusion

The ‘Seal’ image has been successfully compressed with goodresults and all the steps of the JPEG compression method havebeen outlined and described.

Ian Snyder JPEG Compression

Page 45: JPEG Compression - College of the Redwoods · Images and Compression Walkthrough of JPEG Compression Steps Complete Compression Process Results and Conclusion Discrete Cosine Transform

OutlineIntroduction

Images and CompressionWalkthrough of JPEG Compression Steps

Complete Compression ProcessResults and Conclusion

Bibliography

Austin, David. Image Compression: Seeing What’s Not There.Holloway, Catherine. JPEG Image Compression: Transformation,Quantization, and Encoding.O’Hanen, Ben and Matthew Wisan. “JPEG Compression”.Student Projects in Linear Algebra. Ed. David Arnold. 16 Dec.2005. Accessed 2 Sept. 2009.Penfield, Paul. “Chapter 3: Compression”. Notes. 12 Feb. 2004.MIT. Accessed 6 Sept. 2009.Poynton, Charles. Digital Video and HDTV: Algorithms andInterfacesWallace, Gregory K. “The JPEG Still Picture CompressionStandard”. Communications of the ACM. 1 April 1991: 30-44.Accessed online.

Ian Snyder JPEG Compression