David Chernyak Image Compression Presentation - Inside...

33

Transcript of David Chernyak Image Compression Presentation - Inside...

Page 1: David Chernyak Image Compression Presentation - Inside …inside.mines.edu/~whoff/courses/EENG510/projects/2012/David... · Image compression –reducing the amount of data ... Project
Page 2: David Chernyak Image Compression Presentation - Inside …inside.mines.edu/~whoff/courses/EENG510/projects/2012/David... · Image compression –reducing the amount of data ... Project

Introduction Image compression – reducing the amount of data required to represent an image

Motivation: Interest in how files can be represented so compactly Necessary for storage purposes

A 2 hour movie at 30 fps with 720 x 480 pixels/frame would require 224 GB of storage uncompressed

Page 3: David Chernyak Image Compression Presentation - Inside …inside.mines.edu/~whoff/courses/EENG510/projects/2012/David... · Image compression –reducing the amount of data ... Project

Motivation Applications

Movie compression Digital camera photos Web page images Televideo conferencing Medical imaging Many more

Page 4: David Chernyak Image Compression Presentation - Inside …inside.mines.edu/~whoff/courses/EENG510/projects/2012/David... · Image compression –reducing the amount of data ... Project

Project Goals Discuss several common file formats

JPEG JPEG‐2000 GIF PNG

Implement algorithms on sets of test images Compare and contrast important compression statistics: CR, SNR, RMSE

Page 5: David Chernyak Image Compression Presentation - Inside …inside.mines.edu/~whoff/courses/EENG510/projects/2012/David... · Image compression –reducing the amount of data ... Project

Previous Work Two main resources

Performance Analysis of Various Image Compression Techniques Discusses techniques such as Huffman Coding, DCT, etc Applies algorithms on a set of test images Compares using common image compression statistics

Digital Image Processing (Class Textbook) Large amounts of information on compression techniques

Page 6: David Chernyak Image Compression Presentation - Inside …inside.mines.edu/~whoff/courses/EENG510/projects/2012/David... · Image compression –reducing the amount of data ... Project

Previous Work Active Field Deanna Needell – Robust image recovery via total‐variation minimization (10/22/12) Importance of compression to store more data Discussed techniques for image compression Tries to minimize L1 norm Compares HaarWavelet Basis and Gradients 

Page 7: David Chernyak Image Compression Presentation - Inside …inside.mines.edu/~whoff/courses/EENG510/projects/2012/David... · Image compression –reducing the amount of data ... Project

File Format Summary JPEG

Joint Photographic Experts Group standard for photographic quality images

Lossy coding system most common (Lossless exists) Uses discrete cosine transforms on 8 x 8 image blocks, Huffman coding, run‐length coding

One of the most popular methods for compressing images

Page 8: David Chernyak Image Compression Presentation - Inside …inside.mines.edu/~whoff/courses/EENG510/projects/2012/David... · Image compression –reducing the amount of data ... Project

File Format Summary JPEG‐2000

Follow‐on to JPEG to try to increase compression of photographic quality images

Arithmetic coding and discrete wavelet transforms (DWT) are used. 

Compression can be lossy or lossless

Page 9: David Chernyak Image Compression Presentation - Inside …inside.mines.edu/~whoff/courses/EENG510/projects/2012/David... · Image compression –reducing the amount of data ... Project

File Format Summary GIF

Graphic Interchange Format Uses lossless LZW (Lempel‐Ziv‐Welch) coding 1‐8 bit images Frequently used to make small animations and low resolution films

Page 10: David Chernyak Image Compression Presentation - Inside …inside.mines.edu/~whoff/courses/EENG510/projects/2012/David... · Image compression –reducing the amount of data ... Project

File Format Summary PNG

Portable Network Graphics Lossless Compression of full color images Predictive Coding – difference between pixel values

Why not use TIFF? File format that operates as a container Can hold many different compression standards

Page 11: David Chernyak Image Compression Presentation - Inside …inside.mines.edu/~whoff/courses/EENG510/projects/2012/David... · Image compression –reducing the amount of data ... Project

JPEG

Block Transform Coding Map subimages into transform coefficients, encode

Lossy JPEG  8 x 8 subimages DCT  Quantize coefficients Huffman and run‐length coding

Page 12: David Chernyak Image Compression Presentation - Inside …inside.mines.edu/~whoff/courses/EENG510/projects/2012/David... · Image compression –reducing the amount of data ... Project

DCT

Page 13: David Chernyak Image Compression Presentation - Inside …inside.mines.edu/~whoff/courses/EENG510/projects/2012/David... · Image compression –reducing the amount of data ... Project

DCT 8x8 Basis Functions

Page 14: David Chernyak Image Compression Presentation - Inside …inside.mines.edu/~whoff/courses/EENG510/projects/2012/David... · Image compression –reducing the amount of data ... Project

