using jpeg to compress still pictures
play

Using JPEG to Compress Still Pictures Tyler Genter December 17, - PowerPoint PPT Presentation

Using JPEG to Compress Still Pictures Tyler Genter December 17, 2010 Tyler Genter Using JPEG to Compress Still Pictures Saving Space Computers are an excellent tool to view and modify pictures. To be really useful we need to work with large


  1. Using JPEG to Compress Still Pictures Tyler Genter December 17, 2010 Tyler Genter Using JPEG to Compress Still Pictures

  2. Saving Space Computers are an excellent tool to view and modify pictures. To be really useful we need to work with large images. Hard drives are huge compared to 20 years ago. Pictures are still extremely large. We need to efficiently store large numbers of large pictures. JPEG makes it so that images use less space when written to a disk. Tyler Genter Using JPEG to Compress Still Pictures

  3. How JPEG Works A picture can be seen as a large matrix. Every pixel makes up an element in this matrix. To compress the image, this matrix is split up into a number of 8 by 8 matrices. This 8 by 8 matrix from the original image is then compressed The series of processed matrices, when written to disk, use up less space. The original picture is then reconstructed from these processed matrices. Tyler Genter Using JPEG to Compress Still Pictures

  4. Compress an Image We process this 8 by 8 matrix (called B ) to reduce its size. Each entry in this matrix has the range [0 , 255]. First step is to subtract 128 from each entry. f = B − 128 Now every entry has the range [ − 128 , 127] Tyler Genter Using JPEG to Compress Still Pictures

  5. Discrete Cosine Transform Now, we perform the Discrete Cosine Transform. The matrix can be looked at as a sequence of slowly changing values. This can be approximated as a sum of a number of cosine functions. This is known as the discrete cosine transform A typical picture does not have hard, crisp, lines Pictures taken of natural scenes have gradual, slowly changing colors. Thus, images are ideal for the discrete cosine transform Tyler Genter Using JPEG to Compress Still Pictures

  6. Performing the Discrete Cosine Transform Each entry represents a pixel in the original image. After the Discrete Cosine Transform, each entry represents the amplitude of a series of cosine functions. The equation to transform f to F is: 7 7 F ( u , v ) = 1 � � � 4 C ( u ) C ( v ) f ( x , y ) ∗ x =0 y =0 � (2 x + 1) u π � � (2 y + 1) v π � � cos cos 16 16 √ � 1 / 2 , for u , v = 0 C ( u ) , C ( v ) = 1 , otherwise. Tyler Genter Using JPEG to Compress Still Pictures

  7. A Faster Way Which is quite complex and slow on a computer. We can construct a matrix, T , that does the Discrete Cosine Transform instead. F = TfT ′ Which is much faster on any type of processor. T only needs to be computed once. T is an 8 by 8 matrix, where every element t mn is: � 1 t 1 n = 8 � 1 � π (2 n − 1)( m − 1) � t mn = 4 cos 16 Tyler Genter Using JPEG to Compress Still Pictures

  8. Quantization Matrix Now we divide each entry in F by the corresponding entry in the quantization matrix Q and round to the nearest integer. F Q ( u , v ) = Integer Round F ( u , v ) Q ( u , v ) Q is an 8 by 8 matrix, with the entries becoming larger as you approach the lower right. This means that in F Q , the entries in the lower right are smaller and more likely zero. This is the step that throws away less important information. Tyler Genter Using JPEG to Compress Still Pictures

  9. Saving to Disk So now, the matrix has a large number of zeros in it. This matrix is written to disk using a scheme that saves space. This process is repeated for the rest of the 8 by 8 blocks that make up the original image. Tyler Genter Using JPEG to Compress Still Pictures

  10. Decompression The opposite is done to decompress the 8 by 8 blocks. The matrix is read from disk and multiplied by Q . The Inverse Discrete Cosine Transform is performed instead, with f = T ′ FT . 128 is added to each pixel. The individual 8 by 8 matrices are put together to form the original matrix. Tyler Genter Using JPEG to Compress Still Pictures

  11. An Example So we look at our image Tyler Genter Using JPEG to Compress Still Pictures

  12. And we start processing one 8 by 8 block of pixels Tyler Genter Using JPEG to Compress Still Pictures

  13. This block of pixels can be seen as a matrix, like so: 215 234 255 255 255 255 255 255   207 212 255 255 255 255 255 255     216 195 225 255 252 255 254 247     217 218 214 239 252 255 250 248   B =   218 230 205 218 251 255 246 252     217 218 209 206 249 255 244 255     212 202 222 208 243 253 247 255   206 202 229 217 235 250 252 255 Note that 0 represents black, 255 is white, and values in between are grey. Tyler Genter Using JPEG to Compress Still Pictures

  14. Subtract 128 We substract 128 from each entry, and get the matrix:  87 106 127 127 127 127 127 127  79 84 127 127 127 127 127 127     88 67 97 127 124 127 126 119     89 90 86 111 124 127 122 120   f =   90 102 77 90 123 127 118 124     89 90 81 78 121 127 116 127     84 74 94 80 115 125 119 127   78 74 101 89 107 122 124 127 Tyler Genter Using JPEG to Compress Still Pictures

  15. Discrete Cosine Transform T happens to be: 2 0 . 3536 0 . 3536 0 . 3536 0 . 3536 0 . 3536 0 . 3536 0 . 3536 0 . 3536 3 0 . 4904 0 . 4157 0 . 2778 0 . 0975 − 0 . 0975 − 0 . 2778 − 0 . 4157 − 0 . 4904 6 7 6 0 . 4619 0 . 1913 − 0 . 1913 − 0 . 4619 − 0 . 4619 − 0 . 1913 0 . 1913 0 . 4619 7 6 7 0 . 4157 − 0 . 0975 − 0 . 4904 − 0 . 2778 0 . 2778 0 . 4904 0 . 0975 − 0 . 4157 6 7 6 7 0 . 3536 − 0 . 3536 − 0 . 3536 0 . 3536 0 . 3536 − 0 . 3536 − 0 . 3536 0 . 3536 6 7 6 7 0 . 2778 − 0 . 4904 0 . 0975 0 . 4157 − 0 . 4157 − 0 . 0975 0 . 4904 − 0 . 2778 6 7 6 7 0 . 1913 − 0 . 4619 0 . 4619 − 0 . 1913 − 0 . 1913 0 . 4619 − 0 . 4619 0 . 1913 4 5 0 . 0975 − 0 . 2778 0 . 4157 − 0 . 4904 0 . 4904 − 0 . 4157 0 . 2778 − 0 . 0975 Tyler Genter Using JPEG to Compress Still Pictures

  16. Discrete Cosine Transform We calculate F = TfT ′ , and get: 241 . 831 242 . 891 279 . 307 293 . 096 342 . 240 356 . 735 346 . 129 352 . 846 2 3 1 . 960 12 . 290 31 . 792 53 . 834 15 . 728 3 . 283 7 . 965 − 2 . 612 6 7 − 9 . 146 − 5 . 352 38 . 254 7 . 312 − 6 . 579 − 2 . 692 5 . 847 6 . 150 6 7 6 7 4 . 998 26 . 941 − 2 . 756 − 18 . 649 5 . 395 1 . 884 − 5 . 548 5 . 034 6 7 F = 6 7 1 . 414 20 . 153 − 2 . 828 1 . 768 − 2 . 121 − 1 . 061 1 . 061 − 0 . 707 6 7 6 7 4 . 439 − 3 . 247 − 3 . 658 1 . 018 0 . 379 0 . 408 − 0 . 451 − 2 . 443 6 7 6 7 3 . 788 − 2 . 758 − 7 . 426 1 . 946 − 1 . 102 − 0 . 033 0 . 257 − 1 . 782 4 5 2 . 341 − 3 . 334 − 4 . 393 0 . 724 − 0 . 626 − 0 . 068 0 . 266 − 1 . 364 Tyler Genter Using JPEG to Compress Still Pictures

  17. Quantization Matrix An example quantization matrix, given in the official JPEG Standard:  16 11 10 16 24 40 51 61  12 12 14 19 26 58 60 55     14 13 16 24 40 57 69 56     14 17 22 29 51 87 80 62   Q =   18 22 37 56 68 109 103 77     24 35 55 64 81 104 113 92     49 64 78 87 103 121 120 101   72 92 95 98 112 100 103 99 Note the entries in the lower right tend to be larger. Tyler Genter Using JPEG to Compress Still Pictures

  18. Quantization Matrix We calculate F Q by: F Q ( u , v ) = Integer Round F ( u , v ) Q ( u , v ) Tyler Genter Using JPEG to Compress Still Pictures

  19. After Quantization 15 22 28 18 14 9 7 6   0 1 2 3 1 0 0 0     − 1 0 2 0 0 0 0 0     0 2 0 − 1 0 0 0 0 F Q =     0 1 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 Note how many entries of this matrix are zero. This means that it is easier to store to a disk. Yet it still contains enough information to reconstruct approximately the same image. Tyler Genter Using JPEG to Compress Still Pictures

  20. Result Original block before any Block after compression and processing: decompression: There is some difference. But the benefits are so dramatic they outweigh the costs. Tyler Genter Using JPEG to Compress Still Pictures

  21. Result When looking at the entire image Before: After: Tyler Genter Using JPEG to Compress Still Pictures

  22. This procedure is performed on the all of the 8 by 8 blocks that make up the image. Each block is efficiently stored to disk. Pretty much exactly the opposite process is used to decode and decompress a jpeg file. It can then be viewed or edited. Tyler Genter Using JPEG to Compress Still Pictures

  23. Bibliography Gregory K. Wallace. The JPEG Still Picture Compression Standard The International Telegraph and Telephone Consultative Committee. Information Technology: Digital Compression and Coding of Continuous-Tone Still Images – Requirements and Guidelines Nick Kingsbury. The Discrete Cosine Transform Rafael C. Gonzalez, et al. Digital Image Processing Using Matlab Tyler Genter Using JPEG to Compress Still Pictures

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend