210 likes | 454 Views
Tuning Baseline JPEG Encoding for Individual Images. Chien-An Lai Changchuan Yu EE398A Final Project Mar 15 th 2007 . Outline. Motivation Baseline JPEG Optimization Algorithm with baseline JPEG compliance Results Conclusion. Motivation. Flexibility of baseline JPEG – Q and H tables
E N D
Tuning Baseline JPEG Encoding for Individual Images Chien-An Lai Changchuan Yu EE398A Final Project Mar 15th 2007
Outline • Motivation • Baseline JPEG • Optimization Algorithm with baseline JPEG compliance • Results • Conclusion
Motivation • Flexibility of baseline JPEG – Q and H tables • what gain could we get from changing the tables? • A ’97 algorithm revisited in ’07 • Joint implementation of different optimizing techniques • R-D optimized quantizer selection • R-D optimal thresholding • Optimal Huffman encoding • Compare the best baseline JPEG to state-of-the-art JPEG2000
Baseline JPEG • Block-Diagram DCT (8*8) Quantizer Q matrix (8*8) Entropy Coding (Huffman) 101101… Bit sequence 8*8 blocks
Modified baseline JPEG • Block-Diagram Entropy Coding DCT (8*8) Quantizer Threshold T matrix 101101… Bit sequence Q T H 8*8 blocks Q matrix Selection Optimal Thresholding Huffman table Customization Image-adaptive optimization
Algorithm Overview Entropy Coding DCT (8*8) Quantizer Threshold T matrix 101101… Bit sequence Q T H 8*8 blocks Q matrix Selection Optimal Thresholding Huffman table Customization Loop ‘til converge Image-adaptive optimization
Algorithm - Q • For n=1:64 • For q=1:255 • End • End • A fast algorithm is needed, or it’s equivalent to jpeg encoding 255*64 pictures for one single Q search!
Algorithm - Thresholding find which k* is optimal for minimal cost and backtracking from k* to find the T coefficients. This is equivalently the optimal value for 2^63 thresholding combinations.
Algorithm – Huffman Table • Optimization under the constraint of baseline JPEG format • Reordering of Huffman table according to the real statistics table=[... 0 1 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 2 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 3 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 4 4 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 5 5 1 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 7 7 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 8 10 1 1 1 1 1 1 0 1 1 0 0 0 0 0 0 0 0 9 16 1 1 1 1 1 1 1 1 1 0 0 0 0 0 1 0 0 10 16 1 1 1 1 1 1 1 1 1 0 0 0 0 0 1 1 1 1 4 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 2 6 1 1 1 0 0 1 0 0 0 0 0 0 0 0 0 0 1 3 7 1 1 1 1 0 0 1 0 0 0 0 0 0 0 0 0 1 4 9 1 1 1 1 1 0 1 1 0 0 0 0 0 0 0 0 1 5 11 1 1 1 1 1 1 1 0 1 1 0 0 0 0 0 0 1 6 16 1 1 1 1 1 1 1 1 1 0 0 0 0 1 0 0 Re-ordering 2-D symbol run cat code length
How we did the testing • Matlab modeling of baseline JPEG • An accurate model, with everything but headers • Slow! • Baseline JPEG rate-psnr using scaling of Q table • JPEG2000 rate-psnr using rate-constrained Jasper* coder • Mostly run on Scien Lab machines *http://www.ece.uvic.ca/~mdadams/jasper/
Results1 32.5dB, 2.0 bits/pixel 32.3dB, 1.4 bits/pixel
Results1 Q optimized = 11 29 33 31 41 33 43 41 37 33 31 37 39 41 41 57 33 33 37 37 41 41 45 49 35 35 37 37 43 43 53 85 35 41 41 41 43 57 75 111 39 41 43 45 57 83 95 101 37 47 51 53 75 77 93 81 47 47 57 65 97 95 83 87 Q baseline = 15 10 10 15 23 38 49 58 11 11 13 18 25 55 57 52 13 12 15 23 38 54 66 53 13 16 21 28 49 83 76 59 17 21 35 53 65 104 98 73 23 33 52 61 77 99 108 88 47 61 74 83 98 115 114 96 69 88 90 93 107 95 98 94
Results2 – Halfdome top 32.8dB, 0.8 bits/pixel 32.9dB, 1.0 bits/pixel
Results2 – Halfdome top 27.9dB, 0.8 bits/pixel 26.5dB, 0.8 bits/pixel
Results2 Q optimized = 46 19 19 17 19 15 21 23 23 19 19 19 19 21 21 27 20 19 17 19 19 21 25 27 19 19 17 21 21 21 19 27 15 19 17 19 19 21 21 23 19 17 19 17 21 19 21 25 17 21 21 19 21 25 23 35 21 19 21 21 19 23 25 59 Q baseline = 8 6 5 8 12 21 26 31 6 6 7 10 13 30 31 28 7 7 8 12 21 29 36 29 7 9 11 15 26 45 41 32 9 11 19 29 35 56 53 40 12 18 28 33 42 54 58 47 25 33 40 45 53 62 62 52 37 47 49 51 58 52 53 51
Result – scaling effects 256x256, halfdome 512x512, halfdome
Result – it does not always work peppers512x512
Conclusion • Optimization of Q and H tables can result in significant gain, compared to recommended tables • Most gain from Q optimization • Huffman optimization contributes some performance gain • Optimal Thresholding produces little gain • At a cost of thousands times of computation effort • 1+ hours of searching in matlab, on Scien Lab machines • No guarantee for global optimization • JPEG2000 is a far superior winner, hands down • Encoding takes only mini-seconds • Precise control of bit rate
References • [1] G. K. Wallace, "The JPEG still picture compression standard," Communications of the ACM, vol. 34, no. 4, April 1991. • [2] M. Crouse and K. Ramchandran, "Joint thresholding and quantizer selection for transform image coding: entropy-constrained analysis and applications to baseline JPEG", IEEE Transactions on Image Processing, vol. 6, no. 2, February 1997. • [3] K. Ramchandran and M. Vetterli, “Rate-distortion optimal fast thresholding with complete JPEG/MPEG decoder compatibility,” IEEE Trans. Image Processing, vol. 3, pp. 700–704, Sept. 1994.