Quantization JPEG committee suggests matrix with quanitzationlevel 50

Page 15: David Chernyak Image Compression Presentation - Inside …inside.mines.edu/~whoff/courses/EENG510/projects/2012/David... · Image compression –reducing the amount of data ... Project

Entropy Coding JPEG algorithm optimizes encoding based on transform properties DC encoded as difference between subimages

Large, variable, but often close to previous value

AC component: Run length coding Has lots of zeros Encode as  # of zeros followed by value of next non‐zero

Use Huffman coding to encode entire list Table generated in advance

Page 16: David Chernyak Image Compression Presentation - Inside …inside.mines.edu/~whoff/courses/EENG510/projects/2012/David... · Image compression –reducing the amount of data ... Project

JPEG‐2000

Main differences between JPEG‐2000 and JPEG DCT replaced with discrete wavelet transform (DWT)

Based on multi‐resolution image representation Purpose to obtain approximations of a function at different levels of resolution

Replaces Huffman coder with arithmetic coder Mathematically superior, slower to encode Typically makes file 5‐7% smaller

Page 17: David Chernyak Image Compression Presentation - Inside …inside.mines.edu/~whoff/courses/EENG510/projects/2012/David... · Image compression –reducing the amount of data ... Project

Discrete Wavelet Transform A function ψ is called a wavelet if it can be used to define a Hilbert basis Orthogonal basis for the space of square integrablefunctions

Hilbert basis: 

Representation: 

Page 18: David Chernyak Image Compression Presentation - Inside …inside.mines.edu/~whoff/courses/EENG510/projects/2012/David... · Image compression –reducing the amount of data ... Project
Page 19: David Chernyak Image Compression Presentation - Inside …inside.mines.edu/~whoff/courses/EENG510/projects/2012/David... · Image compression –reducing the amount of data ... Project

JPEG 2000 Wavelet Cohen‐Daubechies‐Feauveau wavelets (CDF) For ever positive integer A,

Lossless compression CDF 5/3 wavelet (A = 2)

Lossy compression CDF 9/7 wavelet (A = 4)

Page 20: David Chernyak Image Compression Presentation - Inside …inside.mines.edu/~whoff/courses/EENG510/projects/2012/David... · Image compression –reducing the amount of data ... Project

GIF LZW Coding

Lossless Replaces strings of characters with codes Requires no knowledge of the probability of occurrence For 8‐bit images, first 256 codes are assigned 0,1,…255 Then, sequences not in the dictionary are added

Example Assume dictionary     a = 0   b = 1    d = 2   n = 3   _ = 4

Page 21: David Chernyak Image Compression Presentation - Inside …inside.mines.edu/~whoff/courses/EENG510/projects/2012/David... · Image compression –reducing the amount of data ... Project

LZW ExampleInput Current 

StringSeen this? Encoded 

OutputNew Dictionary Entry

b b yes nothing none

ba ba no 1 ba/5

ban an no 1,0 an/6

bana na no 1,0,3 na/7

banan an yes no change none

banana ana no 1,0,3,6 ana/8

banana_ a_ no 1,0,3,6,0 a_/9

banana_b _b no 1,0,3,6,0,4 _b/10

banana_ba ba yes no change none

banana_ban ban no 1,0,3,6,0,4,5 ban/11

banana_band nd no 1,0,3,6,0,4,5,3 nd/12

banana_banda da no 1,0,3,6,0,4,5,3,2 da/13

banana_bandan an yes no change none

banana_bandana ana yes 1,0,3,6,0,4,5,3,2,8 none

Page 22: David Chernyak Image Compression Presentation - Inside …inside.mines.edu/~whoff/courses/EENG510/projects/2012/David... · Image compression –reducing the amount of data ... Project

LZW Coding LZW dictionary created while data is being encoded. Builds an identical decompression dictionary Long sequences for one code and repeated sequences optimize compression

Possible issues: Dictionary Overflow

Flush when full Flush when compression performance becomes poor

Page 23: David Chernyak Image Compression Presentation - Inside …inside.mines.edu/~whoff/courses/EENG510/projects/2012/David... · Image compression –reducing the amount of data ... Project

PNG Deflate compression algorithm

Lossless compression LZ77 algorithm

Replaces recurring patterns in data with a short code Maintains history buffer, tries to match to next part

Huffman coding

Page 24: David Chernyak Image Compression Presentation - Inside …inside.mines.edu/~whoff/courses/EENG510/projects/2012/David... · Image compression –reducing the amount of data ... Project

LZ77 Example String in look‐ahead buffer is searched for in history Longest match used, distance and length are recorded

Compression based on repetition Addressing must be limited

search look‐up output

abracadabra (0,0,a)

a bracadabra (0,0,b)

ab racadabra (0,0,r)

abr acadabra (3,1,c)

abrac adabra (2,1,d)

