You are on page 1of 46

IMAGE COMPRESSION

Information Technology
FT UGM
Agendas
• Image Compression
– Lossless coding
– Lossy image coding
– Image Compression Standards
• JPEG, JPEG 2000

Teknik Multimedia 2
Image Compression
• Objective:
– to reduce the data size
• Approach:
– to reduce redundancy
• Uncompressed multimedia objects are large.
Objects kept in compressed form
– Save storage space
– Save retrieval bandwidth
– Decompressed and retrieved in parallel
– Save processing time

Teknik Multimedia 3
Introduction to Compression
Standards
• Lossless compression
• Lossy compression
• Using standard saves complexity in
handling heterogeneous methods

Teknik Multimedia 4
Multimedia Compression Standards
Short name Official name Standard Groups Compression Ratios
JPEG Digital compression Joint Photographic 15:1 to 50:1 (full
2000 and coding of Experts Group color still-frame
continuous-tone still applications)
images
H.261 Video Specialist Group on 100:1 to 2000:1
px64 encoder/decoder for Coding for Visual (video-based tele-
audio-visual Telephony communications)
services at px64
Kbps
MPEG, Coding of moving Moving Pictures 50:1 to 2000:1
MPEG2, pictures and Experts Group (motion-intensive
associated audio applications)
MPEG4

Teknik Multimedia 5
Uncompressed MM Object Size
Data Type Object size in order of magnitude
Binary number bits
Text Bytes
Graphics KiloBytes
Greyscale image 100 KiloBytes
Colour image MegaBytes
Voice KB/s
CD quality audio 100 KB/s
Animation graphic MB
Video 100 MB/s

Teknik Multimedia 6
Compression model

model

1011010101
encoder decoder
01010101…

Teknik Multimedia 7
Compression Techniques
• Lossless compression
– Used on programs, DB records, critical
information
• Lossy compression
– Used on images, audio, video, non-critical data
• Hybrid compression
– JPEG, JPEG-LS, JPEG 2000, MPEG-1, MPEG-2

Teknik Multimedia 8
Lossless Compression
• Encode into a form to represent the original
in fewer bits
• The original representation can be perfectly
recovered
• Compression ratios:
– Text 2:1
– Bilevel images 15:1
– Facsimile transmission 50:1

Teknik Multimedia 9
Lossless Compression

Lossless
(Noiseless)

Huffman Arithmetic
Lempel Ziv Run length
coding decomposition

Teknik Multimedia 10
Lossy Compression
• Can be decoded into a representation that
humans find similar to the original
• Compression ratios:
– JPEG image 15:1
– H.261 or px64 100:1 to 2000:1
– MPEG video 200:1

Teknik Multimedia 11
Lossy Compression
Lossy

Frequency Importance
Predictive Hybrid
oriented oriented

Motion
Transform Filtering Subsamping JPEG MPEG
compensation

Bit JPEG
Subband Quantization
allocation 2000

Teknik Multimedia 12
JPEG: Modes of Operations
• Sequential Encoding
– Each image component is encoded in a single left-to-right, top to
bottom scan
• Progressive Encoding
– The image is encoded in multiple scans for applications in which
transmission time is long
• Lossless Encoding
– The image is encoded to guarantee exact recovery of every source
image sample value
– Low compression ratio
• Hierarchical Encoding (also called Layered encoding)
– The image is encoded at multiple resolutions
– Lower resolution versions may be accessed without first having to
decompress the image at its full resolution

Teknik Multimedia 13
JPEG 2000
• Hybrid compression supports both lossless and lossy
methods
• Implements compression of low bit rate
• designed for images over low bandwidth transmission
• Each image is divided into components
• Each component is sub-divided into tiles (<=4096 pixels)
• Performs color transform, wavelet/subband coding,
quantization, progression, and rate control

Source: Michael Adams, “The JPEG-2000 Still Image Compression Standard”

Teknik Multimedia 14
JPEG 2000 Encoder Structure

Forward Forward
Preprocessing Intercomponent Intracomponent
Transform Transform
Original
Image

Tier-1 Tier-2
Quantization
Encoder Encoder

Coded
Image
Rate
control
Source: Michael Adams, “The JPEG-2000 Still Image Compression Standard”

Teknik Multimedia 15
Image Components

• 1 to 255 image components (colour or spectral


bands or channels)
CN

C2
C1

Source image with y


Multiple components

Teknik Multimedia 16
Image to Components - Example

RGB image

Red component Green component Blue component

Teknik Multimedia 17
Preprocessing
• Ensure that the nominal dynamic range is
approximately centre about zero.
P-1
• Subtract a bias of 2 to move the samples to
P-1 P-1
the range [-2 , 2 –1]

Teknik Multimedia 18
Intercomponent Transform
• 2 transforms are defined:
– Irreversible Color Transform (ICT): Lossless
compression using real-to-real transform
– Reversible Color Transform (RCT): Lossy compression
using integer-to-integer transform
• ICT: RGB to YCbCr transform
V0 ( x, y )  0.299 0.587 0.114  U 0 ( x, y )
V ( x, y )    0.16875  0.33126 0.5  U1 ( x, y ) 
 1  
