1 / 39

JPEG-Still Image Compression Standard

JPEG-Still Image Compression Standard. Introduction. JPEG is the first image compression standard for continuous tone still images Acronym for Joint Photographic Experts Group Officially referred to as

taurus
Download Presentation

JPEG-Still Image Compression Standard

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. JPEG-Still Image Compression Standard

  2. Introduction • JPEG is the first image compression standard for continuous tone still images • Acronym for Joint Photographic Experts Group • Officially referred to as • ISO/IEC IS (International Standard) 10918-1: Digital Compression and Coding of Continuous-tone Still Images • ITU-T Recommendation T.81 EA C473 Multimedia Computing

  3. Introduction [2] • Goal of the standard is to support a variety of applications for compression of continuous-tone still images of most image sizes in any color space in order to achieve compression performance at or near the state-of-the-art with user-adjustable compression ratios and with very good to excellent reconstructed quality EA C473 Multimedia Computing

  4. Introduction [3] • JPEG defines four modes of operation • Sequential Lossless Mode: Compress the image in a single scan and the decoded image is an exact replica of the original image. • Sequential DCT-based Mode: Compress the image in a single scan using DCT-based lossy compression technique. As a result, the decoded image is not an exact replica, but an approximation of the original image. • Progressive DCT-based Mode: Compress the image in multiple scans and also decompress the image in multiple scans with each successive scan producing a better-quality image. • Hierarchical Mode: Compress the image at multiple resolutions for display on different devices. EA C473 Multimedia Computing

  5. Introduction [4] • Modes 2, 3 and 4 are lossy • Mode 1 uses predictive coding with no quantization, hence lossless • Sequential DCT-based JPEG algorithm • In it’s simplest form called baseline JPEG algorithm, which is based on Huffman coding for entropy encoding • The other form is based on arithmetic coding for entropy encoding EA C473 Multimedia Computing

  6. The JPEG Lossless Coding Algorithm • Based on the principle of predictive coding, a simple method for spatial redundancy reduction • The difference between the actual pixel value and the predicted value is called the differential or the prediction error value & is entropy encoded using a variable-length encoding technique • Differential Pulse Code Modulation (DPCM) ?? EA C473 Multimedia Computing

  7. The JPEG Lossless Coding Algorithm [2] • The value of the pixel in location X is predicted using one or more of the 3-neighbors as shown in fig-(a) • Then the prediction error / prediction residual is coded using Huffman coding / Arithmetic Coding Fig (a) : 3-pixel neighborhood for pixel X Fig (b) : Encoder Diagram for Lossless mode EA C473 Multimedia Computing

  8. The JPEG Lossless Coding Algorithm [3] • Eight possible options for predictions • Option-0 is available for only JPEG compression in hierarchical mode • Options 1-3 are 1-Dimensional Predictors • Options 4-7 are 2-Dimensional Predictors • The Chosen Predictor function is available at the header of the compressed file Table-1 : Prediction Functions for Lossless JPEG EA C473 Multimedia Computing

  9. The JPEG Lossless Coding Algorithm [4] • Precision of the source image can be from 2 to 16 bits • The very first pixel is calculated as follows • 2 P-Pt-1 • P - Precision of the Source image • Pt – Point Transform Parameter (default value =0) • For the pixels in the first row, except first pixel, use option-1 for prediction • The first pixel of second row to the last row are predicted using option-2 • Every other pixels are predicted using the chosen prediction function EA C473 Multimedia Computing

  10. The JPEG Lossless Coding Algorithm [5] • Prediction residuals are calculated for modulo 216 • The Prediction residuals are first represented using (CATEGORY, MAGNITUDE) pair • CATEGORY • Category of error Value • Represents number of bits needed to represent the error • MAGNITUDE – Variable length integer (VL1) to represent the error • Only the CATEGORY value in each pair is Huffman coded, not the other one EA C473 Multimedia Computing

  11. The JPEG Lossless Coding Algorithm [6] • The 2-step pair formation process is as follows • Huffman code CATEGORY • Append it to CATEGORY number of bits to represent MAGNITUDE • If MAGNITUDE is positive, Append As Such (hence starts with 1) • If MAGNITUDE is negative, Append 1’s complement EA C473 Multimedia Computing

  12. For prediction residual 25 The pair becomes (5,25) Assuming the Huffman code for 5 is 011, the representation would be 01111001 –25 is represented as, 01100110 The JPEG Lossless Coding Algorithm [7] Table 2: Categories of Prediction Error Values EA C473 Multimedia Computing

  13. The JPEG Lossless Coding Algorithm [8] • So, Why not using Huffman code Just for the complete range of prediction residuals? • Huffman table with 216 entries for all the 216 possible symbols of prediction residuals !!! EA C473 Multimedia Computing

  14. Baseline JPEG Compression • Defined for continuous tone images with 1 to 4 components • Grayscale image consists only one component • Only 8 bits allowed for each component • Good compression relies on exploiting the inter-component correlation between the R, G, B components • Image in R,G B components is converted into Luminance-Chrominance components • Chrominance Components are further subsampled EA C473 Multimedia Computing

  15. Baseline JPEG Compression [2]COLOR SPACE CONVERSIONS • Converting from RGB to YCBCR • CB & CR can result in negative. To bring it to positive & representable in 8 bits EA C473 Multimedia Computing

  16. Baseline JPEG Compression [3]COLOR SPACE CONVERSIONS • The inverse color transformation is • Baseline JPEG supports the subsampling of CB & CR according to 4:2:2 or 4:4:4 color formats • Choosing 4:2:2 would be the first lossy step in the baseline compression • The color space conversion is not applicable for Grayscale images EA C473 Multimedia Computing

  17. Baseline JPEG Compression [4]SOURCE IMAGE DATA ARRANGEMENT • Dimension of each component Y, Cb and Cr could be different, due to subsampling • Each component is divided into 8 x 8 non overlapping blocks • In non interleaved scan, each data blocks are coded from left to right & top to bottom • In Interleaved scan, Minimum coded Unit (MCU) consists data blocks from all the three components EA C473 Multimedia Computing

  18. Baseline JPEG Compression [5]SOURCE IMAGE DATA ARRANGEMENT (a) YCbCr 4:4:4, (b) YCbCr 4:2:2, (c) YCbCr 4:2:0. EA C473 Multimedia Computing

  19. Baseline JPEG Compression [6]BASELINE COMPRESSION ALGORITHM EA C473 Multimedia Computing

  20. Baseline JPEG Compression [7]BASELINE COMPRESSION ALGORITHM • Level shift each pixel in the 8 x 8 block & convert it to signed integer (subtract 128) • Transform each pixel in the block into frequency domain via forward discrete cosine transform (FDCT) • The FDCT for 8 x 8 block is defined by • For u = 0  7 & v = 07 and EA C473 Multimedia Computing

  21. Transformed 8 × 8 block now consists of 64 DCT coefficients The first coefficient F(0, 0) is the DC component of the block DC components is the sum of all the 64 pixels in the input scaled by 1/8 Remaining 63 coefficients are AC components ACu,v = F(u, v) of the block Baseline JPEG Compression [8]CODING DCT COEFFICIENTS DC and AC components of the transformed block. • Transformation is done… next step in coding? QUANTIZATION EA C473 Multimedia Computing

  22. Baseline JPEG Compression [9]CODING DCT COEFFICIENTS • Each of the 64 coefficients are uniformly quantized • Quantization Matrix gives the 64 quantization step-size parameters for uniform quantization of the 64 DCT coefficients • Each element in the quantization matrix is an integer between 1 and 255. • Each DCT coefficient F(u, v) is divided by the corresponding quantizer step-size parameter Q(u, v) in the quantization matrix and rounded to the nearest integer as EA C473 Multimedia Computing

  23. Baseline JPEG Compression [10]CODING DCT COEFFICIENTS Luminance Quantization Matrix Chrominance Quantization Matrix EA C473 Multimedia Computing

  24. Baseline JPEG Compression [11]CODING DCT COEFFICIENTS • Quality of the reconstructed image and the achieved compression can be controlled by a user by selecting a quality factorQ_JPEG • Q_JPEG ranges between 1 to 100 • When Q_JPEG is used, the entries in tables in previous slide is scaled by the factor alpha (α), defined as • Q_JPEG is 100 for best reproduction • Quantization is done… Proceeding to coding the quantized values… EA C473 Multimedia Computing

  25. Baseline JPEG Compression [12]CODING DCT COEFFICIENTS • Quantized DC coefficient is encoded by differential encoding • DC coefficient DCi of the current block is subtracted by the DC coefficient DCi−1 of the previous block • The difference DIFF = DCi − DCi−1 is encoded • Encoding AC Components • Only the nonzero coefficients are encoded by an efficient manner such that the runs of zeros preceding a nonzero value are embedded into the encoding. • Irregular ordering of the AC coefficients is called zig-zag ordering EA C473 Multimedia Computing

  26. Zig Zag They are defined by partitioning the input data into segments of fixed size, and adding sequence of check bits to the data, where each check bit is the exclusive or of the bits in a single segment and of the previous check bit in the sequence.The code rate is high: J/(J + 1) where J is the number of bits per segment. Its worst-case ability to correct transmission errors is very limited: in the worst case it can only detect a single bit error and cannot correct any errors. However, it works better in the soft-decision model of decoding: its regular structure allows the task of finding a maximum-likelihood decoding or an a posteriori probability decoding to be performed in constant time per input bit. EA C473 Multimedia Computing

  27. Baseline JPEG Compression [13]CODING DCT COEFFICIENTS (a) Zig-zag ordering of AC coefficients (b) differential coding of DC EA C473 Multimedia Computing

  28. Baseline JPEG Compression [14]CODING DCT COEFFICIENTS • The zig-zag sequence of AC component broken into a number of runs of zeros ending in a nonzero coefficient • For 8-bit images in baseline JPEG, the DCT coefficients fall in the range [−1023, +1023] • Differential values of DC fall in the range [−2047, +2047] EA C473 Multimedia Computing

  29. Baseline JPEG Compression [15]CODING DCT COEFFICIENTS • This sequence of AC coefficients is mapped into an intermediate sequence of a combination of two symbols, symbol1, symbol2 • symbol1 is represented by a pair (RUNLENGTH, CATEGORY) • RUNLENGTH is the number of consecutive zeros preceding the nonzero AC coefficient being encoded • CATEGORY is the number of bits to represent the VLI code of this nonzero AC coefficient • symbol2 is a single piece of information designated (AMPLITUDE) that is encoded by the VLI code of the nonzero AC coefficient. EA C473 Multimedia Computing

  30. Baseline JPEG Compression [16]CODING DCT COEFFICIENTS • Assume the zigzag ordering results in the sequence as follows −6 6 −5 0 2 0 −1 0 0 0 0 0 −1 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 0 0 0 0 0 0 0 0 • This can be represented as (0, 3)(−6), (0, 3)(6), (0, 3)(−5), (1, 2)(2), (1, 1)(−1), (5, 1)(−1), (2, 1)(−1), (0, 1)(1), (0,0). EA C473 Multimedia Computing

  31. Baseline JPEG Compression [17]CODING DCT COEFFICIENTS • Two special symbols in encoding the zig-zag sequence of AC coefficients • (0,0)  referred to as EOB (end-of-block), to indicate that the remaining elements in the zig-zag block are zeros • (15, 0)referred to as ZRL (zero-run-length) to indicate a run of 16 zeros • Maximum length of a run of zeros allowed in baseline JPEG is 16 • Runs of more than 16 zeros should be broken into the number of runs of zeros of length 16. • Example : 57 zeros before a nonzero coefficient,−29. • Represented by (15, 0) (15, 0) (15, 0), (9, 5)(−29) EA C473 Multimedia Computing

  32. Baseline JPEG Compression [18]EXAMPLE A Sample 8 × 8 Data Block After Level Shifting EA C473 Multimedia Computing

  33. Baseline JPEG Compression [19]EXAMPLE Results of DCT Coefficients Quantized by Luminance Quantization Matrix DCT Coefficients of the Above 8 × 8 Block EA C473 Multimedia Computing

  34. Baseline JPEG Compression [20]EXAMPLE The ZigZag Sequence to be coded is −6 6 −5 0 2 0 −1 0 0 0 0 0 −1 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 0 0 0 0 0 0 0 0 And the code is (0, 3)(−6), (0, 3)(6), (0, 3)(−5), (1, 2)(2), (1, 1)(−1), (5, 1)(−1), (2, 1)(−1), (0, 1)(1), (0,0). (From Slide number 30) EA C473 Multimedia Computing

  35. Baseline JPEG Compression [21]EXAMPLE • Original Pepper image • Compressed with baseline JPEG using quality factor 75 (1.57 bit/pixel) • Compressed with baseline JPEG using quality factor 10 (0.24 bit/pixel) • Compressed with the new JPEG2000 standard using the same bit rate (0.24 bit/pixel). EA C473 Multimedia Computing

  36. Progressive DCT-Based Mode • The image is coded sequentially in multiple scan • Need to wait till the decoding is over to view the image in sequential mode • Transmit a coarser version of the image in the first scan and then progressively improve the reconstructed quality at the receiver by transmitting more compressed bits in successive scans • Complete the computation of DCT coefficients before the start of entropy coding • Perform selective encoding of the DCT coefficients & transmit • Two methods • spectral selection and successive approximation EA C473 Multimedia Computing

  37. Encode sets of DCT coefficients starting from lower frequencies and moving progressively to higher frequencies. For example Encode all the DC coefficients of all the 8 × 8 DCT blocks in the first scan Encode and transmit the first three AC coefficients of the zig-zag sequence of all the DCT blocks in the second scan Transmit the next 3 AC coefficients in the third scan, and so on The last three AC coefficients can be transmitted in the 21st scan Number of coefficients in each scan could be different and user selectable. Start encoding with certain number of most significant bits (say N1) of all the DCT coefficients of all the blocks and transmit in the first scan. In the second scan, the following N2 most significant bits are encoded and transmitted and so on. The scans continue until the least significant bit of all the coefficients is encoded. Usually the successive approximation offers better reconstructed quality in the earlier scans compared to the spectral selection method. Progressive DCT-Based Mode[2]PROGRESSIVE CODING SUCESSIVE APPROXIMATION EA C473 Multimedia Computing

  38. Progressive DCT-Based Mode [3] Progressive encoding: (a) spectral selection (b) successive approximation. EA C473 Multimedia Computing

  39. Hierarchical Mode • Progressive coding with increasing spatial resolution in a number of stages • Original image is filtered and down-sampled by required multiples of two for the target resolution and the lower-resolution image is encoded using any of the other three JPEG modes • The compressed lower-resolution image is then decoded and interpolated for upsampling by the same interpolation method that will be used at the decoder • Interpolated image is then subtracted from the next-higher-resolution image. The difference is then encoded by one of the other three JPEG modes (lossless or lossy). This procedure of the hierarchical encoding process is continued until it encodes all the resolutions. Hierarchical multiresolution encoding. EA C473 Multimedia Computing

More Related