Presentation is loading. Please wait.

Presentation is loading. Please wait.

Image Compression Lecture 5. Image Compression  GIF (Graphics Interchange Format)  PNG (Portable Network Graphics)  JPEG (Join Picture Expert Group)

Similar presentations


Presentation on theme: "Image Compression Lecture 5. Image Compression  GIF (Graphics Interchange Format)  PNG (Portable Network Graphics)  JPEG (Join Picture Expert Group)"— Presentation transcript:

1 Image Compression Lecture 5

2 Image Compression  GIF (Graphics Interchange Format)  PNG (Portable Network Graphics)  JPEG (Join Picture Expert Group)

3 GIF (Graphics Interchange Format)  Introduced by Compuserv in 1987 (GIF87a)  Support for multiple images in one file and metadata adding in 1989 (GIF89a)  Indexed image format: up to 256 colours per image chosen from a variable palette.  One colour index can indicate transparency.  Uses lossless LZW compression of data bytes.  Optional interlacing capability.

4 LZW (Lempel-Ziv-Welch)  LZW is a form of dictionary coding (based on LZ78).  Build a dictionary of words in the text to be encoded.  Send index into dictionary instead of word itself.  Example of dictionary encoding  Uncompressed text: “I am dumb and because I am dumb, I can’t even tell you that I am dumb.”  Compressed text: “$1 and because $1, I can’t even tell you that $1. $1 = [I am dumb]”  Nice property is that dictionary does not need to be sent – is rebuilt automatically at receiver.

5 GIF Uses  GIF became very popular in the early days of the Web.  Supported by NCSA Mosaic.  Pretty good compression.  Most displays then were indexed rather than truecolour.  Today, it’s still good for diagrams, cartoons and other non-photographic images  Lossless encoding good for sharp edges (not blur).

6 PNG (Portable Network Graphics)  Support truecolour, grayscale and palette-based (8-bit) colourmaps.  Uses DEFLATE algorithm:  As used in gzip  LZ77 algorithm with Huffman coding  Patent free  Combines this with prediction.  5 different simple prediction algorithms can be used, chosen on a per-scanline basis  E.g. sample-to-left, sample-above, average of s-t-l and s-a, etc.  DEFLATE only compresses the difference between the prediction and the actual value

7 LZ77  Unlike LZ78, uses the datastream as the dictionary.  Keeps a history window of the recently seen data. Compares current data with history.  A match is encoded as: Length of match Position in history  A non-match is encoded as a literal for ‘non-match’ followed by the actual sample value.

8 JPEG  JPEG is an image compression standard that was developed by the Joint Photographic Experts Group and formally accepted as an international standard in 1992.  JPEG is a lossy image compression, employs a transform coding method using DCT  An image is a function of i and j (or conventionally x and y) in the spatial domain. The 2D DCT is used as one step in JPEG in order to yield a frequency response which is a function F(u, v) in the spatial frequency domain, indexed by two integers u and v.

9 JPEG  Good for compressing photographic images  Gradual changes in colour  Not good for graphics  Sharp changes in colour  Compression ration of 10:1 achievable without visible loss.  Uses JFIF file format:  JPEG File Interchange Format  http://www.w3c.org/Graphics/JPEG/jfif3.pdf

10 JPEG  Convert RGB (24 bit) data to YUV  Divide each image up into 8x8 tiles  Convert to frequency space using a two-dimensional DCT  Quantise the frequency space, using more bits for the lower frequencies  Encode the quantised values using Run-length encoding and Huffman coding in a zig-zag manner

11 Block diagram for JPEG

12 DCT on image blocks  Each image is divided into 8 × 8 blocks. The 2D DCT is applied to each block image f(i, j), with output being the DCT coefficients F(u, v) for each block.  Using blocks, however, has the effect of isolating each block from its neighbouring context. This is why JPEG images look choppy (“blocky”) when a high compression ratio is specified by the user. Li & Drew12

13 Quantisation  F(u, v) represents a DCT coefficient, Q(u, v) is a “quantization matrix” entry, and represents the quantized DCT coefficients which JPEG will use in the succeeding entropy coding.  The quantization step is the main source for loss in JPEG compression.  The entries of Q(u, v) tend to have larger values towards the lower right corner. This aims to introduce more loss at the higher spatial frequencies.  The default Q(u, v) values obtained from psychophysical studies with the goal of maximizing the compression ratio while minimizing perceptual losses in JPEG images.

14 JPEG Example

15  Subtract 128 from each value to convert to signed  Then apply FDCT

16 DCT Basis Functions [what each coefficient corresponds to in the image]

