Top Banner
Image Compression using SVD and DCT Math 2270-003 Spring 2012 Yizhou Ye
37

Image Compression using SVD and DCT - University … · Image Compression using SVD and DCT Math 2270-003 Spring 2012 ... Matrix? Matrix? Notes Image File = Header + RGB / GrayScale

Sep 06, 2018

Download

Documents

vuongkhanh
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: Image Compression using SVD and DCT - University … · Image Compression using SVD and DCT Math 2270-003 Spring 2012 ... Matrix? Matrix? Notes Image File = Header + RGB / GrayScale

Image Compression using SVD and DCT

Math 2270-003

Spring 2012

Yizhou Ye

Page 2: Image Compression using SVD and DCT - University … · Image Compression using SVD and DCT Math 2270-003 Spring 2012 ... Matrix? Matrix? Notes Image File = Header + RGB / GrayScale

Image? Matrix?

Page 3: Image Compression using SVD and DCT - University … · Image Compression using SVD and DCT Math 2270-003 Spring 2012 ... Matrix? Matrix? Notes Image File = Header + RGB / GrayScale

Matrix?

Page 4: Image Compression using SVD and DCT - University … · Image Compression using SVD and DCT Math 2270-003 Spring 2012 ... Matrix? Matrix? Notes Image File = Header + RGB / GrayScale

Notes

Image File = Header + RGB / GrayScale Maple / Matlab what do they do?

Page 5: Image Compression using SVD and DCT - University … · Image Compression using SVD and DCT Math 2270-003 Spring 2012 ... Matrix? Matrix? Notes Image File = Header + RGB / GrayScale

Matlab API

A = imread(filename, fmt) reads a grayscale or color image from the file specified by the string filename.

The return value A is an array containing the image data. If the file contains a grayscale image, A is an M-by-N array. If the file contains a true-color image, A is an M-by-N-by-3 array.

Page 6: Image Compression using SVD and DCT - University … · Image Compression using SVD and DCT Math 2270-003 Spring 2012 ... Matrix? Matrix? Notes Image File = Header + RGB / GrayScale

.jpeg, .jpg

Image == matrix? No. Approximate way

Page 7: Image Compression using SVD and DCT - University … · Image Compression using SVD and DCT Math 2270-003 Spring 2012 ... Matrix? Matrix? Notes Image File = Header + RGB / GrayScale

Basically

Read Image Matrix SVD / DCT done/ compressed

Page 8: Image Compression using SVD and DCT - University … · Image Compression using SVD and DCT Math 2270-003 Spring 2012 ... Matrix? Matrix? Notes Image File = Header + RGB / GrayScale

SVD

SVD: singular value decomposition

Page 9: Image Compression using SVD and DCT - University … · Image Compression using SVD and DCT Math 2270-003 Spring 2012 ... Matrix? Matrix? Notes Image File = Header + RGB / GrayScale

SVD

Note that A is m*n, U is m*m orthogonal matrix, Σ is an m*n matrix containing singular values of A, and V is an r*r orthogonal matrix. And the singular values of A are:

All these singular values are along the main diagonal of Σ.

We can rewrite the formula in the following way:

Page 10: Image Compression using SVD and DCT - University … · Image Compression using SVD and DCT Math 2270-003 Spring 2012 ... Matrix? Matrix? Notes Image File = Header + RGB / GrayScale

SVD

Page 11: Image Compression using SVD and DCT - University … · Image Compression using SVD and DCT Math 2270-003 Spring 2012 ... Matrix? Matrix? Notes Image File = Header + RGB / GrayScale

Approximation

Approximation of SVD is the most crucial part:

We know that the terms {Ai} are ordered from greatest to lowest, thus we can approximate A by varying the number of items. In other words, we can change the rank of A to make the approximation (of course, larger number gives us a more accurate approximation).

