0% found this document useful (0 votes)
12 views

Image Processing Fundamentals

JPEG is an image compression standard established in 1992 that uses Discrete Cosine Transform (DCT) for reducing interpixel redundancy and supports multiple encoding modes including sequential, progressive, lossless, and hierarchical. The compression process involves dividing images into 8x8 blocks, applying DCT, quantizing coefficients, and encoding them using variable-length coding. JPEG is also applicable to color images through the YUV color space, allowing for efficient processing and chrominance subsampling.

Uploaded by

fioona
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views

Image Processing Fundamentals

JPEG is an image compression standard established in 1992 that uses Discrete Cosine Transform (DCT) for reducing interpixel redundancy and supports multiple encoding modes including sequential, progressive, lossless, and hierarchical. The compression process involves dividing images into 8x8 blocks, applying DCT, quantizing coefficients, and encoding them using variable-length coding. JPEG is also applicable to color images through the YUV color space, allowing for efficient processing and chrominance subsampling.

Uploaded by

fioona
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 40

JPEG Compression

• JPEG is an image compression standard which was


accepted as an international standard in 1992.
• Developed by the Joint Photographic Expert Group of
the ISO/IEC for coding and compression of color/gray
scale images.
• Yields acceptable compression.
• A scheme for video compression based on JPEG
called Motion JPEG (MJPEG) exists
JPEG Compression (cont’d)

• JPEG uses DCT for handling interpixel redundancy.

• Modes of operation:
(1) Sequential DCT-based encoding
(2) Progressive DCT-based encoding
(3) Lossless encoding
(4) Hierarchical encoding
JPEG Compression
(Sequential DCT-based encoding)

Entropy
encoder

Entropy
decoder
JPEG Steps

1. Divide the image into 8x8 subimages;

For each subimage do:


2. Shift the gray-levels in the range [-128, 127]
- DCT requires range be centered around 0
3. Apply DCT (i.e., 64 coefficients)
1 DC coefficient: F(0,0)
63 AC coefficients: F(u,v)
Example

(i.e., non-centered
spectrum)
JPEG Steps

4. Quantize the coefficients (i.e., reduce the amplitude of


coefficients that do not contribute a lot).

Q(u,v): quantization table


Example

• Quantization Table Q[i][j]


Example (cont’d)

Quantization
JPEG Steps (cont’d)

5. Order the coefficients using zig-zag ordering


- Place non-zero coefficients first
- Create long runs of zeros (i.e., good for run-length encoding)
Example
JPEG Steps (cont’d)

6. Form intermediate symbol sequence and encode coefficients:

6.1 DC coefficients: predictive encoding

6.2 AC coefficients: variable length coding


Intermediate Coding

DC

symbol_1 (SIZE) symbol_2 (AMPLITUDE)


DC (6) (61) end of block

symbol_1 (RUN-LENGTH, SIZE) symbol_2 (AMPLITUDE)


AC (0,2) (-3)
SIZE: # bits for encoding amplitude
RUN-LENGTH: run of zeros
Entropy Encoding (e.g, variable length)
Effect of “Quality”

10 (8k bytes) 50 (21k bytes) 90 (58k bytes)

worst quality, best quality,


highest compression lowest compression
Write a Python script that reads an image, compresses it using JPEG
compression at different quality levels (e.g., 90%, 50%, and 10%), and
saves the compressed images to disk. Also, calculate the file size of each
compressed image and display the original and compressed images side by
side for comparison.

compress.py
Effect of “Quality” (cont’d)
Example 1: homogeneous 8 x 8 block
Example 1 (cont’d)

Quantized De-quantized
Example 1 (cont’d)

Reconstructed Error
Example 2: less homogeneous 8 x 8 block
Example 2 (cont’d)

Quantized De-quantized
Example 2 (cont’d)

Reconstructed – spatial Error


simple_jpeg_c.py
JPEG for Color Images
• Could apply JPEG on R/G/B components .

• It is more efficient to describe a color in terms of its


luminance and chrominance content separately, to enable
more efficient processing.
– YUV

• Chrominance can be subsampled due to human vision


insensitivity
JPEG for Color Images
• Luminance: Received brightness of the light
(proportional to the total energy in the visible band).

• Chrominance: Describe the perceived color tone of the


light (depends on the wavelength composition of light
– Hue: Specify the color tone (i.e., depends on the peak
wavelength of the light).
– Saturation: Describe how pure the color is (i.e., depends on
the spread or bandwidth of the light spectrum).
YUV Color Space

• YUV color space


– Y is the components of luminance
– Cb and Cr are the components of chrominance
– The values in the YUV coordinate are related to the values in
the RGB coordinate by:

 Y   0.299 0.587 0.114   R   0 


      
Cb
     0.169  0.334 0.500 G
    128 
 Cr   0.500  0.419  0.081   B   128 
      
JPEG for Color Images
B
G
R Chrominance
YVU color 8X8
Downsampling
Image coordinate FDCT
(4:2:2 or 4:2:0)

Huffman
zigzag
Encoder Quantizer
Encoding
Bit-stream
Differential Huffman
Quantization Coding Encoding
Table

Huffman
De-zigzag
Decoding
Bit-stream Dequantizer
De-DC Huffman
Quantization coding Decoding
Decoder Table
B
G
Chrominance R
8X8 YVU color
Upsampling Decoded
IDCT coordinate
(4:2:2 or 4:2:0) Image
JPEG Modes

• JPEG supports several different modes


– Sequential Mode
– Progressive Mode
– Hierarchical Mode
– Lossless Mode

• Sequential is the default mode


– Each image component is encoded in a single left-to-right,
top-to-bottom scan.
– This is the mode we have been describing.
Progressive JPEG
• The image is encoded in multiple scans, in order to
produce a quick, rough decoded image when
transmission time is long.

Sequential

Progressive
Progressive JPEG (cont’d)

• Send DCT coefficients in multiple scans:


(1) Progressive spectral selection algorithm
(2) Progressive successive approximation algorithm
(3) Hybrid progressive algorithm
Progressive JPEG (cont’d)

(1) Progressive spectral selection algorithm


– Group DCT coefficients into several spectral bands
– Send low-frequency DCT coefficients first
– Send higher-frequency DCT coefficients next
Progressive JPEG (cont’d)

(2) Progressive successive approximation algorithm


– Send all DCT coefficients but with lower precision.
– Refine DCT coefficients in later scans.
Progressive JPEG (cont’d)

(3) Hybrid progressive algorithm


– Combines spectral selection and successive approximation.
Results using spectral selection
Results using successive approximation
Example using successive approximation
after 0.9s after 1.6s

after 3.6s after 7.0s


Hierarchical JPEG

• Hierarchical mode encodes the image at several


different resolutions.

• Image is transmitted in multiple passes with increased


resolution at each pass.
Hierarchical JPEG (cont’d)

f4
N/4 x N/4

f2
N/2 x N/2

NxN
Hierarchical JPEG (cont’d)
Hierarchical JPEG (cont’d)

You might also like