17 The Luminance Quantisation Table The Chrominance Quantisation Table 16 11 10 16 24 40 51 61 1212 14 19 26 58 6055 1413 16 24 40 57 69 56 14 17 22 29 51 87 80 62 18 22 37 56 68 109 103 77 24 35 55 64 81 104 113 92 49 64 78 87 103 121 120 101 72 92 95 98 112 100 103 99 17 18 24 47 99 99 99 99 18 21 26 66 99 99 99 99 24 26 56 99 99 99 99 99 47 66 99 99 99 99 99 99 99 99 99 99

18

19

20  Huffman code what remains. Encoding is complete

21 JPEG Decoding  Decoding is simply the reverse of encoding.  Reverse of Huffman, RLE encodings.  Dequantise.  Apply inverse DCT (IDCT)  Add 128 to convert back to unsigned.

22 Comparison

23 200 202 189 188 189 175 175 175 200 203 198 188 189 182 178 175 203 200 200 195 200 187 185 175 200 200 200 200 197 187 187 187 200 205 200 200 195 188 187 175 200 200 200 200 200 190 187 175 205 200 199 200 191 187 187 175 210 200 200 200 188 185 187 186 f(i, j) 515 65 -12 4 1 2 -8 5 -16 3 2 0 0 -11 -2 3 -12 6 11 -1 3 0 1 -2 -8 3 -4 2 -2 -3 -5 -2 0 -2 7 -5 4 0 -1 -4 0 -3 -1 0 4 1 -1 0 3 -2 -3 3 3 -1 -1 3 -2 5 -2 4 -2 2 -3 0 F(u, v) An 8 x 8 block from only the luminance image JPEG image coding JPEG Example

24 JPEG decompression

25 Entropy Coding  The DC and AC coefficients finally undergo an entropy coding step to gain a possible further compression.  Run-length encoding on ACs and DPCM (Differential Pulse Code modulation) on DCs

26 Entropy coding on DC coefficients  Each DPCM coded DC coefficient is represented by (SIZE, AMPLITUDE), where SIZE indicates how many bits are needed for representing the coefficient, and AMPLITUDE contains the actual bits.  In the example, DC coefficients for the first 5 image blocks are 150, 5, −6, 3, −8 will be turned into (8, 10010110), (3, 101), (3, 001), (2, 11), (4, 0111).  SIZE is Huffman coded since smaller SIZEs occur much more often. AMPLITUDE is not Huffman coded, its value can change widely so Huffman coding has no appreciable benefit.

27 Entropy coding on AC coefficients  Run-Length Coding (RLC) on AC coefficients  RLC aims to turn the values into sets {#-zeros-to-skip, next non-zero value} / (RUNLENGTH, VALUE)  In Huffman coding, the VALUE is further represented by SIZE and AMPLITUTE  To make it most likely to hit a long run of zeros: a zig-zag scan is used to turn the 8×8 matrix into a 64-vector.  In an example, (32, 6, -1, -1, 0, -1, 0, 0, 0, -1, 0, 0, 1, 0, 0,…, 0)  Not considering the first DC component, you will have (0,6)(0,-1) (0,-1) (1,-1) (3,-1) (2,1) (15,0)

28 JPEG Compression Ratio  Compression ratio depends on how large the values in the quantisation matrix are.  10:1 achievable without noticeable loss.  100:1 achievable but artefacts are noticeable.

29 Edges in JPEG

30 JPEG Modes  Sequential Mode  Progressive Mode  Hierarchical Mode  Lossless mode

31 Sequential DCT-based  A subset of sequential mode is the Baseline Sequential Mode  8 bits/pel  Huffman coding: 2 DC and 2 AC tables  Extended  8 or 12 bits/pel  Huffman coding: 4 DC and 4 AC tables

32 Progressive DCT-based  Successive approximation: MSB first, LSB later  Spectral selection: Low-frequency first, high-frequency later

33 Hierarchical  Pyramid coding

34 A Glance at the JPEG Bitstream

35 Extension to Video  Motion JPEG (M-JPEG)  Compared to MPEG, M-JPEG has  No error propagation  Random access  Low complexity  But the compression ratio is low

36 JPEG 2000  Image Coding System (JTC 1.29.14, ISO 15444)  Goals  Low bit-rate compression  Lossless and lossy compression in a single bitstream  Large images  Single decompression architecture  Transmission in noisy environments  Computer generated imagery  Compound documents: bi-level and grey-scale

37 Applications  Low bandwidth dissemination of imagery  Medical imagery lossless/lossy compression  Pre-press imagery  Client/server applications (WWW)  Electronic photography  Photo and art digital libraries  Security  Facsimile  Laser print rendering  Scanner and digital copier memory buffers

38 Thanks.


Download ppt "Image Compression Lecture 5. Image Compression  GIF (Graphics Interchange Format)  PNG (Portable Network Graphics)  JPEG (Join Picture Expert Group)"

Similar presentations


Ads by Google