abracad abra (7,4,null)

Page 25: David Chernyak Image Compression Presentation - Inside …inside.mines.edu/~whoff/courses/EENG510/projects/2012/David... · Image compression –reducing the amount of data ... Project

Advantages JPEG

Can specify quality Useful for real images, photos Exploits properties that our eyes see best

JPEG‐2000 Multi‐resolution Arithmetic Coding Wavelets

GIF Supports animation LZW one of the best general purpose algorithms

PNG Designed as improvement to GIF Better compression, more options

Page 26: David Chernyak Image Compression Presentation - Inside …inside.mines.edu/~whoff/courses/EENG510/projects/2012/David... · Image compression –reducing the amount of data ... Project

Disadvantages JPEG

Not well suited to flat‐color or sharp‐edged images Compression effects are cumulative

JPEG‐2000 Resource intensive Does poorly at very high compression ratios (25 : 1)

GIF Maximum of 8 bits, 256 colors Doesn’t work well with bilevel or true color images

PNG No animation

Page 27: David Chernyak Image Compression Presentation - Inside …inside.mines.edu/~whoff/courses/EENG510/projects/2012/David... · Image compression –reducing the amount of data ... Project

ResultsJPEG ImageOriginal Image

JPEG‐2000 Image

Page 28: David Chernyak Image Compression Presentation - Inside …inside.mines.edu/~whoff/courses/EENG510/projects/2012/David... · Image compression –reducing the amount of data ... Project

Results

Page 29: David Chernyak Image Compression Presentation - Inside …inside.mines.edu/~whoff/courses/EENG510/projects/2012/David... · Image compression –reducing the amount of data ... Project

ResultsCR RMSE PSNR

JPEG 24.7 : 1 0.0098 64.28JPEG 2000 7.5 : 1 0.0011 83.08

GIF 5.0 : 1 0 infPNG 8.7 : 1 0 inf

CR RMSE PSNRJPEG 15.3 : 1 0.012 62.51

JPEG 2000 2.5 : 1 0.002 78.05GIF 1.3 : 1 0 infPNG 2.0 : 1 0 inf

CR RMSE PSNRJPEG 30.4 : 1 0.0081 65.93

JPEG 2000 6.9 : 1 0.0016 79.82GIF 3.1 : 1 0 infPNG 4.1 : 1 0 inf

CR RMSE PSNRJPEG 38.9 : 1 0.0056 69.09

JPEG 2000 6.4 : 1 0.0022 77.34GIF 1.8 : 1 0 infPNG 3.1 : 1 0 inf

CR RMSE PSNRJPEG 31.7 : 1 0.0066 67.71

JPEG 2000 5.6 : 1 0.0022 77.33GIF 1.7 : 1 0 infPNG 2.9 : 1 0 inf

Artificial Cathedral Fireworks

Flower FoodCR RMSE PSNR

JPEG 73.1 : 1 0.0259 55.81JPEG 2000 14.6 : 1 0.0019 78.62

GIF 9.3 : 1 0 infPNG 13.5 : 1 0 inf

Cameraman

Page 30: David Chernyak Image Compression Presentation - Inside …inside.mines.edu/~whoff/courses/EENG510/projects/2012/David... · Image compression –reducing the amount of data ... Project

Results

0

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

0 1 2 3 4 5 6 7

Com

pres

sion Ratio

Test

Compression Ratio for Different Pictures

JPEG

JPEG‐2000

GIF

PNG

Page 31: David Chernyak Image Compression Presentation - Inside …inside.mines.edu/~whoff/courses/EENG510/projects/2012/David... · Image compression –reducing the amount of data ... Project

Results

0

0.005

0.01

0.015

0.02

0.025

0.03

0 1 2 3 4 5 6 7

RMSE

Test

RMSE for Different Pictures

JPEG

JPEG‐2000

Page 32: David Chernyak Image Compression Presentation - Inside …inside.mines.edu/~whoff/courses/EENG510/projects/2012/David... · Image compression –reducing the amount of data ... Project

References [1] D. O. Kukreja, S.R. Suralkar, A.H. Karode, “Performance Analysis of 

Various Image Compression Techniques,” Pratibha: International Journal of Science, Spirituality, Business, and Technology (IJSSBT), Vol. 1, No.1, March 2012 pp. 98‐109

[2] R. Gonzalez, R. Woods. Digital Image Processing, third edition. Pearson Education International, 2007, pp. 547‐644. 

[3] T. Lee, P. Wu “Other Still Image Compression Standards” Internet: disp.ee.ntu.edu.tw/tutorial, Dec. 19, 2010 [Dec. 2012]. 

Page 33: David Chernyak Image Compression Presentation - Inside …inside.mines.edu/~whoff/courses/EENG510/projects/2012/David... · Image compression –reducing the amount of data ... Project

Questions?