Top Banner
JPEG Marco Fuentes García Francisco Gea Martínez
37

JPEG

Feb 23, 2016

Download

Documents

anson

JPEG. Marco Fuentes García Francisco Gea Martínez. Topics. Why do we need image compression ? Lossless and lossy compression Image file formats What is JPEG ? Steps of compressions Effects of JPEG compression. Why do we need image compression ?. - PowerPoint PPT Presentation
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: JPEG

JPEGMarco Fuentes GarcíaFrancisco Gea Martínez

Page 2: JPEG

TOPICS Why do we need image compression? Lossless and lossy compression Image file formats What is JPEG? Steps of compressions Effects of JPEG compression

Page 3: JPEG

WHY DO WE NEED IMAGE COMPRESSION? there are numerous applications involving

processing, storage and transmission of digital images, generating a large number of files of large size

An RGB image 800x600 24 bits/px without compression takes 800x600x24 = 1.4 MB

Page 4: JPEG

The aim of compressing images: Reduce the size

Image compression: Reduce the amount of data keeping the information

Page 5: JPEG

LOSSLESS AND LOSSY COMPRESSION In many applications the compression is only

acceptable from the point of view of error-free data reduction Medical imaging, satellite, legal documents…

in others, small loss of information can lead to a compression efficiency Internet, multimedia, FAX…

Page 6: JPEG

Compression Lossly

The image obtained after decompression has error

Lossless Compression preserve the data. It is possible to

decompress the image without error

Page 7: JPEG

IMAGE FILE FORMATSFormat Real

colorPalette

Gray

Bitonal

Compression

Source Multi-Image

Bitmap (BMP)

Yes Yes Yes Yes Run-length

Windows No

TIFF Yes Yes Yes Yes JPG, LZW, Runs, CCITT4, CCITT3, packBits

Standard

Yes

JFIF(JPEG) Yes No Yes No JPEG Standard

No

PCX No Yes No No Own Windows NoPGM No No Yes No No Unix NoGIF No Yes Yes Yes LZW Standar

dYes

Page 8: JPEG

WHAT IS JPEG? JPEG (Joint Photographic Experts Group)

defines various standards for monochromatic and color images

Each standard uses differents compression methods:

Standard AlgorithmJPEG – original TDC + HuffmanJPEG – 2000 TDW (Wavelets)JPEG – LS (Lossless)

Lossless prediction + Run-lenghts

Page 9: JPEG

JPEG, JFIF AND SPIFF JPEG defines some compression methods

Eric Hamilton created JFIF (JPEG File Interchange Format)

JPEG file usually means JPEG file in JFIF format

Later, SPIFF replaced JFIF

Page 10: JPEG

STEPS OF COMPRESSIONS The encoding process consists of several steps:

