software research image compression mohamed n. ahmed, ph.d

67
Software Research Software Research Digital Image Digital Image Processing Processing Image Compression Mohamed N. Ahmed, Ph.D.

Upload: evelyn-hodge

Post on 24-Dec-2015

232 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Software Research Image Compression Mohamed N. Ahmed, Ph.D

Software ResearchSoftware Research

Digital Image ProcessingDigital Image Processing

Image Compression

Mohamed N. Ahmed, Ph.D.

Page 2: Software Research Image Compression Mohamed N. Ahmed, Ph.D

Software ResearchSoftware Research

Digital Image ProcessingDigital Image Processing

Image Compression

• Everyday an enormous amount of information is stored, processed, and transmitted

• Financial data

• Reports

• Inventory

• Cable TV

• Online Ordering and tracking

0

20

40

60

80

100

1st Qtr 2nd

Qtr

3rd Qtr4th Qtr

East

West

North

Page 3: Software Research Image Compression Mohamed N. Ahmed, Ph.D

Software ResearchSoftware Research

Digital Image ProcessingDigital Image Processing

Image Compression

• Because much of this information is graphical or pictorial in nature, the storage and communications requirements are immense.

• Image compression addresses the problem of reducing the amount of data requirements to represent a digital image.

• Image Compression is becoming an enabling technology: HDTV.

• Also it plays an important role in Video Conferencing, remote sensing, satellite TV, FAX, document and medical imaging.

Page 4: Software Research Image Compression Mohamed N. Ahmed, Ph.D

Software ResearchSoftware Research

Digital Image ProcessingDigital Image Processing

Image Compression

• We want to remove redundancy from the data

• Mathematically

Transformation2D array Of pixels

Statistically Uncorrelated data

Page 5: Software Research Image Compression Mohamed N. Ahmed, Ph.D

Software ResearchSoftware Research

Digital Image ProcessingDigital Image Processing

Day4 : Image Compression

Outline:1. Fundamentals

Coding RedundancyInterpixel RedundancyPsychovisual RedundancyFidelity Criteria

2. Error-Free CompressionVariable-length CodingLZW CodingPredictive Coding

3. Lossy CompressionTransform CodingWavelet Coding

4. Image Compression Standards

Page 6: Software Research Image Compression Mohamed N. Ahmed, Ph.D

Software ResearchSoftware Research

Digital Image ProcessingDigital Image Processing

Fundamentals

• The term data compression refers to the process of reducing the amount of data required to represent a given quantity of information

• Data Information

• Various amount of data can be used to represent the same information

• Data might contain elements that provide no relevant information : data redundancy

• Data redundancy is a central issue in image compression. It is not an abstract concept but mathematically quantifiable entity

Some Images are adopted from R. C. Gonzalez & R. E. Woods

Page 7: Software Research Image Compression Mohamed N. Ahmed, Ph.D

Software ResearchSoftware Research

Digital Image ProcessingDigital Image Processing

Data Redundancy

• Let n1 and n2 denote the number of information carrying units in two data sets that represent the same information

• The relative redundancy RD is define as :

where CR, commonly called the compression ratio, is

2

1

11

n

nC

CR

R

RD

Page 8: Software Research Image Compression Mohamed N. Ahmed, Ph.D

Software ResearchSoftware Research

Digital Image ProcessingDigital Image Processing

Data Redundancy

• If n1 = n2 , CR=1 and RD=0 no redundancy

• If n1 >> n2 , CR and RD high redundancy

• If n1 << n2 , CR and RD undesirable

• A compression ration of 10 (10:1) means that the first data set has 10 information carrying units (say, bits) for every 1 unit in the second (compressed) data set.

• In Image compression , 3 basic redundancy can be identified» Coding Redundancy

» Interpixel Redundancy

» Psychovisual Redundancy

10

Page 9: Software Research Image Compression Mohamed N. Ahmed, Ph.D

Software ResearchSoftware Research

Digital Image ProcessingDigital Image Processing

Coding Redundancy

• Recall from the histogram calculations

where p(rk) is the probability of a pixel to have a certain value rk

