# JPEG Compression

Published on March 6, 2009

Author: ankush85

Source: authorstream.com

JPEG Compression : 1 JPEG Compression Fact about JPEG Compression : 2 Fact about JPEG Compression JPEG stands for Joint Photographic Experts Group JPEG compression is used with .jpg and can be embedded in .tiff and .eps files. Used on 24-bit color files. Works well on photographic images. Although it is a lossy compression technique, it yields an excellent quality image with high compression rates. Steps in JPEG Compression : 3 Steps in JPEG Compression 1. (Optionally) If the color is represented in RGB mode, translate it to YUV. 2. Divide the file into 8 X 8 blocks. 3. Transform the pixel information from the spatial domain to the frequency domain with the Discrete Cosine Transform. 4. Quantize the resulting values by dividing each coefficient by an integer value and rounding off to the nearest integer. 5. Look at the resulting coefficients in a zigzag order. Do a run-length encoding of the coefficients ordered in this manner. Follow by Huffman coding. Step 1a: Converting RGB to YUV : 4 Step 1a: Converting RGB to YUV YUV color mode stores color in terms of its luminance (brightness) and chrominance (hue). The human eye is less sensitive to chrominance than luminance. YUV is not required for JPEG compression, but it gives a better compression rate. RGB vs. YUV : 5 RGB vs. YUV It’s simple arithmetic to convert RGB to YUV. The formula is based on the relative contributions that red, green, and blue make to the luminance and chrominance factors. There are several different formulas in use depending on the target monitor. For example: Y = 0.299 * R + 0.587 * G + 0.114 * B U = -0.1687 * R – 0.3313* G + 0.5 * B + 128 V = 0.5 * R – 0.4187 * G – 0.813 * B + 128 Step 1b: Downsampling : 6 Step 1b: Downsampling The chrominance information can (optionally) be downsampled. The notation 4:1:1 means that for each block of four pixels, you have 4 samples of luminance information (Y), and 1 each of the two chrominance components (U and V). MCU – minimum coded unit Y Y Y Y U, V Step 2: Divide into 8 X 8 blocks : 7 Step 2: Divide into 8 X 8 blocks Note that with YUV color, you have 16 pixels of information in each block for the Y component (though only 8 in each direction for the U and V components). If the file doesn’t divide evenly into 8 X 8 blocks, extra pixels are added to the end and discarded after the compression. The values are shifted “left” by subtracting 128. (See JPEG Compression for details.) Discrete Cosine Transform : 8 Discrete Cosine Transform The DCT transforms the data from the spatial domain to the frequency domain. The spatial domain shows the amplitude of the color as you move through space The frequency domain shows how quickly the amplitude of the color is changing from one pixel to the next in an image file. Step 3: DCT : 9 Step 3: DCT The frequency domain is a better representation for the data because it makes it possible for you to separate out – and throw away – information that isn’t very important to human perception. The human eye is not very sensitive to high frequency changes – especially in photographic images, so the high frequency data can, to some extent, be discarded. Step 3: Forward DCT : 10 Step 3: Forward DCT For an N X N pixel image the DCT is an array of coefficients where where Step 3: DCT : 11 Step 3: DCT The color amplitude information can be thought of as a wave (in two dimensions). You’re decomposing the wave into its component frequencies. For the 8 X 8 matrix of color data, you’re getting an 8 X 8 matrix of coefficients for the frequency components. Slide 12: 12 Fourier Transform (p. 42 in your book) Slide 13: 13 Basic Functions for Discrete Cosine Transform Step 4: Quantize the CoefficientsComputed by the DCT : 14 Step 4: Quantize the CoefficientsComputed by the DCT The DCT is lossless in that the reverse DCT will give you back exactly your initial information (ignoring the rounding error that results from using floating point numbers.) The values from the DCT are initially floating-point. They are changed to integers by quantization. See JPEG Compression for an example. Step 4: Quantization : 15 Step 4: Quantization Quantization involves dividing each coefficient by an integer between 1 and 255 and rounding off. The quantization table is chosen to reduce the precision of each coefficient to no more than necessary. The quantization table is carried along with the compressed file. Step 5: Arrange in “zigzag” order : 16 Step 5: Arrange in “zigzag” order This is done so that the coefficients are in order of increasing frequency. The higher frequency coefficients are more likely to be 0 after quantization. This improves the compression of run-length encoding. Do run-length encoding and Huffman coding.

03. 04. 2009
0 views

06. 03. 2009
0 views

27. 03. 2009
0 views

20. 11. 2009
0 views

22. 11. 2009
0 views

14. 07. 2009
0 views

