1 / 43

JPEG

JPEG. Introduction. JPEG (Joint Photographic Experts Group) Basic Concept Data compression is performed in the frequency domain. Low frequency components are retained. High frequency components are truncated. JPEG System Overview.

norina
Télécharger la présentation

JPEG

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. JPEG

  2. Introduction • JPEG (Joint Photographic Experts Group) • Basic Concept Data compression is performed in the frequency domain. Low frequency components are retained. High frequency components are truncated

  3. JPEG System Overview • The JPEG is a transform coding scheme. Its encoding process can be separated into 3 stages: Color Transform Discrete Cosine Transform Quantization Bitstream Formation

  4. Color Transform • Process the data in blocks of 8×8 samples • Convert RGB into Luminance (Y) and Chrominance (Cr and Cb). • Use half resolution for Chrominance (because eye is more sensitive to Luminance)

  5. Discrete Cosine Transform • Transform each block of 8×8 samples into 64 DCT coefficients • energy tends to be concentrated into a few significant coefficients

  6. Quantization (I) • Divide each DCT coefficient by an integer, discard remainder • Typically, a few non-zero coefficients are left.

  7. Quantization (II)

  8. DCT Transform • The JPEG is based on the 8 × 8 DCT. • To use the DCT ,we first divide an image into non-overlapping 8 × 8 blocks. • Let x(n,m), 0≦n,m≦7, be the pixel values in the block. • Let X(u,v), 0≦u,v≦7, be the DCT coefficients.

  9. The X(u,v) and x(n,m) are related by where and N = 8

  10. Quantization In the JPEG,each of the 64 resulting DCT coefficients is quantized by an uniform scalar quantizer according to the following equation: where Xq(u,v) is the quantized coefficient and

  11. is the quantization table.

  12. Note that Q should be the same at the encoder and decoder. Given Xq(u,v) and Q(u,v), 0≦ u,v≦ 7,the dequantized DCT coefficients Xr(u,v), 0≦ u,v≦ 7, are then obtained by Xr(u,v) = Xq(u,v) Q(u,v)

  13. Example • Original Image block x(m,n)

  14. DCT coefficients of the image block X(u,v)

  15. Quantization table Q(u,v)

  16. Quantized DCT coefficients Xq(u,v)

  17. Dequantized DCT coefficients Xr(u,v)

  18. Reconstructed image block

  19. Error block

  20. Bitstream Formation Here we use the Huffman code to form bitstream representing the quantized DCT coefficients.

  21. Before performing the Huffman coding, all the quantized coefficients are separated into two groups: (1)DC coefficient: Xq(0,0) (2)AC coefficients: Xq(u,v), u≠0 or v≠ 0 These two groups are encoded independently.

  22. DC coefficient The encoding of the DC coefficient is based on the DIFFf value ,defined as DIFFf = Xqf(0,0)-Xqf-1(0,0) where Xqf(0,0) = The DC coefficient of the current block. Xqf-1(0,0) = The DC coefficient of the previous block.

  23. The DIFFf values are classified into 12 classes (Table1). TABLE 1

  24. The Huffman code representing each class is shown in Table2. TABLE 2

  25. When DIFFf class 0,DIFFf is represented by codeword 00. When DIFFf classes 1-11 ,the representation of DIFFf consists of two parts:

  26. The Extra Bits can be expressed in the following form: Extra Bits = Sign bit + Amplitude When DIFFf> 0,Sign bit = 1 When DIFFf< 0, Sign bit = 0

  27. When DIFFf> 0: Amplitude=Lower-order bit of DIFFf (MSB is not include.) When DIFFf< 0: Amplitude = 1’s complement of lower-order bits of |DIFFf|

  28. Example If DIFFf= 5,then it is represented as If DIFFf = -5,then it is represented as

  29. AC coefficients The Huffman coding of the AC coefficients can be separated into three stages: Stage 1: ZigZag ordering of AC coefficients. Stage 2: Run/Size Representation of Nonzero AC coefficients. Stage 3: Huffman encoding based on the Run/Size Representation.

  30. Zig-zag Ordering

  31. Run/Size Representation Because many AC coefficients become zero after quantization, runs of zeros along the zigzag scan are identified and compacted.

  32. Each nonzero AC coefficientis descibed by a composite R/S,where R(Run) is a 4-bit zero-run from the previous non-zero value, and S(Size) represents the size of the non-zero AC coefficient.

  33. The size can be separated into 10 classes as shown in Table 3. TABLE 3

  34. Huffman Encoding A Huffman table has been generated for each composite R/S. The Huffman encoding process of the AC coefficients is based on the table. The additional bits to the Huffman codes are the same as those for coding the DC coefficients.

  35. There are two special cases that describe some attention : Case 1 : all the remaining coefficientsalong the zigzag scan are zero. In this case,we set R/S =x’00’, which is coded as an EOB code of 1010.

  36. Case 2 : zero-run are greater than 16. In this case ,we set R/S = x’F0’(15 zero- runs and 1 zero value). Therefore 16 zero-runs are coded. The same procedure is repeated until the length of zero-runs is less than 16.

  37. Example Consider the Xq matrix shown below: After the zig-zag ordering process ,we have (39 -3 2 1 -1 1 0 0 0 0 0 -1 EOB)

  38. To encode 39 , we first have to compute DIFFf , Note that Xqf(0,0) = 39 ,Assume Xqf-1(0,0) = 34. Then DIFFf= 5 ,From the previous example, We conclude that 39 can be encoded as 100101

  39. The first AC coefficient is –3. The R and S values for –3 is R=0 and S=2 , respectively. The corresponding Huffman code is 01. Consequently, -3 is encoded as Proceed in the similar fashion ,we have (100101/0100/0110/001/000/001/11110100/1010)

  40. Note that the last nonzero coefficient –1 has R=5 and S=1. The Huffman code therefore is 1111010. Consequently, -1 is encode as A total of 35 bits are needed to deliver this block. The bit rate for this block is

  41. Run/Size Table

  42. Discussions • The major drawbacks of JPEG are: • The algorithm may have block artifact. • It is difficult to perform accurate rate control.

More Related