36
Computer Vision – Computer Vision – Compression(2) Compression(2) Hanyang University Jong-Il Park

Computer Vision – Compression(2) Hanyang University Jong-Il Park

Embed Size (px)

Citation preview

Page 1: Computer Vision – Compression(2) Hanyang University Jong-Il Park

Computer Vision – Computer Vision – Compression(2)Compression(2)

Hanyang University

Jong-Il Park

Page 2: Computer Vision – Compression(2) Hanyang University Jong-Il Park

            

Department of Computer Science and Engineering, Hanyang University

Topics in this lectureTopics in this lecture

Practical techniques Lossless coding Lossy coding

Optimum quantization Predictive coding Transform coding

Page 3: Computer Vision – Compression(2) Hanyang University Jong-Il Park

            

Department of Computer Science and Engineering, Hanyang University

Lossless codingLossless coding

=Error-free compression

=information-preserving coding

General steps1. Devising an alternative representation of the image in

which its interpixel redundancies are reduced

2. Coding the representation to eliminate coding redundancies

Page 4: Computer Vision – Compression(2) Hanyang University Jong-Il Park

            

Department of Computer Science and Engineering, Hanyang University

Huffman codingHuffman coding

Most popular coding (Huffman[1952]) Two step approach

1. To create a series of source reduction by ordering the probabilities of the symbols and combining the lowest probability symbols into a single symbol that replaces them in the next source reduction

2. To code each reduced source, starting with the smallest source and working back to the original source

Instantaneous uniquely decodable block code Optimal code for a set of symbols and probabilities

subject to the constraint that the symbols be coded one at a time.

Page 5: Computer Vision – Compression(2) Hanyang University Jong-Il Park

            

Department of Computer Science and Engineering, Hanyang University

Eg. Huffman codingEg. Huffman coding

Page 6: Computer Vision – Compression(2) Hanyang University Jong-Il Park

            

Department of Computer Science and Engineering, Hanyang University

Arithmetic codingArithmetic coding

Non-block code One-to-one correspondence between source

symbols and code words does not exist.

an entire sequence of source symbols is assigned a single arithmetic code word.

As the length of the sequence increases, the resulting arithmetic code approaches the bound established by the noiseless coding theorem.

Practical limiting factors The addition of the end-of-message indicator The use of finite precision arithmetic

Page 7: Computer Vision – Compression(2) Hanyang University Jong-Il Park

            

Department of Computer Science and Engineering, Hanyang University

Eg. Arithmetic codeEg. Arithmetic code

0.068

Page 8: Computer Vision – Compression(2) Hanyang University Jong-Il Park

            

Department of Computer Science and Engineering, Hanyang University

LZW codingLZW coding Lempel-Ziv-Welch coding Assigning fixed-length code words to variable length

sequences of source symbols but requires no a priori knowledge of the probability of occurrence of the symbols to be encoded

Generating a dictionary(=codebook) as the encoding proceeds.

The size of the dictionary is an important parameter. => trade-off

Applied to GIF, TIFF, PDF format and many zip algorithm

Page 9: Computer Vision – Compression(2) Hanyang University Jong-Il Park

            

Department of Computer Science and Engineering, Hanyang University

Eg. LZW codingEg. LZW coding

Page 10: Computer Vision – Compression(2) Hanyang University Jong-Il Park

            

Department of Computer Science and Engineering, Hanyang University

22D Run-length codingD Run-length coding

• Relative address coding(RAC)

Page 11: Computer Vision – Compression(2) Hanyang University Jong-Il Park

            

Department of Computer Science and Engineering, Hanyang University

Lossless predictive codingLossless predictive coding

Principle: De-correlating data by prediction = entropy reduction

Page 12: Computer Vision – Compression(2) Hanyang University Jong-Il Park

            

Department of Computer Science and Engineering, Hanyang University

Eg. Lossless predictive codingEg. Lossless predictive coding

Histogram

Page 13: Computer Vision – Compression(2) Hanyang University Jong-Il Park

            

Department of Computer Science and Engineering, Hanyang University

Lossy compressionLossy compression

Approaches Predictive coding Transform coding Vector quantization Etc.

Significant data reduction compared with lossless compression at the expense of quality degradation

Page 14: Computer Vision – Compression(2) Hanyang University Jong-Il Park

            

Department of Computer Science and Engineering, Hanyang University

Lossy predictive codingLossy predictive coding

Prevent error accumulation

Page 15: Computer Vision – Compression(2) Hanyang University Jong-Il Park

            

Department of Computer Science and Engineering, Hanyang University

Delta modulation(DM)Delta modulation(DM)

Page 16: Computer Vision – Compression(2) Hanyang University Jong-Il Park

            

Department of Computer Science and Engineering, Hanyang University

DPCMDPCM(Differential pulse code modulation)(Differential pulse code modulation)

Optimal predictor:

Try to minimize the mean-square of the prediction error

subject to the constraint that

and

}]ˆ{[}{ 22nnn ffEeE

nnnnnn ffefef ˆˆ

in

m

iin ff

1

ˆ

Page 17: Computer Vision – Compression(2) Hanyang University Jong-Il Park

            

Department of Computer Science and Engineering, Hanyang University

Practical predictionPractical prediction

Prediction for 2D Markov source

Reduction of accumulated transmission error

Typical predictors

jh

ivjyixfyxfE 2)},(),({

m

ii

1

1

otherwise ),1(97.0

if )1,(97.0),(ˆ)

)1,1(5.0),1(75.0)1,(75.0),(ˆ)

),1(5.0)1,(5.0),(ˆ)

)1,(97.0),(ˆ)

