JPEG The JPEG Standard JPEG is an image

  • Slides: 36
Download presentation
JPEG

JPEG

The JPEG Standard • JPEG is an image compression standard which was accepted as

The JPEG Standard • JPEG is an image compression standard which was accepted as an international standard in 1992. w Developed by the Joint Photographic Expert Group of the ISO/IEC w For coding and compression of color/gray scale images w Yields acceptable compression in the 10: 1 range

The JPEG Standard • JPEG is a lossy compression technique w Based on the

The JPEG Standard • JPEG is a lossy compression technique w Based on the DCT w JPEG is a general image compression technique independent of § Image resolution § Image and pixel aspect ratio § Color system § Image complexity w A scheme for video compression based on JPEG called Motion JPEG (MJPEG) exists

The JPEG Standard • JPEG is effective because of the following three observations w

The JPEG Standard • JPEG is effective because of the following three observations w Image data usually changes slowly across an image, especially within an 8 x 8 block § Therefore images contain much redundancy w Experiments indicate that humans are not very sensitive to the high frequency data images § Therefore we can remove much of this data using transform coding

The JPEG Standard • Humans are much more sensitive to brightness (luminance) information than

The JPEG Standard • Humans are much more sensitive to brightness (luminance) information than to color (chrominance) w JPEG uses chroma subsampling (4: 2: 0) • The following slide gives an overview of the various steps in JPEG compression

JPEG Encoding Overview

JPEG Encoding Overview

JPEG Encoding Overview • The main steps in JPEG encoding are the following w

JPEG Encoding Overview • The main steps in JPEG encoding are the following w Transform RGB to YUV or YIQ and subsample color w DCT on 8 x 8 image blocks w Quantization w Zig-zag ordering and run-length encoding w Entropy coding

DCT on Image Blocks • The image is divided up into 8 x 8

DCT on Image Blocks • The image is divided up into 8 x 8 blocks w 2 D DCT is performed on each block w The DCT is performed independently for each block w This is why, when a high degree of compression is requested, JPEG gives a “blocky” image result

Quantization • Quantization in JPEG aims at reducing the total number of bits in

Quantization • Quantization in JPEG aims at reducing the total number of bits in the compressed image w Divide each entry in the frequency space block by an integer, then round w Use a quantization matrix Q(u, v)

Quantization • Use larger entries in Q for the higher spatial frequencies w These

Quantization • Use larger entries in Q for the higher spatial frequencies w These are entries to the lower right part of the matrix w The following slide shows the default Q(u, v) values for luminance and chrominance § Based on psychophysical studies intended to maximize compression ratios while minimizing perceptual distortion § Since after division the entries are smaller, we can use fewer bits to encode them

Quantization

Quantization

Quantization • Multiple quantization matrices can be used (perhaps by scaling the defaults), allowing

Quantization • Multiple quantization matrices can be used (perhaps by scaling the defaults), allowing the user to choose how much compression to use w Trades off quality vs. compression ratio w More compression means larger entries in Q w An example of JPEG coding and decoding on one image block is shown next

Original and DCT coded block

Original and DCT coded block

Quantized and Reconstructed Blocks

Quantized and Reconstructed Blocks

After IDCT and Difference from Original

After IDCT and Difference from Original

Same steps on a less homogeneous block

Same steps on a less homogeneous block

Steps 2 and 3

Steps 2 and 3

IDCT and Difference

IDCT and Difference

Preparation for Entropy Coding • We have seen two main steps in JPEG coding:

Preparation for Entropy Coding • We have seen two main steps in JPEG coding: DCT and quantization • The remaining steps all lead up to entropy coding of the quantized DCT coefficients w These additional data compression steps are lossless w Most of the lossiness is in the quantization step

Run-Length Coding • We now do run-length coding w The AC and DC components

Run-Length Coding • We now do run-length coding w The AC and DC components are treated differently w Since after quantization we have many 0 AC components, RLC is a good idea w Note that most of the zero components are towards the lower right corner (high spatial frequencies) w To take advantage of this, use zigzag scanning to create a 64 -vector

Zigzag Scan in JPEG

Zigzag Scan in JPEG

