Presentation is loading. Please wait.

Presentation is loading. Please wait.

JPEG. Introduction JPEG (Joint Photographic Experts Group) Basic Concept Data compression is performed in the frequency domain. Low frequency components.

Similar presentations


Presentation on theme: "JPEG. Introduction JPEG (Joint Photographic Experts Group) Basic Concept Data compression is performed in the frequency domain. Low frequency components."— 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) 79757982 8694 7678768283868594 7275677880787482 747675 86808179 7370756778 7985 6963686975788280 76 71 67798083 7277786975 78

14 DCT coefficients of the image block X(u,v) 619-29821-301 22-6-4070-2-3 1105-4-340 2-10500732 62 -3008 121202-2 -8-2-41211 -315-211-3

15 Quantization table Q(u,v) 1611101624405161 12 141926586055 1413162440576956 1417222951878062 182237566810910377 243555648110411392 49647887103121120101 7292959811210010399

16 Quantized DCT coefficients X q (u,v) 39-3100000 2000000 10000000 0 000000 00000000 00000000 00000000 00000000

17 Dequantized DCT coefficients X r (u,v) 624-331000000 24-12000000 140000000 0-17000000 00000000 00000000 00000000 00000000

18 Reconstructed image block 7475778085919598 77 787982868991 7877 78818384 74 76788182 69 707275788284 68 697175798285 73 727375778081 7877767574757677

19 Error block 5022-3-5-4 1-2310-41 -6-2-1012-3-9-2 02111020-3 415-530-31 1-5-200-5 33-2-8202 -602 1021

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 DIFF f value,defined as DIFF f = Xq f (0,0)-Xq f-1 (0,0) where Xq f (0,0) = The DC coefficient of the current block. Xq f-1 (0,0) = The DC coefficient of the previous block.

23 The DIFF f values are classified into 12 classes (Table1). Class DIFF f value 0 1 2 3 4 5 6 7 8 9 10 11 0 -1,1 -3,-2,2,3 -7, …,-4,4, …,7 -15, …,-8,8, …,15 -31, …,-16,16, …,31 -63, …,-32,32, …,63 -127, …,-64,64, …,127 -255,..,-128,128, …,255 -511, …,-256,256, …,511 -1023, …,-512,512, …,1023 -2047,..,-1024,1024, …,2047 TABLE 1

24 ClassCodeword 0 1 2 3 4 5 6 7 8 9 10 11 00 010 011 100 101 110 1110 11110 111110 1111110 11111110 111111110 TABLE 2 The Huffman code representing each class is shown in Table2.

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

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

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

28 Example If DIFF f = 5,then it is represented as If DIFF f = -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. Class AC coefficients 1 2 3 4 5 6 7 8 9 10 -1,1 -3,-2,2,3 -7,..,-4,4,..,7 -15, …,-8,8, …,15 -31, …,-16,16, …,31 -63, …,-32,32, …,63 -127, …,-64,64, …,127 -255, …,-128,128, …,255 -511, …,-256,256, …,511 -1023, …,-512,512, …,1023 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 coefficients along 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 DIFF f, Note that Xq f (0,0) = 39,Assume Xq f-1 (0,0) = 34. Then DIFF f = 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

43 Discussions The major drawbacks of JPEG are: –The algorithm may have block artifact. –It is difficult to perform accurate rate control. –It is sensitive to transmission errors.


Download ppt "JPEG. Introduction JPEG (Joint Photographic Experts Group) Basic Concept Data compression is performed in the frequency domain. Low frequency components."

Similar presentations


Ads by Google