Page 12: Image Compression using SVD and DCT - University … · Image Compression using SVD and DCT Math 2270-003 Spring 2012 ... Matrix? Matrix? Notes Image File = Header + RGB / GrayScale

Example:

One term Three terms

Page 13: Image Compression using SVD and DCT - University … · Image Compression using SVD and DCT Math 2270-003 Spring 2012 ... Matrix? Matrix? Notes Image File = Header + RGB / GrayScale

Examples:

10 terms 50 terms

Page 14: Image Compression using SVD and DCT - University … · Image Compression using SVD and DCT Math 2270-003 Spring 2012 ... Matrix? Matrix? Notes Image File = Header + RGB / GrayScale

Examples:

100 terms 300 terms

Page 15: Image Compression using SVD and DCT - University … · Image Compression using SVD and DCT Math 2270-003 Spring 2012 ... Matrix? Matrix? Notes Image File = Header + RGB / GrayScale

Examples:

300 terms (rank) Original image

Page 16: Image Compression using SVD and DCT - University … · Image Compression using SVD and DCT Math 2270-003 Spring 2012 ... Matrix? Matrix? Notes Image File = Header + RGB / GrayScale

Issues

Compression Ratio: Not exactly (1+m+n) / (m*n) for a m*n A This plot is draw by matlab: Image is more complex

than we thought MatLab Read original size: 24206

Just the RGB / GrayScaler

Page 17: Image Compression using SVD and DCT - University … · Image Compression using SVD and DCT Math 2270-003 Spring 2012 ... Matrix? Matrix? Notes Image File = Header + RGB / GrayScale

Ratio

0

0.2

0.4

0.6

0.8

1

1.2

Ratio

Ratio

# of terms

Page 18: Image Compression using SVD and DCT - University … · Image Compression using SVD and DCT Math 2270-003 Spring 2012 ... Matrix? Matrix? Notes Image File = Header + RGB / GrayScale

Cost of items

-200

0

200

400

600

800

1000

1200

1400

1600

Cost of one term

index of terms

byte

Page 19: Image Compression using SVD and DCT - University … · Image Compression using SVD and DCT Math 2270-003 Spring 2012 ... Matrix? Matrix? Notes Image File = Header + RGB / GrayScale

DCT

“Discrete Cosine Transformation”, which works by separate image into parts of different frequencies.

A “lossy” compression, because during a step called “quantization”, where parts of compression occur, the less important frequencies will be discarded. Later in the “recombine parts” step, which is known as decompression step, some little distortion will occur, but it will be somehow adjusted in further steps.

Page 20: Image Compression using SVD and DCT - University … · Image Compression using SVD and DCT Math 2270-003 Spring 2012 ... Matrix? Matrix? Notes Image File = Header + RGB / GrayScale

DCT Equations

i, j are indices of the ij-th entry of the image matrix, p(x, y) is the matrix element in that entry, and N is the size of the block we are working on.

Page 21: Image Compression using SVD and DCT - University … · Image Compression using SVD and DCT Math 2270-003 Spring 2012 ... Matrix? Matrix? Notes Image File = Header + RGB / GrayScale

8 * 8 blocks

For a standard procedure where N=8, the equation can be also written as the following form:

Page 22: Image Compression using SVD and DCT - University … · Image Compression using SVD and DCT Math 2270-003 Spring 2012 ... Matrix? Matrix? Notes Image File = Header + RGB / GrayScale

T matrix

Page 23: Image Compression using SVD and DCT - University … · Image Compression using SVD and DCT Math 2270-003 Spring 2012 ... Matrix? Matrix? Notes Image File = Header + RGB / GrayScale

Procedure

Break the image matrix into 8*8 pixel blocks Applying DCT equations to each block in level

order Each block is compressed through

quantization Basically done. When desired, it can be decompressed, by

Inverse Discrete Cosine Transformation.

