330 likes | 793 Views
Outline of Vector Quantization of Images. VQ Coding Outline. Divide data (signal) into non-overlapping vectors (Each vector contains ‘n’ elements (pixels/samples)) For each image vector : Find closest vector in codebook Get its index in codebook Encode indices. VQ Decoding Outline.
E N D
VQ Coding Outline • Divide data (signal) into non-overlapping vectors • (Each vector contains ‘n’ elements (pixels/samples)) • For each image vector : • Find closest vector in codebook • Get its index in codebook • Encode indices
VQ Decoding Outline • Entropy decode the indices • Lookup codebook for each index and retrieve vector • Combine vectors to reconstruct image (data)
VQ Terminology • Vector : Group of ‘n’ elements (pixels/samples) • Codebook : (Final) set of codevectors • Training set : (Initial) set of codevectors • Codevector : Vector derived from image/group of images
Why VQ is better than scalar Quantization • Scalar Quantizer : • Treats each pixel independently • Does not use correlation between neighboring pixels • Vector Quantizer: • Image (data) divided into vectors (blocks) • Correlation among pixels in vectors is exploited • Block size should be appropriate: • Too large block : correlation is lost • Too small block : More code vectors • If no interpixel correlation, then no gain
VQ Bitrate • Vector size : n (say, n = p x p) pixels • Codebook size : L vectors • Codebook index size : bits • Bit Rate of VQ : bits/pixel
Distortion Measures Codebook Image V1 codevectors : Vi , xk V2 closest matching code vector Vk Image vectors : Xj VL Mean Square Error (MSE) (Euclidean Distance) Weighted MSE
Two Basic Kinds of Codebook • Local Codebook • One codebook for each image • Codebook derived from vectors of one image • Good performance (Quality of reconstruction) • More overhead : • (1) computation • (2) Transmission of CB to decoder
Two Basic Kinds of Codebook • Global Codebook • One codebook for a class of images • Codebook derived from vectors of all images in the class • Less overhead (compared to local codebook) • Lower performance
Major Issues in VQ • Generation (construction) of codebook • concerns what needs to be included in the codebook • Design of codebook • concerns structuring codebook entries to minimize search time
Codebook Generation • Generate codebook from a Training set • Training Set: Set of vectors derived from image vectors • Codevectors should minimize distortion • Most commonly used algorithm : LBG algorithm • LBG : Linde–Buzo–Gray algorithm
Codebook Initialization • Three basic schemes: • Random • Perturb and Split (Bottoming) • Pairwise Nearest Neighbor (PNN) clustering (PNN)
Codebook Design • Basic objective : Minimize search time for codevector • Full (Exhaustive) Search : very expensive • Design emphasis : Organization of codebook
Codebook Organizations • Tree-structured codebook • Product codebook • Mean/Residual VQ • Interpolative/Residual VQ • Gain/Shape VQ • Classified VQ • Finite State VQ
Tree – Structured Codebook • Codebook organized as M–ary tree • Number of Levels : • Code vectors stored at the leaves • Intermediate node : ‘average’ of ‘codevectors’ of children • Improved search time • Increased Storage cost • Performance inferior to full search
Variations of Tree – Structured VQ • Tapered trees: • Non – Uniform number of branches at nodes • Branches per node increases going down the tree ( Ex: 2 branches at level 1, 3 at level 2 etc.) • Pruned Trees • Start with (full) large initial tree • Remove code vectors that do not reduce distortion
Product Codebook • Codebook : Cartesian product of many smaller codebooks • Vector characterized by many independent features:f1,f2...,fN • Separate codebook for each feature • Smaller codebook sizes : L1,L2...,LN • Effective codebook size : L1,L2...,LN • Actual storage + search complexity O(L1+L2+...+LN)
Prediction/Residual Class VQ • Predict Original Image • Derive Residual Image • Data used in prediction: Scalar Quantization + Encoding • Residual Image : Vector Quantization • Major Types: • Mean/Residual VQ • Interpolative/Residual VQ
Mean/Residual VQ • Image Vectors have similar variations about different mean/ends • Remove mean from vectors fewer code vectors
Mean/Residual VQ • Scheme : • Compute ‘mean’ of image vectors : M={m1,m2...,mN} • Quantize M using scalar quantization : • (Apply DPCM before Quantization further bitrate reduction) • Subtract Quantized means from vector elements • Residual vectors • Quantize Residual vectors using VQ
Interpolative/Residual VQ • Subsample original image by l in each dimension (typically, l=8) • Quantize subsampled value • Upsample using Quantized subsampled values (typically, bilinear interpolation is used) • Form Residual : (Original – Upsampled) • Segment Residual to form 4 x 4 vectors • Quantize Residual vectors using VQ
Classified VQ • Several codebooks • Each codebook for a specific feature • ex. edges, smooth areas, etc. • Codebooks could be of different sizes
What is the measure of performance VQ? • How does one rate the performance of a compressed image or sound using VQ? • There is no good way to measure the performance of VQ. • This is because the distortion that VQ incurs will be evaluated by us humans and that is a subjective measure.
What is the measure of performance VQ? • We can always resort to good old Mean Squared Error (MSE) and Peak Signal to Noise Ratio (PSNR). • MSE is defined as follows: where M is the number of elements in the signal, or image.
What is the measure of performance VQ? • For example, if we wanted to find the MSE between the reconstructed and the original image, then we would take the difference between the two images pixel by pixel, square the results, and average the results.
What is the measure of performance VQ? • The PSNR is defined as follows: where n is the number of bits per symbol. • As an example, if we want to find the PSNR between two 256 gray level images, then we set n to 8 bits.