If the number of bits used to represent rk is l(rk), then

)()((

)()(

1

0

L

kkkav

kkk

rprlL

n

n

n

rhrp

Page 10: Software Research Image Compression Mohamed N. Ahmed, Ph.D

Software ResearchSoftware Research

Digital Image ProcessingDigital Image Processing

Coding Redundancy

• Example:

Page 11: Software Research Image Compression Mohamed N. Ahmed, Ph.D

Software ResearchSoftware Research

Digital Image ProcessingDigital Image Processing

Coding Redundancy

Variable-LengthCoding

Page 12: Software Research Image Compression Mohamed N. Ahmed, Ph.D

Software ResearchSoftware Research

Digital Image ProcessingDigital Image Processing

Inter-pixel Redundancy

Here the two pictures have Approximately the same Histogram.

We must exploit Pixel Dependencies.

Each pixel can be estimated From its neighbors.

Page 13: Software Research Image Compression Mohamed N. Ahmed, Ph.D

Software ResearchSoftware Research

Digital Image ProcessingDigital Image Processing

Run-Length Encoding

Example of Inter-pixel Redundancy removal

Page 14: Software Research Image Compression Mohamed N. Ahmed, Ph.D

Software ResearchSoftware Research

Digital Image ProcessingDigital Image Processing

Psycho-visual Redundancy

The human visual system is more sensitive to edges

Middle Picture: Uniform quantization from 256 to 16 gray levelsCR= 2

Right picture: Improved gray level quantization(IGS)CR= 2

Page 15: Software Research Image Compression Mohamed N. Ahmed, Ph.D

Software ResearchSoftware Research

Digital Image ProcessingDigital Image Processing

Fidelity Criteria

2

1

0

1

0

)],(),([1

)],(),([

),(),(),(

yxfyxfMN

e

yxfyxf

yxfyxfyxe

rms

M

x

N

y

The error between two functions is given by:

So, the total error between the two images is

The root-mean-square error averaged over the whole image is

Page 16: Software Research Image Compression Mohamed N. Ahmed, Ph.D

Software ResearchSoftware Research

Digital Image ProcessingDigital Image Processing

Fidelity Criteria

• A closely related objective fidelity criterion is the mean square signal to noise ratio of the compressed-decompressed image

21

0

1

0

21

0

1

0

)],(),([

),(

yxfyxf

yxf

SNR M

x

N

y

M

x

N

yms

Page 17: Software Research Image Compression Mohamed N. Ahmed, Ph.D

Software ResearchSoftware Research

Digital Image ProcessingDigital Image Processing

Fidelity Criteria

Page 18: Software Research Image Compression Mohamed N. Ahmed, Ph.D

Software ResearchSoftware Research

Digital Image ProcessingDigital Image Processing

Compression Model

The source encoder is responsible for removing redundancy(coding, inter-pixel, psycho-visual)

The channel encoder ensures robustness against channel noise.

Page 19: Software Research Image Compression Mohamed N. Ahmed, Ph.D

Software ResearchSoftware Research

Digital Image ProcessingDigital Image Processing

Compression Types

Compression

Error-Free Compression(Loss-less)

Lossy Compression

Page 20: Software Research Image Compression Mohamed N. Ahmed, Ph.D

Software ResearchSoftware Research

Digital Image ProcessingDigital Image Processing

Error-Free Compression

• Some applications require no error in compression (medical, business documents, etc..)

• CR=2 to 10 can be expected.

• Make use of coding redundancy and inter-pixel redundancy.

• Ex: Huffman codes, LZW, Arithmetic coding, 1D and 2D run-length encoding, Loss-less Predictive Coding, and Bit-Plane Coding.

Page 21: Software Research Image Compression Mohamed N. Ahmed, Ph.D

Software ResearchSoftware Research

Digital Image ProcessingDigital Image Processing

Huffman Coding

• The most popular technique for removing coding redundancy is due to Huffman (1952)

• Huffman Coding yields the smallest number of code symbols per source symbol

• The resulting code is optimal

Page 22: Software Research Image Compression Mohamed N. Ahmed, Ph.D

Software ResearchSoftware Research

Digital Image ProcessingDigital Image Processing

Huffman Codes

Page 23: Software Research Image Compression Mohamed N. Ahmed, Ph.D

Software ResearchSoftware Research

Digital Image ProcessingDigital Image Processing

Huffman Codes

Page 24: Software Research Image Compression Mohamed N. Ahmed, Ph.D

Software ResearchSoftware Research

Digital Image ProcessingDigital Image Processing

Workshop

Obtain the Huffman codes for the following sequence:

– 5 5 5 5 8 8 4 2 7 7 7 2 2 2 2 4 4 7 7 7 7 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 4 4 4

– What is the average code length with and without compression ?

Page 25: Software Research Image Compression Mohamed N. Ahmed, Ph.D

Software ResearchSoftware Research

Digital Image ProcessingDigital Image Processing

Fixed Length: LZW Coding

• Error Free Compression Technique

• Remove Inter-pixel redundancy

• Requires no priori knowledge of probability distribution of pixels

• Assigns fixed length code words to variable length sequences

• Patented Algorithm US 4,558,302

• Included in GIF and TIFF and PDF file formats

Page 26: Software Research Image Compression Mohamed N. Ahmed, Ph.D

Software ResearchSoftware Research

Digital Image ProcessingDigital Image Processing

LZW Coding

• Coding Technique– A codebook or a dictionary has to be constructed

– For an 8-bit monochrome image, the first 256 entries are assigned to the gray levels 0,1,2,..,255.

– As the encoder examines image pixels, gray level sequences that are not in the dictionary are assigned to a new entry.

– For instance sequence 255-255 can be assigned to entry 256, the address following the locations reserved for gray levels 0 to 255.

Page 27: Software Research Image Compression Mohamed N. Ahmed, Ph.D

Software ResearchSoftware Research

Digital Image ProcessingDigital Image Processing

LZW Coding

• Example

Consider the following 4 x 4 8 bit image

39 39 126 126

39 39 126 126

39 39 126 126

39 39 126 126

Dictionary Location Entry

0 01 1. .255 255256 -

511 -

Initial Dictionary

Page 28: Software Research Image Compression Mohamed N. Ahmed, Ph.D

Software ResearchSoftware Research

Digital Image ProcessingDigital Image Processing

LZW Coding

39 39 126 126

39 39 126 126

39 39 126 126

39 39 126 126

•Is 39 in the dictionary……..Yes•What about 39-39………….No•Then add 39-39 in entry 256•And output the last recognized symbol…39

Dictionary Location Entry

0 01 1. .255 255256 -

511 -

39-39

Page 29: Software Research Image Compression Mohamed N. Ahmed, Ph.D

Software ResearchSoftware Research

Digital Image ProcessingDigital Image Processing

Workshop

• Code the following image using LZW codes

39 39 126 126

39 39 126 126

39 39 126 126

39 39 126 126

* How can we decode the compressed sequence to obtain the original image ?

Page 30: Software Research Image Compression Mohamed N. Ahmed, Ph.D

Software ResearchSoftware Research

Digital Image ProcessingDigital Image Processing

LZW Coding

Page 31: Software Research Image Compression Mohamed N. Ahmed, Ph.D

Software ResearchSoftware Research

Digital Image ProcessingDigital Image Processing

Bit-Plane Coding

• An effective technique to reduce inter pixel redundancy is to process each bit plane individually

• The image is decomposed into a series of binary images.

• Each binary image is compressed using one of well known binary compression techniques.

Page 32: Software Research Image Compression Mohamed N. Ahmed, Ph.D

Software ResearchSoftware Research

Digital Image ProcessingDigital Image Processing

Bit-Plane Decomposition

Page 33: Software Research Image Compression Mohamed N. Ahmed, Ph.D

Software ResearchSoftware Research

Digital Image ProcessingDigital Image Processing

Bit-Plane Encoding

Constant Area Coding

One Dimensional Run Length coding

Two Dimensional Run Length coding

1b 2w 1b 3w 4b 1w

12 w

Page 34: Software Research Image Compression Mohamed N. Ahmed, Ph.D

Software ResearchSoftware Research

Digital Image ProcessingDigital Image Processing

Loss-less Predictive Encoding

Page 35: Software Research Image Compression Mohamed N. Ahmed, Ph.D

Software ResearchSoftware Research

Digital Image ProcessingDigital Image Processing

Loss-less Predictive Encoding

Page 36: Software Research Image Compression Mohamed N. Ahmed, Ph.D

Software ResearchSoftware Research

Digital Image ProcessingDigital Image Processing

Lossy Compression

Quantizer

Page 37: Software Research Image Compression Mohamed N. Ahmed, Ph.D

Software ResearchSoftware Research

Digital Image ProcessingDigital Image Processing

Lossy Compression

Page 38: Software Research Image Compression Mohamed N. Ahmed, Ph.D

Software ResearchSoftware Research

Digital Image ProcessingDigital Image Processing

DPCM

Page 39: Software Research Image Compression Mohamed N. Ahmed, Ph.D

Software ResearchSoftware Research

Digital Image ProcessingDigital Image Processing

DPCM

Page 40: Software Research Image Compression Mohamed N. Ahmed, Ph.D

Software ResearchSoftware Research

Digital Image ProcessingDigital Image Processing

• A reversible linear transform (such as Fourier Transform) is used to map the image into a set of transform coefficients

• These coefficients are then quantized and coded.• The goal of transform coding is to decorrelate

pixels and pack as much information into small number of transform coefficients.

• Compression is achieved during quantization not during the transform step

Transform Coding

Page 41: Software Research Image Compression Mohamed N. Ahmed, Ph.D

Software ResearchSoftware Research

Digital Image ProcessingDigital Image Processing

Transform Coding

Page 42: Software Research Image Compression Mohamed N. Ahmed, Ph.D

Software ResearchSoftware Research

Digital Image ProcessingDigital Image Processing

• Energy packing– 2D transforms pack most of the energy

into small number of coefficients located

at the upper left corner of the 2D array

2D Transforms

EnergyPacking

Page 43: Software Research Image Compression Mohamed N. Ahmed, Ph.D

Software ResearchSoftware Research

Digital Image ProcessingDigital Image Processing

• Consider an image f(x,y) of size N x N

Forward transform

g(x,y,u,v) is the forward transformation kernel or basis functions

2D Transforms

.1,...,2,1,0,

),,,(),(),(1

0

1

0

Nvu

vuyxgyxfvuTN

x

N

y

Page 44: Software Research Image Compression Mohamed N. Ahmed, Ph.D

Software ResearchSoftware Research

Digital Image ProcessingDigital Image Processing

2D Transforms

• Inverse transform

h(x,y,u,v) is the inverse transformation kernel or basis functions

.1,...,2,1,0,

),,,(),(),(1

0

1

0

Nyx

vuyxhvuTyxfN

u

N

v

Page 45: Software Research Image Compression Mohamed N. Ahmed, Ph.D

Software ResearchSoftware Research

Digital Image ProcessingDigital Image Processing

Discrete Cosine Transform

• One of the most frequently used transformations for image compression is the DCT.

N

Nu

N

vy

N

uxvu

vuyxhvuyxg

2

1

)(

2

)12(cos

2

)12(cos)()(

),,,(),,,(

for u=0

for u=1, 2, …, N-1

Page 46: Software Research Image Compression Mohamed N. Ahmed, Ph.D

Software ResearchSoftware Research

Digital Image ProcessingDigital Image Processing

Discrete Cosine Transform

Page 47: Software Research Image Compression Mohamed N. Ahmed, Ph.D

Software ResearchSoftware Research

Digital Image ProcessingDigital Image Processing

2D Transforms

Page 48: Software Research Image Compression Mohamed N. Ahmed, Ph.D

Software ResearchSoftware Research

Digital Image ProcessingDigital Image Processing

Effect of Window Size

Page 49: Software Research Image Compression Mohamed N. Ahmed, Ph.D

Software ResearchSoftware Research

Digital Image ProcessingDigital Image Processing

Quantization

Quantizer

Page 50: Software Research Image Compression Mohamed N. Ahmed, Ph.D

Software ResearchSoftware Research

Digital Image ProcessingDigital Image Processing

Quantization

• Each transformed coefficient is quantized

),(

),(),(ˆ

vuZ

vuTroundvuT

Page 51: Software Research Image Compression Mohamed N. Ahmed, Ph.D

Software ResearchSoftware Research

Digital Image ProcessingDigital Image Processing

Quantization

Page 52: Software Research Image Compression Mohamed N. Ahmed, Ph.D

Software ResearchSoftware Research

Digital Image ProcessingDigital Image Processing

Bit allocation and Zig Zag Ordering

Page 53: Software Research Image Compression Mohamed N. Ahmed, Ph.D

Software ResearchSoftware Research

Digital Image ProcessingDigital Image Processing

DCT and Quantization

),(

),(),(ˆ

vuZ

vuTroundvuT

),(4

),(),(ˆ

vuZ

vuTroundvuT

Right Column

Page 54: Software Research Image Compression Mohamed N. Ahmed, Ph.D

Software ResearchSoftware Research

Digital Image ProcessingDigital Image Processing

Wavelet Coding

Page 55: Software Research Image Compression Mohamed N. Ahmed, Ph.D

Software ResearchSoftware Research

Digital Image ProcessingDigital Image Processing

Wavelet Transform

Put a pixel in each quadrant- No size change

1 23 4

Page 56: Software Research Image Compression Mohamed N. Ahmed, Ph.D

Software ResearchSoftware Research

Digital Image ProcessingDigital Image Processing

• Now let» a = (x1+x2+x3+x4)/4

» b =(x1+x2-x3-x4)/4

» c =(x1+x3-x2-x4)/4

» d =(x1+x4-x2-x3)/4

Wavelet Transforma bc d

d

c

b

a

x

x

x

x

x

x

x

x

d

c

b

a

1111

1111

1111

1111

4

3

2

1

4

3

2

1

1111

1111

1111

1111

4

1

Page 57: Software Research Image Compression Mohamed N. Ahmed, Ph.D

Software ResearchSoftware Research

Digital Image ProcessingDigital Image Processing

Wavelet Transform

Page 58: Software Research Image Compression Mohamed N. Ahmed, Ph.D

Software ResearchSoftware Research

Digital Image ProcessingDigital Image Processing

Wavelet Transform

Page 59: Software Research Image Compression Mohamed N. Ahmed, Ph.D

Software ResearchSoftware Research

Digital Image ProcessingDigital Image Processing

Wavelet Transform

Page 60: Software Research Image Compression Mohamed N. Ahmed, Ph.D

Software ResearchSoftware Research

Digital Image ProcessingDigital Image Processing

Wavelet Coding

• High Frequency coefficients tend to be very small --- 0

• They can be quantized very effectively without distorting the results

Page 61: Software Research Image Compression Mohamed N. Ahmed, Ph.D

Software ResearchSoftware Research

Digital Image ProcessingDigital Image Processing

Wavelet Transform

Wavelet DCT

Page 62: Software Research Image Compression Mohamed N. Ahmed, Ph.D

Software ResearchSoftware Research

Digital Image ProcessingDigital Image Processing

Wavelet Transform

Page 63: Software Research Image Compression Mohamed N. Ahmed, Ph.D

Software ResearchSoftware Research

Digital Image ProcessingDigital Image Processing

Image Compression Standards

• Binary Compression Standards• CCITT G3 -> 1D Run Length Encoding

• CCITT G4 -> 2D Run Length encoding

• JBIG1 -> Lossless adaptive binary compression

• JBIG2 -> Lossy/Lossless adaptive binary compression

Page 64: Software Research Image Compression Mohamed N. Ahmed, Ph.D

Software ResearchSoftware Research

Digital Image ProcessingDigital Image Processing

JBIG/JBIG2

Page 65: Software Research Image Compression Mohamed N. Ahmed, Ph.D

Software ResearchSoftware Research

Digital Image ProcessingDigital Image Processing

• Continuous Tone Still Image Compression Standards

• JPEG

• JPEG 2000

• Mixed Raster Content (MRC)

Image Compression Standards

Page 66: Software Research Image Compression Mohamed N. Ahmed, Ph.D

Software ResearchSoftware Research

Digital Image ProcessingDigital Image Processing

MRC

Page 67: Software Research Image Compression Mohamed N. Ahmed, Ph.D

Software ResearchSoftware Research

Digital Image ProcessingDigital Image Processing

Video Compression