Compressing a D Discrete Signal Divide the signal into 8blocks. Subtract the sample mean from each value. Compute the 8 8covariancematrixforthe blocks. Compute the eigenvectors of the covariance matrix. Compute the KL transform of each block. Threshold each transformed block to create long runs of zeros. Compute differences of KL transform coefficients in raster scan order. Run length encode differences. Huffman-code run-lengths. Huffman-code labels.
Average Over all Initial Positions Given a D discrete signal f of length, construct an 8 8covariancematrixforthe8consecutive values starting at all initial positions n: C = = [ ] T [ ] fn+0 f n+7 fn+0 f n+7 n=0 f n+0 f n+0 f n+0 f n+ f n+0 f n+7 f n+ f n+0 f n+ f n+ f n+ f n+7...... f n+7 f n+0 f n+7 f n+ f n+7 f n+7. Because the covariance matrix is an average over all initial positions, there can be no dependence on n: f n+i f n+ j = f m+i f m+ j. It follows that C is circulant and the eigenvectors of C are sampled harmonic signals!
Compressing a D Discrete Signal (revised) Divide the signal into 8blocks. Subtract the sample mean from each value. Compute DFT of each block. Threshold each transformed block to create long runs of zeros. Compute differences of thresholded DFT coefficients in raster scan order. Run length encode differences. Huffman-code run-lengths. Huffman-code labels.
Symmetric Extension Given a vector f of length construct a vector g of length such that { f (n) if 0 n g(n)= f ( n ) if n. The DFT of g shifted by one-half is: ( G(m) = jπ(n + g(n) exp ) n=0 for 0 m. Recall that ( jπ(n + exp ) ( π(n + = cos ) ( π(n + + j sin ). ow, because g is symmetric: ( π(n + g(n) j sin ) = 0. n=0 Consequently G(m) = n=0 ( π(n + g(n) cos ).
Symmetric Extension (contd.) Dividing the sum into two parts and substituting f (n) for g(n) in the first part and f ( n ) for g(n) in the second part yields G(m)= n=0 n= We now observe that ( π(n + f (n)cos ) + ( π(n + f ( n )cos ). ( π(n + f ( n )cos ) ( π(n + = f ( )cos ) when n. It follows that [ ( G(m) = π(n + f (n) cos ) ( π(n + + cos )] n=0 ( = π(n + f (n)cos ). n=0
Discrete Cosine Transform The Discrete Cosine Transform is defined as follows: ( F(m) = π(n + f (n)cos ). n=0 Because the DCT is a real valued transform there is no need for complex arithmetic. Unlike f which had a discontinuity at f (0), g is continuous at both g(0) and g()! For this reason, the energy in the DCT representation of a function is localized in fewer non-zero values.
Periodicity of DFT and DCT Figure : The DCT is the unique half of the real part of the DFT of a length symmetric extension of a length signal shifted by one-half.
Periodicity of D DFT and DCT Figure : Periodicity of the D Discrete Fourier Transform (DFT). Figure 3: Periodicity of D Discrete Cosine Transform (DCT).
JPEG Divide image into 8 8blocks. Center gray values (i.e., subtract 8). Compute the DCT of each block. Quantize DCT coefficients using quantization table. Compute differences of quantized DCT coefficients along zigzag path. Run-length encode differences. Huffman-code run-lengths. Huffman-code labels. Joint Photographic Experts Group
Example Block 5 55 6 66 70 6 64 73 63 59 55 90 09 85 69 7 6 59 68 3 44 04 66 73 63 58 7 54 06 70 69 67 6 68 04 6 88 68 70 79 65 60 70 77 68 58 75 85 7 64 59 55 6 65 83 87 79 69 68 65 76 78 94 Figure 4: JPEG compression (top) and decompression (bottom) algorithms.
Subtracting 8 f = 76 73 67 6 58 67 64 55 65 69 73 38 9 43 59 56 66 69 60 5 6 4 6 55 65 70 57 6 6 58 59 6 67 60 4 40 60 58 49 63 68 58 5 60 70 53 43 57 64 69 73 67 63 45 4 49 59 60 63 5 50 34 Figure 5: Subtracting 8 from blocks.
DCT of 8 8Block 4 7 x=0 7 y=0 F(u,v)= ( ) ( ) π(x + )u π(y + )v f (x,y)cos cos 6 6 F = Figure 6: Discrete cosine transform of blocks. 45.38 30.9 6.0 7.4 56. 0.0.39 0.46 4.47.86 60.76 0.5 3.5 7.09 8.54 4.88 46.83 7.37 77.3 4.56 8.9 9.93 5.4 5.65 48.53.07 34.0 4.76 0.4 6.30.83.95. 6.55 3.0 3.95.87.75.79 3.4 7.73.9.38 5.94.38 0.94 4.30.85.03 0.8 0.4.4 0.88 3.0 4. 0.66 0.7 0.4.07 4.9.7 0.0 0.50.68
JPEG Basis Functions Figure 7: JPEG basis functions.
Block Quantization Q = 6 0 6 4 40 5 6 4 9 6 58 60 55 4 3 6 4 40 57 69 56 4 7 9 5 87 80 6 8 37 56 68 09 03 77 4 35 55 64 8 04 3 9 49 64 78 87 03 0 0 7 9 95 98 00 03 99 G(u,v)= F(u,v) Q(u,v) + 0.5 G = Figure 8: Quantize blocks. 6 3 6 0 0 0 4 0 0 0 3 5 0 0 0 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Difference Encode along Zigzag Path Figure 9: Zigzag scan order. Figure 0: Difference encode blocks. Table : AC Coefficient Encoding Scheme. 4bits 4bits 8bits zero run length category amplitude
Rescaling Block F(u,v)=G(u,v) Q(u,v) Figure : Rescale blocks. F = 46 33 60 3 48 40 0 0 0 4 56 9 6 0 0 0 4 3 80 4 40 0 0 0 4 7 44 9 0 0 0 0 8 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Inverse DCT 4 7 u=0 7 v=0 f (x,y)= [ ] π(x + )u F(u,v)cos cos 6 [ ] π(y + )v 6 f = Figure : Inverse discrete cosine transform of blocks. 66 63 7 68 56 65 68 46 7 73 7 46 0 4 66 57 70 78 68 7 0 4 6 63 63 73 6 8 7 4 60 58 58 65 6 7 6 40 68 50 57 57 64 58 48 66 7 47 53 46 6 74 65 63 6 45 47 34 53 74 60 47 47 4
Reconstruction Errors f f = 0 0 4 6 4 9 6 4 8 7 4 9 8 4 0 8 3 5 8 3 3 4 0 8 8 8 6 4 0 3 6 6 0 3 5 8 4 0 6 5 6 4 3 5 3 7
Adding 8 6 65 57 60 7 63 60 8 57 55 56 8 08 87 6 7 58 50 60 48 4 67 65 65 55 66 0 55 4 68 70 70 63 67 0 88 60 78 7 7 64 70 80 6 56 8 75 8 67 54 63 65 66 83 8 94 75 54 68 8 8 87 Figure 3: Add 8 to blocks.
Conclusion The DCT is really the KL transform of the block in disguise! The quantization table tells us which eigenvectors are most important perceptually. Compression ratios of 8 to without perceptible differences are typical.