420 likes | 438 Views
第 四 章. VQ 加速運算與編碼表壓縮. 4.1 VQ Codeword Search. Vector Quantization (VQ). Euclidean Distance. The dimensionality of vector = k (= w*h) An input vector x = (x 1 , x 2 , … , x k ) A codeword y i = (y i1 , y i2 , … , y ik ) The Euclidean distance between x and y i. 4.2 PCA.
E N D
第 四 章 VQ 加速運算與編碼表壓縮 4-
Euclidean Distance • The dimensionality of vector = k (= w*h) • An input vector x = (x1, x2, …, xk) • A codeword yi = (yi1, yi2, …, yik) • The Euclidean distance between x and yi 4-
4.2 PCA 4-
Principal component analysis (PCA) Given a set of points Y1, Y2, …, and YM where every Yi is characterized by a set of variables X1, X2, …, and XN. We want to find a direction D = (d1, d2, …, dN), where such that the variance of points projected onto D is maximized. 4-
Principal component analysis (PCA) • D1 = [0.710 0.703] • D2 = [-0.703 0.710] 4-
PCA • 40 samples with 2 variables, X1 and X2 • Covariance matrix • λ1 =1160.139 • λ2 =36.780 4-
Principal component analysis (PCA) • λ1 =1160.139 • λ2 =36.780 • D1 = (0.710, 0.703) • D2 = (-0.703, 0.710) 4-
Principal component analysis (PCA) • Algorithm of PCA • Start by coding the variables Y = (Y1, Y2, …YN) to have zero means and unit variances. • Calculate the covariance matrix C of the samples. • Find the eigenvalues λ1, λ2, …, λN, for C, where λi λi+1, i = 1, 2, …, N-1. Let D1, D2, … DN denote the corresponding eigenvectors. • D1 is the first principal component direction, D2 is the second principal component direction, … , DN is the Nth principal component direction . 4-
The Encoding Algorithm Using PCA Technique • (A) the codebook processing: • For each codeword cwi in codebook matrix B, evaluate projected value pi by pi=D1.cwi. Then, all the codewords in the matrix B are transformed into 256 real numbers. The set of these real numbers can be expressed as P = {p1, p2, …, p256}. • Sort the values in P. We obtain the new ordered set P’ = {p’1, p’2, …, p’256} and their corresponding vector cw’1, cw’2 ,… cw’256 form an ordered codebook B’={cw’1, cw’2 ,… cw’256}. 4-
The Encoding Algorithm Using PCA Technique • (B) The Encoding Algorithm] • For the input vector x, evaluate the projected value px by px = D1.x. • Search the set P’ for r values P’i’s which are the r closest ones to Px. • Compute their distances from the set {cw’k, cw’k+1 ,… cw’k+r-1} to find a vector cw’j such that (cw’j, x) has a minimum distortion. Here, let the searching range be r and assume that the corresponding codeword of P’j is cw’j. • Store or transmit the index j of cw’j 4-
The Encoding algorithm using PCA Codebook The covariance matrix 4-
The Encoding algorithm using PCA • From the covariance matrix, we compute D1: (0.5038, 0.4904, 0.4788, 0.5259), λ1=19552, D2: (-0.4915, -0.5126, 0.4293, 0.5580), λ2=151, D3: (-0.0294, -0.0292, 0.7658, -0.6418), λ3=86 and D4: (0.7098, -0.7042, -0.0108, -0.0134), λ4=6. D1: (0.5038, 0.4904, 0.4788, 0.5259) is a coordinate D1 reserves 98.77% information of the variance of the codewords. 4-
The Encoding algorithm using PCA The new sorted codebook and the corresponding projected value of codewords Codebook The sorted codewords The projected values D1: (0.5038, 0.4904, 0.4788, 0.5259) 4-
Encode an input vector v = (150, 145, 121, 130) • Transform v to ρ= D1.v ρ= D1.v =(0.5038,0.4904,0.4788,0.5259)*(150,145,121,130)T=272 • To search and find that 321.93 is the closest value to 272 • For P5’ = 321.93, d(v, cw’5)=63.2 For P4’ = 162.60, d(v, cw’4)=122.3 For P6’ = 382.84, d(v, cw’6)=114.2 • So, we choose cw’5 to replace the input vector v. 4-
Experimental results • The quality of the encoded image is evaluated by the peak signal-to noise ration PSNR, which is defined as • For an m*m image, the mean-square error (MSE) is defined as • Where xij and denote the original and quantized gray levels, respectively. 4-
Look-up Table (LUT) The content of each pixel belongs to [0, m-1] 4-
Truncated Look-up Table (TLUT) 0 1 2 … 4-
Truncated Look-up Table (TLUT) • For example, r = 256/32 = 8 • (17-34)2= 289 • Error = |289 – 576| • = 287 4-
4.3.2 Reduced Code LUT (RCLUT) • Suppose m = 2t. • Express xj (or yij) by • Define low nibble L(xj) = the lowest bits of xj= • Define high nibble H(xj) = the lowest bits of xj= 4-
Reduced Code LUT (RCLUT) • H(xj), H(yij), L(xj), L(yij) are within the range [0.21/2-1] • Look-up Table (LUT) 4-
4.4.2. Locally Adaptive scheme An example of segmentation with region size 4*4 for indices of VQ 4-
The compressing steps of our example 0 10 10 01 10 11 11 100 011 011 4-
The decoding steps of our example 0 10 10 01 10 11 11 100 011 011 4-
The comparison of two schemes in the unmatched index numbers 4-
The comparison of proposed method and SOC scheme in bit rate (bit/pixel) 4-
Discussions 4-
Discussion of the VQ scheme • Advantage: • The bit rate of the VQ scheme is low. • bit rate = bpp. • Example: • When the codebook is composed of 256 codewords. Each block used is of 4*4 pixels. • bit rate = 0.5 bpp • VQ has a simple decoding structure. 4-
Discussion of the VQ scheme • Disadvantage: • The reconstructed image quality highly depends on the codebook performance. • Therefore, how to design a representative codebook is an important issue of VQ scheme. • The VQ scheme requires a lot of computation cost in codebook generation process and VQ encoding process. 4-