V2 ( x, y )  0.5  0.41869  0.08131  U 2 ( x, y )

Teknik Multimedia 19
Intercomponent Transform
• RCT: Reversible integer-to-integer
approximation of the ICT

1 
V0 ( x, y )   U 0 ( x, y )  2U 1 ( x, y )  U 2 ( x, y ) 
4 
V1 ( x, y)  U 2 ( x, y)  U1 ( x, y)

V2 ( x, y)  U 0 ( x, y)  U1 ( x, y)

Teknik Multimedia 20
IntraComponent Transform
LLR-1
2D Wavelet/subband coding LL0 …
• A subband image of ½ HLR-2
resolution is formed by …
using the mean of the HLR-1
sample values in the higher LHR-2 HHR-2
resolution.
• Applied in both horizontal
and vertical directions to
form 4 subbands
• This is performed LHR-1 HHR-1
recursively on the LL
subband of the previous
level.

Teknik Multimedia 21
Quantization
• Mathematically, the quantization process is

V ( x, y)  U ( x, y ) /  sgn U ( x, y)

– where Δ is the quantization step size.


• The dequantization is

U ( x, y)  V ( x, y)  r sgn V ( x, y)
– Where r=0.5 is the bias parameter

Teknik Multimedia 22
Tier-1 Coding
• Code blocks of rectangular
tiles with size  4096
pixels per tile (e.g. 64x64
block) … 4 samples
• 3 passes per bit plane to
get the sample values in
the scan order …
– Significance bit (only the
most significant bit)
– Refinement bits
– Cleanup: other bits (least
significant bits)
• Scan height: 4 samples

Teknik Multimedia 23
Multiple Passes Encoding
• For images transmitted at low transmission rate
• Resolution increases progressively as more data
are received
E.g. All coefficients are transmitted with increasing
accuracy after each pass.
• 1st pass: Most significant bits (coarse)
– E.g. bits ’01’ from ‘01100100’
• 2nd pass: Medium significant bits (medium)
– E.g. bits ’100’ from ‘01100100’
• 3rd pass: Least significant bits (fine)
– E.g. bits ’100’ from ‘01100100’

Teknik Multimedia 24
Tier-2 Coding
• Build packets with passes
• Packet is comprised of 2 parts: header, body
• Coded data for each tile is organized into L layers:
0 to L-1.
• 5 sorting orders of packets called progressions are
specified:
– Layer-resolution-component-position
– Resolution-layer-component-position
– Resolution-position-component-layer
– Position-component-resolution-layer
– Component-position-resolution-layer

Teknik Multimedia 25
Progressive Encoding
• Progressive encoding
– Increases resolution when more data are received
– Suitable for low bandwidth transmission links
• E.g.

Non-progressive Progressive
Teknik Multimedia 26
Rate Control
Bit Rate can be controlled using
• Choice of quantizer step sizes
• Select subset of coding passes to include

Teknik Multimedia 27
Region Of Interest
Region of Interest (ROI) coding
• Different regions of an image is coded with
differing fidelity
• While synthesized from its transformed
coefficients in the decompression process,
each coefficient contributes only to a specific
region.
• Identify the coefficient contributing to ROI
• Encode some or all of these coefficients with
greater precision than the others

Teknik Multimedia 28
Region of Interest

Region of Interest

Teknik Multimedia 29
Code Stream Structure
• A code stream is a Main header
Start of Codestream
sequence of marker
Image and tile size
segments
Other marker segments
• Each marker segment
Tile-Part Header
has 3 fields: type,
Start of Tile
length, and parameter
Other marker segments
• The code stream has Start of Data
one main header, a
Tile-Part Body
number of tile-part Packet data
header body pairs, …
and one main trailer Main Trailer
End of Codestream

Teknik Multimedia 30
JP2 File Format
• A JP2 file contains a JPEG-2000 signature box
number of boxes
File type box
• Each box has
JP2 header box
– LBox(32 bits): box length
– TBox(32 bits): box type Image header box

– XLBox(64 bits): true length Color spec box


of box when Lbox is 1. …
– DBox(variable): box data
• The valid file structure is Contiguous code stream box
shown …

Teknik Multimedia 31
JPEG 2000 Decompression
• To reverse the process of JPEG 2000 Compression
• The compressed code stream is fed through tier-2
and tier-1 decoders
• The decoded values goes through dequantizer
• The dequantized values go through Inverse
Intracomponet and Intercomponent transforms
• The postprocessing restores the pixel values
• The component is reconstructed from the pixel tiles
• The image is reconstructed from the components

Teknik Multimedia 32
JPEG 2000 Decoder Structure

Tier-2 Tier-1
Dequantization
Decoder Decoder

Coded
Image

Inverse Inverse
Intracomponent Intercomponent Postprocessing
Transform Transform
Reconstructed
Image