Run-Length Coding • Now the RLC step replaces values in a 64 -vector (previously

Run-Length Coding • Now the RLC step replaces values in a 64 -vector (previously an 8 x 8 block) by a pair (RUNLENGTH, VALUE), where RUNLENGTH is the number of zeroes in the run and VALUE is the next non-zero value w From the first example we have (32, 6, -1, 0, 0, 1, 0, 0, …, 0) w This becomes (0, 6) (0, -1)(1, -1)(3, -1)(2, 1)(0, 0) - Note that DC coefficient is ignored

Coding of DC Coefficients • Now we handle the DC coefficients w 1 DC

Coding of DC Coefficients • Now we handle the DC coefficients w 1 DC per block w DC coefficients may vary greatly over the whole image, but slowly from one block to its neighbor (once again, zigzag order) w So apply Differential Pulse Code Modulation (DPCM) for the DC coefficients w If the first five DC coefficients are 150, 155, 149, 152, 144, we come up with DPCM code 150, 5, -6, 3, -8

Entropy Coding • Now we apply entropy coding to the RLC coded AC coefficients

Entropy Coding • Now we apply entropy coding to the RLC coded AC coefficients and the DPCM coded DC coefficients w The baseline entropy coding method uses Huffman coding on images with 8 -bit components w DPCM-coded DC coefficients are represented by a pair of symbols (SIZE, AMPLITUDE) § SIZE = number of bits to represent coefficient § AMPLITUDE = the actual bits

Entropy Coding • The size category for the different possible amplitudes is shown below

Entropy Coding • The size category for the different possible amplitudes is shown below w DPCM values might require more than 8 bits and might be negative

Entropy Coding w One’s complement is used for negative numbers w Codes 150, 5,

Entropy Coding w One’s complement is used for negative numbers w Codes 150, 5, -6, 3, -8 become w (8, 10010110), (3, 101), (2, 11), (4, 0111) w Now the SIZE is Huffman coded § Expect lots of small SIZEs w AMPLITUDE is not Huffman coded § Pretty uniform distribution expected, so probably not worth while

Huffman Coding for AC Coefficients • AC coefficients have been RL coded and represented

Huffman Coding for AC Coefficients • AC coefficients have been RL coded and represented by symbol pairs (RUNLENGTH, VALUE) w VALUE is really a (SIZE, AMPLITUDE) pair § RUNLENGTH and SIZE are each 4 -bit values stored in a single byte - Symbol 1 • For runs greater than 15, special code (15, 0) is used § Symbol 2 is the AMPLITUDE § Symbol 1 is run-length coded, Symbol 2 is not

JPEG Modes • JPEG supports several different modes w Sequential Mode w Progressive Mode

JPEG Modes • JPEG supports several different modes w Sequential Mode w Progressive Mode w Hierarchical Mode w Lossless Mode • Sequential is the default mode w Each image component is encoded in a single left-to-right, top-to-bottom scan § This is the mode we have been describing

Progressive Mode • Progressive mode delivers low-quality versions of the image quickly, and then

Progressive Mode • Progressive mode delivers low-quality versions of the image quickly, and then fills in the details in successive passes • This is useful for web browsers, where the image download might take a long time w The user gets an approximate image quickly w Can be done by sending the DC coefficient and a few AC coefficients first w Next send some more (low spatial resolution) AC coefficients, and continue in this way until all of the coefficients have been sent

Sequential vs. Progressive

Sequential vs. Progressive

JPEG 2000 • JPEG 2000 (extension jp 2) is the latest series of standards

JPEG 2000 • JPEG 2000 (extension jp 2) is the latest series of standards from the JPEG committee w w w w Uses wavelet technology Better compression than JPG Superior lossless compression Supports large images and images with many components Region-of-interest coding Compound documents Computer-generated imagery Other improvements over JPG

Original

Original

JPEG 27: 1

JPEG 27: 1

JPEG 2000 27: 1

JPEG 2000 27: 1

Region-of-Interest Coding

Region-of-Interest Coding

JBIG • JBIG (Joint Bi-Level Image Processing Group) is a standard for coding binary

JBIG • JBIG (Joint Bi-Level Image Processing Group) is a standard for coding binary images w Faxes, scanned documents, etc. w These have characteristics different from color/greyscale images which lend themselves to different coding techniques w JBIG - lossless coding w JBIG 2 - both, lossless and lossy § Model-based coding