Introduction to JPEG

Post on 21-Jan-2016

31 views 0 download

description

http://en.wikipedia.org/wiki/JPEG. Introduction to JPEG. m5141153 Akram Ben Ahmed. Outline. Introduction Encoding Decoding Summary and Future work. Introduction. JPEG (Joint Photographic Experts Group) is one of the most widely used lossy compression method. - PowerPoint PPT Presentation

Transcript of Introduction to JPEG

Introduction to JPEG

m5141153 Akram Ben Ahmed

http://en.wikipedia.org/wiki/JPEG

森 憲一

Outline

• Introduction• Encoding• Decoding• Summary and Future work

Research Paper Reading 22010/7/12

Introduction

• JPEG (Joint Photographic Experts Group) is one of the most widely used lossy compression method.

• JPEG has many standards and can be encoded in many ways.

06/22/2011 Research Progress Seminar 3

Outline

• Introduction• Encoding• Decoding• Summary and Future work

Research Paper Reading 42010/7/12

Encoding: Color space transformation

• The image should be converted first from RGB to YCrCb.

• Y represents the brightness of the picture while Cr and Cb represent the red and bleu chrominance respectively.

• This picture shows a color image and the Y, Cb and Cr elements of it.

06/22/2011 Research Progress Seminar 5

Encoding: Color space transformation

• The conversion is done by multiplying the pixels values of the RGB image by Y, Cr and Cb factors as shown below.

06/22/2011 Research Progress Seminar 6

Encoding: Downsampling

• In this step, the resolution of the Chroma components (Cr and Cb) is reduced.

• This reduction came from the fact that human eyes detect the brightness change more than the color differences.

06/22/2011 Research Progress Seminar 7

Encoding: Downsampling

• The ratios at which the downsampling is ordinarily done for JPEG images are 4:4:4, 4:2:2 or 4:2:0 (most commonly) .

06/22/2011 Research Progress Seminar 8

Encoding

• The next process steps are done to each Y Cr Cb components separately.

06/22/2011 Research Progress Seminar 9

Encoding: Discrete cosine transform

• We divide first the image into 8x8 blocks.• If one block can’t be exactly represented in

8x8, the encoder must fill the remaining area of the incomplete blocks with some form of dummy data.

06/22/2011 Research Progress Seminar 10

Encoding: Discrete cosine transform

• Before computing the DCT of the 8×8 block, its values are shifted from a positive range (0-->255) to one centered around zero by subtracting the mid-point of the range (128 in our case) from the original block values.

06/22/2011 Research Progress Seminar 11

Encoding: Discrete cosine transform

06/22/2011 Research Progress Seminar 12

m= Original Block matrix g= Resulted shifted matrix

Encoding: Discrete cosine transform

• We perform now the 2D DCT given by:

– u is the horizontal spatial frequency, for the integers 0<u<8.– v is the vertical spatial frequency, for the integers 0<v<8.

– .

– gx,y is the pixel value at coordinates (x,y)– Gu,v is the DCT coefficient at coordinates (u,v)

06/22/2011 Research Progress Seminar 13

Encoding: Discrete cosine transform

• The resulted DCT matrix G is:

06/22/2011 Research Progress Seminar 14

Encoding: Quantization

• This step consists of dividing each component in the frequency domain by a constant for that component, and then rounding to the nearest integer.

• This makes the quantization the only lossy operation due to the rounding operation.

06/22/2011 Research Progress Seminar 15

Encoding: Quantization

• Assuming the following quantization matrix:

06/22/2011 Research Progress Seminar 16

Encoding: Quantization

• And that the quantization formula is:

• The resulted rounded matrix is:

06/22/2011 Research Progress Seminar 17

Encoding: Entropy coding

• Involves arranging the image components in a "zigzag" order employing run-length encoding (RLE) algorithm that groups similar frequencies together, inserting length coding zeros, and then using Huffman coding on what is left.

06/22/2011 Research Progress Seminar 18

Encoding: Entropy coding

06/22/2011 Research Progress Seminar 19

• The zigzag sequence for the above quantized matrix B is:

Encoding: Entropy coding

• In order to encode the above generated coefficient pattern, JPEG uses Huffman encoding.

• If we consider that an image can be divided into n 8x8 blocks {B1, B2, … Bn} and each block is represented by horizontal (x) and vertical (y)

coordinates, we distinguish 2 different types of encoding.

06/22/2011 Research Progress Seminar 20

Encoding: Entropy coding

• Baseline sequential encoding: Takes the components of one single block then go to next block of the image.

• Starting from i=1, the order of the zigzag encoding is Bi(0,0), B0(0,1), Bi(1,0), Bi(2,0), Bi(1,1), Bi(0,2), Bi(0,3), Bi(1,2). Then the next block (i+1) until Bn.

06/22/2011 Research Progress Seminar 21

Encoding: Entropy coding

• Progressive encoding: Takes one single component for all the different blocks, then move to the next component.

• The order of the zigzag encoding starts with Bi(0,0) for all the blocks {B1, B2, … Bn} then Bi(0,1) also for all the blocks.

• JPEG has a special Huffman code word for ending the sequence prematurely when the remaining coefficients are zero.

06/22/2011 Research Progress Seminar 22

Encoding: Entropy coding

• Using this special code word: "EOB", the sequence becomes:

06/22/2011 Research Progress Seminar 23

Encoding: Compression ratio and artifacts

• One of the problems that can be found with JPEG, is some differences between the original and the resulted compressed image.

• These differences are called artifacts and I should be fixed to assure a good compression quality.

06/22/2011 Research Progress Seminar 24

Outline

• Introduction• Encoding• Decoding• Summary and Future work

Research Paper Reading 252010/7/12

Decoding

• Decoding consists of doing all the encoding steps in reverse. Starting with DCT coefficient matrix of one single 8x8 block:

06/22/2011 Research Progress Seminar 26

Decoding

• Make entry-for-entry product with the same quantization Q matrix as in Encoding :

06/22/2011 Research Progress Seminar 27

Decoding

• Using the Inverse 2D-DCT expressed by:

06/22/2011 Research Progress Seminar 28

Decoding

• We round then the resulted values we can get the following matrix:

06/22/2011 Research Progress Seminar 29

Decoding

• As we did in the Encoding part, we should shift back the values by 128 to obtain :

06/22/2011 Research Progress Seminar 30

Decoding

• Since the previous steps are for one block, we should reassemble all the blocks together to form the complete image.

• One way to check the quality of the compression is to compare the original image with the decompressed one.

06/22/2011 Research Progress Seminar 31

Decoding

• Subtracting the uncompressed resulted image from the original one we can obtain the following error matrix:

06/22/2011 Research Progress Seminar 32

Decoding

• Finally we can calculate the average absolute error to evaluate the decompression quality:

06/22/2011 Research Progress Seminar 33

Outline

• Introduction• Encoding• Decoding• Other• Summary and Future work

Research Paper Reading 342010/7/12

Summary and Future work

• In this article, JPEG was presented as a well known compression technique widely used in different image processing domains thanks to its simplicity and high flexibility maintaining a good compression quality.

06/22/2011 Research Progress Seminar 35

Summary and Future work

• Unfortunately this article doesn’t explain the steps after the Huffman coding and the buffering operation after this process.

• As this part of the JPEG encoder is extremely important, I should investigate more about it as a future work.

06/22/2011 Research Progress Seminar 36