yxf

ΔvΔhyxfyxfD

yxfyxfyxfyxfC

yxfyxfyxfB

yxfyxfA

Page 18: Computer Vision – Compression(2) Hanyang University Jong-Il Park

            

Department of Computer Science and Engineering, Hanyang University

Eg. PredictorEg. Predictor

A B

C D

Page 19: Computer Vision – Compression(2) Hanyang University Jong-Il Park

            

Department of Computer Science and Engineering, Hanyang University

Optimal quantizationOptimal quantization

Minimization of the mean-square quantization error:

}){( 2itsE

Page 20: Computer Vision – Compression(2) Hanyang University Jong-Il Park

            

Department of Computer Science and Engineering, Hanyang University

Lloyd-Max quantizerLloyd-Max quantizer Optimal quantizer in the mean-square sense Method

Reconstruction level: centroid Decision level: halfway

No explicit closed-form solutions for most pdfs An iterative design procedure is applied in many cases

Optimum uniform quantizer (uniform q.+VLC) outperforms (non-uniform q.+FLC)

Page 21: Computer Vision – Compression(2) Hanyang University Jong-Il Park

            

Department of Computer Science and Engineering, Hanyang University

Adaptive quantizationAdaptive quantization

Different quantization for each subimage(eg.block)

improved performance

increased complexity

Eg. Four different quantizers: Scaled version of the same quantizer

Notice: Substantial decrease in error BUT small improvement in compression ratio

Page 22: Computer Vision – Compression(2) Hanyang University Jong-Il Park

            

Department of Computer Science and Engineering, Hanyang University

Eg. DPCM vs. Adaptive DPCMEg. DPCM vs. Adaptive DPCM

DPCMAdaptiveDPCM

Substantial decreasein perceived error

Page 23: Computer Vision – Compression(2) Hanyang University Jong-Il Park

            

Department of Computer Science and Engineering, Hanyang University

Transform codingTransform coding

A reversible, linear transform is used Goal:

to decorrelate the pixels of each subimage, or to pack as much information as possible into the

smallest number of transform coefficients

Page 24: Computer Vision – Compression(2) Hanyang University Jong-Il Park

            

Department of Computer Science and Engineering, Hanyang University

Basis images: WHTBasis images: WHT

Page 25: Computer Vision – Compression(2) Hanyang University Jong-Il Park

            

Department of Computer Science and Engineering, Hanyang University

Basis images: DCTBasis images: DCT

Page 26: Computer Vision – Compression(2) Hanyang University Jong-Il Park

            

Department of Computer Science and Engineering, Hanyang University

Comparison: Energy compactionComparison: Energy compaction

DFT

WHT

DCT

Best performance

• KLT is optimal BUT it is image dependent!

•DCT is a good compromise!

Page 27: Computer Vision – Compression(2) Hanyang University Jong-Il Park

            

Department of Computer Science and Engineering, Hanyang University

DFT vs. DCT DFT vs. DCT

Less blocking artifact

2n-pointperiodicity

Page 28: Computer Vision – Compression(2) Hanyang University Jong-Il Park

            

Department of Computer Science and Engineering, Hanyang University

Effect of subimage sizeEffect of subimage size

•Complexity increases•Performance enhances

Page 29: Computer Vision – Compression(2) Hanyang University Jong-Il Park

            

Department of Computer Science and Engineering, Hanyang University

Eg. Block sizeEg. Block size

2x2

8x84x4

Org.

25% reduction

Error(8x8)

Page 30: Computer Vision – Compression(2) Hanyang University Jong-Il Park

            

Department of Computer Science and Engineering, Hanyang University

Bit allocationBit allocation

Zonal coding Allocation of appropriate bits for each coefficient

according to the statistics Rate-distortion theory

Eg. Gaussian pdf

Threshold coding Global threshold Local threshold

Fixed (N-largest coding) constant rate Variable variable rate. Good performance

DR

2

2log2

1

Page 31: Computer Vision – Compression(2) Hanyang University Jong-Il Park

            

Department of Computer Science and Engineering, Hanyang University

Zonal vs. ThresholdZonal vs. Threshold

Page 32: Computer Vision – Compression(2) Hanyang University Jong-Il Park

            

Department of Computer Science and Engineering, Hanyang University

Eg. Zonal vs. ThresholdEg. Zonal vs. Threshold

Threshold better

zonal

Page 33: Computer Vision – Compression(2) Hanyang University Jong-Il Park

            

Department of Computer Science and Engineering, Hanyang University

Quantization tableQuantization table

•Different scaling for each coefficient.•The same quantization curve for all coefficients.

Z

Page 34: Computer Vision – Compression(2) Hanyang University Jong-Il Park

            

Department of Computer Science and Engineering, Hanyang University

Eg. Quality control by scaling ZEg. Quality control by scaling Z

34:1 67:1

Page 35: Computer Vision – Compression(2) Hanyang University Jong-Il Park

            

Department of Computer Science and Engineering, Hanyang University

Wavelet codingWavelet coding

• New technique in 1990s• Computationally efficient• No subdivision no blocking artifact• Good performance!

Page 36: Computer Vision – Compression(2) Hanyang University Jong-Il Park

            

Department of Computer Science and Engineering, Hanyang University

Eg. Wavelet transformEg. Wavelet transform