Page 24: Image Compression using SVD and DCT - University … · Image Compression using SVD and DCT Math 2270-003 Spring 2012 ... Matrix? Matrix? Notes Image File = Header + RGB / GrayScale

Example of DCT

Page 25: Image Compression using SVD and DCT - University … · Image Compression using SVD and DCT Math 2270-003 Spring 2012 ... Matrix? Matrix? Notes Image File = Header + RGB / GrayScale

-128 for each entry

Since pixels are valued from -128 to 127

Page 26: Image Compression using SVD and DCT - University … · Image Compression using SVD and DCT Math 2270-003 Spring 2012 ... Matrix? Matrix? Notes Image File = Header + RGB / GrayScale

Apply D = TMT’

T matrix is from the previous equations.

Page 27: Image Compression using SVD and DCT - University … · Image Compression using SVD and DCT Math 2270-003 Spring 2012 ... Matrix? Matrix? Notes Image File = Header + RGB / GrayScale

Human eye fact

The human eye is fairly good at seeing small differences in brightness over a relatively large area

But not so good at distinguishing the exact strength of a high frequency (rapidly varying) brightness variation.

Page 28: Image Compression using SVD and DCT - University … · Image Compression using SVD and DCT Math 2270-003 Spring 2012 ... Matrix? Matrix? Notes Image File = Header + RGB / GrayScale

We know the fact, then

This fact allows one to reduce the amount of information required by ignoring the high frequency components. This is done by simply dividing each component in the frequency domain by a constant for that component, and then rounding to the nearest integer.

This is the main lossy operation in the whole process. As a result of this, it is typically the case that many of the higher frequency components are rounded to zero, and many of the rest become small positive or negative numbers.

Page 29: Image Compression using SVD and DCT - University … · Image Compression using SVD and DCT Math 2270-003 Spring 2012 ... Matrix? Matrix? Notes Image File = Header + RGB / GrayScale

Quantization Matrix

Page 30: Image Compression using SVD and DCT - University … · Image Compression using SVD and DCT Math 2270-003 Spring 2012 ... Matrix? Matrix? Notes Image File = Header + RGB / GrayScale

Quantization

quantization level = 50, a common choice of Q matrix

Page 31: Image Compression using SVD and DCT - University … · Image Compression using SVD and DCT Math 2270-003 Spring 2012 ... Matrix? Matrix? Notes Image File = Header + RGB / GrayScale

Round Equation

Typically, upper left corner. Thus we apply zig-zag order:

Page 32: Image Compression using SVD and DCT - University … · Image Compression using SVD and DCT Math 2270-003 Spring 2012 ... Matrix? Matrix? Notes Image File = Header + RGB / GrayScale

Zip-Zag Ordering

Page 33: Image Compression using SVD and DCT - University … · Image Compression using SVD and DCT Math 2270-003 Spring 2012 ... Matrix? Matrix? Notes Image File = Header + RGB / GrayScale

Original VS. Decompressed

Page 34: Image Compression using SVD and DCT - University … · Image Compression using SVD and DCT Math 2270-003 Spring 2012 ... Matrix? Matrix? Notes Image File = Header + RGB / GrayScale

Examples

Page 35: Image Compression using SVD and DCT - University … · Image Compression using SVD and DCT Math 2270-003 Spring 2012 ... Matrix? Matrix? Notes Image File = Header + RGB / GrayScale

More Examples

Page 36: Image Compression using SVD and DCT - University … · Image Compression using SVD and DCT Math 2270-003 Spring 2012 ... Matrix? Matrix? Notes Image File = Header + RGB / GrayScale

Finale

Image can be expressed by matrix somehow, but image is much more than that.

SVD and DCT are techniques to compress image, but both of them are “lossy”.

Still many other ways to compress:

Page 37: Image Compression using SVD and DCT - University … · Image Compression using SVD and DCT Math 2270-003 Spring 2012 ... Matrix? Matrix? Notes Image File = Header + RGB / GrayScale

Thank you!