18. 03. 2009
0 views

08. 04. 2009
0 views

06. 03. 2009
0 views

20. 04. 2009
0 views

03. 06. 2013
0 views

03. 06. 2013
0 views

16. 10. 2012
0 views

25. 09. 2012
0 views

25. 09. 2012
0 views

03. 01. 2012
0 views

24. 11. 2009
0 views

22. 11. 2009
0 views

22. 11. 2009
0 views

16. 05. 2009
0 views

19. 04. 2009
0 views

16. 05. 2009
0 views

10. 07. 2009
0 views

01. 07. 2009
0 views

21. 07. 2009
0 views

21. 07. 2009
0 views

01. 07. 2009
0 views

05. 03. 2009
0 views

13. 06. 2009
0 views

11. 05. 2009
0 views

05. 03. 2009
0 views

06. 03. 2009
0 views

25. 08. 2009
0 views

19. 06. 2009
0 views

24. 06. 2009
0 views

02. 10. 2008
0 views

25. 04. 2009
0 views

28. 04. 2009
0 views

17. 06. 2009
0 views

25. 04. 2009
0 views

25. 06. 2009
0 views

19. 06. 2009
0 views

18. 03. 2009
0 views

27. 04. 2009
0 views

23. 03. 2009
0 views

23. 05. 2009
0 views

23. 05. 2009
0 views

24. 06. 2009
0 views

24. 05. 2009
0 views

03. 04. 2009
0 views

08. 04. 2009
0 views

23. 03. 2009
0 views

06. 03. 2009
0 views

06. 03. 2009
0 views

29. 04. 2009
0 views

24. 05. 2009
0 views

06. 03. 2009
0 views

11. 04. 2009
0 views

08. 03. 2009
0 views

13. 03. 2009
0 views

04. 09. 2009
0 views

20. 11. 2009
0 views

22. 11. 2009
0 views

06. 03. 2009
0 views

06. 03. 2009
0 views

21. 04. 2009
0 views

25. 05. 2009
0 views

06. 03. 2009
0 views

05. 03. 2009
0 views

14. 07. 2009
0 views

14. 07. 2009
0 views

05. 03. 2009
0 views

09. 05. 2009
0 views

05. 03. 2009
0 views

05. 03. 2009
0 views

05. 03. 2009
0 views

06. 03. 2009
0 views

06. 03. 2009
0 views

06. 03. 2009
0 views

06. 03. 2009
0 views

06. 03. 2009
0 views

06. 03. 2009
0 views

06. 03. 2009
0 views

09. 03. 2009
0 views

09. 03. 2009
0 views

13. 03. 2009
0 views

19. 03. 2009
0 views

25. 03. 2009
0 views

08. 04. 2009
0 views

10. 04. 2009
0 views

10. 04. 2009
0 views

13. 04. 2009
0 views

15. 04. 2009
0 views

17. 04. 2009
0 views

23. 04. 2009
0 views

21. 04. 2009
0 views

21. 04. 2009
0 views

21. 04. 2009
0 views

23. 04. 2009
0 views

25. 04. 2009
0 views

25. 04. 2009
0 views

29. 04. 2009
0 views

29. 04. 2009
0 views

26. 04. 2009
0 views

26. 04. 2009
0 views

27. 04. 2009
0 views

05. 05. 2009
0 views

14. 05. 2009
0 views

16. 05. 2009
0 views

15. 05. 2009
0 views

15. 05. 2009
0 views

23. 04. 2009
0 views

23. 05. 2009
0 views

23. 05. 2009
0 views

24. 05. 2009
0 views

28. 05. 2009
0 views

04. 06. 2009
0 views

19. 06. 2009
0 views

19. 06. 2009
0 views

07. 06. 2009
0 views

13. 06. 2009
0 views

13. 06. 2009
0 views

13. 06. 2009
0 views

13. 06. 2009
0 views

13. 06. 2009
0 views

13. 06. 2009
0 views

13. 06. 2009
0 views

13. 06. 2009
0 views

13. 06. 2009
0 views

15. 06. 2009
0 views

26. 06. 2009
0 views

27. 06. 2009
0 views

01. 07. 2009
0 views

06. 07. 2009
0 views

05. 07. 2009
0 views

05. 07. 2009
0 views

10. 07. 2009
0 views

01. 08. 2009
0 views

26. 04. 2009
0 views

21. 08. 2009
0 views

25. 08. 2009
0 views

27. 08. 2009
0 views

27. 08. 2009
0 views

27. 08. 2009
0 views

04. 09. 2009
0 views

04. 09. 2009
0 views

27. 06. 2009
0 views