The representation of the colors in the image is converted from RGB to Y′CBCR, consisting of one luma component (Y'), representing brightness, and two chroma components, (CB and CR).

The image is split into blocks of 8×8 pixels, and for each block, each of the Y, CB, and CR data undergoes the Discrete Cosine Transform (DCT)

The amplitudes of the frequency components are quantized.

The resulting data for all 8×8 blocks is further compressed with a lossless algorithm, a variant of Huffman encoding

Page 11: JPEG

STEPS OF COMPRESSIONS

Page 12: JPEG

RGB -> YUV

JFIF usage of JPEG allows Y’CbCr where Y’, Cb and Cr have the full 8-bit range of 0-255.

And back:

Page 13: JPEG

JPEG FORMAT A JPEG image consists of a sequence of segments, each beginning with a marker, each of which begins with a 0xFF byte followed by a byte indicating what kind of marker it is.

Page 14: JPEG

After each data marker usually appear two bytes that indicate the length of data containing.

Example: FF DB 00 43, Following 43 bytes define quantization table

Page 15: JPEG

EXAMPLE

Page 16: JPEG

DCT DCT becomes a set input of a set of

coefficients with increasing frequency cosine. Each component of the image is divided into

small blocks of 8 × 8 pixels, which are processed almost independently, which significantly reduces the computation time.

Page 17: JPEG

EXAMPLE:

[0,255] -> [-128,127]

Page 18: JPEG

The next step is to take the two-dimensional DCT, which is given by:

Top-left corner entry with the rather large magnitude. This is the DC coefficient. The remaining 63 coefficients are called the AC coefficients.

Page 19: JPEG

QUANTIZATION The human eye is good at seeing small

differences in brightness over a relatively large area, but not so good at distinguishing the exact strength of a high frequency brightness variation.

This allows one to greatly reduce the amount of information in the high frequency components.

This is done by simply dividing each component in the frequency domain by a constant for that component, and then rounding to the nearest integer.

Page 20: JPEG

This rounding operation is the only lossy operation in the whole process (other than chroma subsampling) if the DCT computation is performed with sufficiently high precision.

As a result of this, it is typically the case that many of the higher frequency components are rounded to zero, and many of the rest become small positive or negative numbers, which take many fewer bits to represent.

Page 21: JPEG

The elements in the quantization matrix control the compression ratio, with larger values producing greater compression. A typical quantization matrix, as specified in the original JPEG Standard, is as follows:

Page 22: JPEG

The quantized DCT coefficients are computed with:

Where G is the unquantized DCT coefficients; Q is the quantization matrix above; and B is the quantized DCT coefficients.

Page 23: JPEG

Using this quantization matrix with the DCT coefficient matrix from above results in:

Page 24: JPEG

24

ENTROPY CODING Entropy coding is a special form of lossless

data compression.  It 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.

Page 25: JPEG

25

−26, −3, 0, −3, −2, −6, 2, −4, 1 −4, 1, 1, 5, 1, 2, −1, 1, −1, 2, 0, 0, 0, 0, 0, −1, −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, 0, 0, 0, 0, 0, 0, 0, 0

Huffman code: −26, −3, 0, −3, −2, −6, 2, −4, 1 −4, 1, 1, 5, 1, 2, −1, 1, −1, 2, 0, 0, 0, 0, 0, −1, −1, EOB

Page 26: JPEG

DECODING Decoding to display the image consists of

doing all the above in reverse. Taking the DCT coefficient matrix (after

adding the difference of the DC coefficient back in)

Page 27: JPEG

and taking the entry-for-entry product with the quantization matrix from above results in

which closely resembles the original DCT coefficient matrix for the top-left portion.

Page 28: JPEG

The next step is to take the two-dimensional inverse DCT (a 2D type-III DCT), which is given by:

Where: x is the pixel row y is the pixel column F_u,v is the reconstructed approximate coeffiecient at

coordinates (u,v) f_u,v is the reconstructed pixel value at coordinates (x,y)

Page 29: JPEG

Rounding the output to integer values (since the original had integer values) results in an image with values (still shifted down by 128)

Page 30: JPEG

and adding 128 to each entry

This is the decompressed subimage

Page 31: JPEG

EFFECTS OF JPEG COMPRESSIONQuality Size

(bytes)Compression ratio

Comment

Highest quality (Q = 100)

83,261 2.6:1 Extremely minor artifacts

Page 32: JPEG

Quality Size (bytes)

Compression ratio

Comment

High quality (Q = 50)

15,138 15:1 Initial signs of subimage artifacts

Page 33: JPEG

Quality Size (bytes)

Compression ratio

Comment

Medium quality (Q = 25)

9,553 23:1 Stronger artifacts; loss of high frequency information

Page 34: JPEG

Quality Size (bytes)

Compression ratio

Comment

Low quality (Q = 10)

4,787 46:1 Severe high frequency loss; artifacts on subimage boundaries are obvious

Page 35: JPEG

Quality Size (bytes)

Compression ratio

Comment

Lowest quality (Q = 1)

1,523 144:1 Extreme loss of color and detail; the leaves are nearly unrecognizable

Page 36: JPEG

36

http://www.youtube.com/watch?v=Fk6kV5N1rzs&feature=player_embedded