Teknik Multimedia 33
Summary to JPEG 2000
• JPEG 2000 compression standard
– Is a hybrid compression method for continuous tone
images compressions
– Implements compression for low bit rate (50:1)
– Compresses each 4096 pixels tile using 2D wavelet,
quantization, multiple passes, progression, rate-control,
and region-of-interest.

Teknik Multimedia 34
JPEG Sequential Encoding Compression

• An image is divided into components


• Each component is divided into blocks with 8x8
pixels in each block
• Each block goes through
– Forward Discrete Cosine Transform (FDCT)
– The transformed values goes through quantizer
– The quantized values are fed through an entropy
encoder
• The resultant code stream is the compressed
image

Teknik Multimedia 35
Component to Blocks

• Each component is single


divided into blocks Component
of 8 pixels wide by 8
pixels tall
• The block may
cover areas beyond
Single
the image boundary 8
8x8 block
at the rightmost
and bottom blocks
8

Teknik Multimedia 36
DCT-based Encoder

Forward
Discrete Entropy
Quantizer
Cosine Encoder
Transform
compressed
uncompressed
block
block

Table Table
Specification Specification

Teknik Multimedia 37
FDCT output
• After preprocessing, 8x8 source block is
transformed to a 64-point discrete signal which is
a function of two spatial dimension x and y
(spatial frequencies, or DCT coefficients)
• Input [-255,255]  outputs [-2048, 2048]
• One DC coefficient: F(0,0)
• 63 AC coefficients: F(0,1), F(0,2), …,F(8,8)
• Typical 8x8 block, most of the spatial frequencies
have 0 or near zero amplitude and need not be
encoded after quantization; foundation for
compression

Teknik Multimedia 38
DCT Coefficients Example

8x8 block of image data DCT coefficients after transformation

232 233 234 228 222 217 216 217 1779 19.3 4.0 -5.2 0.6 -0.6 0.1 -0.6
229 229 227 224 221 217 215 216 -3.0 15.7 -2.4 0.4 0.2 -0.1 0.4 0.8
226 226 223 221 220 217 216 216 14.7 -0.1 -0.5 -4.2 -0.5 -0.9 -0.2 0.6
226 223 222 221 219 219 217 217 -0.8 3.5 -0.2 -0.8 -0.2 0.8 0.2 -0.3
225 223 222 221 219 219 219 219 5.6 -0.3 0.1 -0.9 -0.3 0.9 0.8 0.5
223 223 221 221 218 219 220 221 -0.2 0.7 -0.6 0.0 0.0 -0.1 0.3 -0.1
222 224 223 223 222 222 223 226 0.0 -0.1 0.5 -0.6 -0.5 0.2 -0.4 0.1
222 225 226 225 224 225 229 233 0.7 0.1 -0.2 -0.2 -0.1 -0.4 -0.3 0.4

Teknik Multimedia 39
JPEG Decompression
• To reverse the process of JPEG Compression
• The entropy and quantization tables are extracted from the
compressed code stream
• The input compressed code stream
– The code stream is fed through an entropy decoder
– The decoded values goes through dequantizer
– The dequantized values go through Inverse Discrete Cosine
Transform (IDCT)
• The component is reconstructed from the 8x8 blocks.
• The image is reconstructed from the components.

Teknik Multimedia 40
DCT-based Decoder

Entropy Inverse
Dequantizer
Decoder DCT

compressed
image Reconstructed
block image
block
Table Table
Specification Specification

Teknik Multimedia 41
Quantization in JPEG
• The 64 DCT coefficients are uniformly quantized
in conjunction to a Quantization Table with 64
elements
• Quantization Table specified by the application or
user. Each element can be any integer value from
1 to 255, which specifies the step size of the
quantizer for its corresponding DCT coefficient.
• Quantization discards information which is not
visually significant. It is the principal source of
lossiness in DCT-based encoding

Teknik Multimedia 42
Quantization Formulae
• Quantization:
 F (u, v) 
F (u, v)  Round 
Q

 Q (u , v )  from
• Dequantization: Quantization Table

F (u, v)  F Q (u, v) * Q(u, v)


• Psycho-visual experiments to determine
perceptual thresholds  a set of default
Quantization Tables for CCIR-601 images and
displays

Teknik Multimedia 43
JPEG Picture Quality
For colour images with moderately complex scenes
• 0.25 – 0.5 bits/pixel Moderate to Good quality
• 0.5 – 0.75 bits/pixel Good to Very good quality
• 0.75 – 1.5 bits/pixel Excellent quality
• 1.5 – 2.0 bits/pixel Indistinguishable from the
original

Teknik Multimedia 44
JPEG Sequential Encoding Summary
• An image is divided into components
• Each component is divided into blocks with 8x8
pixels in each block
• Each block goes through
– Forward Discrete Cosine Transform (FDCT)
– The transformed values goes through quantizer
– The quantized values are fed through an entropy
encoder
• The resultant code stream is the compressed
image

Teknik Multimedia 45
QUESTIONS?

Teknik Multimedia 46

You might also like