Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 42

JPEG and JPEG200 Compression

Supervisor: Dr. Nasru Minallah


Submitted by: Nasir Ali Shah

Department of Computer System Engineering


University of Engineering and Technology, Peshawar

The JPEG standard


"JPEG" stands for Joint Photographic Experts Group, the name of the committee that
created the JPEG standard and also other still picture coding standards .
Defines how an image is compressed into a stream of bytes and decompressed back into
an image, but not the file format used to contain that stream .
Uses a lossy form of compression based on the discrete cosine transform (DCT).

have the following mods

Lossless mode, predictive coding


Sequential mode, DCT-based coding
Progressive mode, DCT-based coding
Hierarchical mode

JPEG ENCODER
Huffman
Table

AC
Color
components
(Y, Cb, or Cr)

88
FDCT

Zig-zag
reordering

Huffman
coding

Difference
Encoding

Huffman
coding

Quantizer

DC
Quantization
Table

Figure 1. JPEG encoder

Huffman
Table

JPEG
bit-stream

JPEG DECODER

Figure 2 . JPEG decoder

DCT : Discrete Cosine Transform


A Fourier-related transform similar to the discrete Fourier transform (DFT), but
using only real numbers.
Why DCT is more appropriate for image compression than DFT ?
The DCT can concentrate the energy of the transformed signal in low frequency,
whereas the DFT can not
For image compression, the DCT can reduce the blocking effect than the DFT

2-D DCT
As images are two dimensional so 2-D DCT is required.
Two series of 1-D transforms result in a 2-D transform as demonstrated in the figure
below
f(i, j)

1-D

1-D

Columnwise

Rowwise

8x8

8x8

8x8
F(u, v)

F(0,0) is called the DC component and the rest of F(i,j) are

called AC components

Quantization
Quantization is done to reduce number of bits per sample
F(u,v) = round(F(u,v)/q(u,v))
Quantization error is the main source of the Lossy Compression

1. Uniform Quantization:
1. q(u,v) is a constant.

2. Non-uniform Quantization -- Quantization Tables


. Eye is most sensitive to low frequencies (upper left corner in frequency matrix),
less sensitive to high frequencies (lower right corner)
. Custom quantization tables can be put in image/scan header.
. JPEG Standard defines two default quantization tables, one each for luminance and
chrominance.

Zig-Zag Scan
To group low frequency coefficients in top of vector and high frequency
coefficients at the bottom
Maps 8 x 8 matrix to a 1 x 64 vector

8x8

...
1x64

DPCM on DC Components
The DC component value in each 8x8 block is large and varies across
blocks, but is often close to that in the previous block.
Differential Pulse Code Modulation (DPCM): Encode the difference
between the current and previous 8x8 block. Remember, smaller number
-> fewer bits
45

1x64

54

1x64

48

32

.
.
.

1x64

1x64

36
1x64

45

1x64

1x64

-6

12
4

.
.
.

1x64

1x64
1x64

RLE on AC Components
The 1x64 vectors have a lot of zeros in them, more so towards the end of the
vector.
Higher up entries in the vector capture higher frequency (DCT) components which
tend to be capture less of the content.
Could have been as a result of using a quantization table

Encode a series of 0s as a (skip, value) pair, where skip is the number of zeros
and value is the next non-zero component.
Send (0,0) as end-of-block sentinel value.

...

0 0 0 0 0 1 1 0 0 0 0 0 0 0 02...
5,1

7,2

1x64

Entropy Coding: DC Components


DC components are differentially coded as (SIZE, Value)
The code for a Value is derived from the following table
SIZE

Value

Code

---

-1,1

0,1

-3, -2, 2,3

00,01,10,11

-7,, -4, 4,, 7

000,, 011, 100,111

-15,, -8, 8,, 15

0000,, 0111, 1000,,


1111

11

-2047,, -1024, 1024,


2047

Size and Value Table

Entropy Coding: AC Components


AC components (range 1023..1023) are coded as (S1,S2 pairs):
S1: (RunLength/SIZE)

RunLength: The length of the consecutive zero values [0..15]

SIZE: The number of bits needed to code the next nonzero AC components value. [0-A]

(0,0) is the End_Of_Block for the 8x8 block.

S1 is Huffman coded (see AC code table below)

S2: (Value)

Value: Is the value of the AC component.(refer to size_and_value table)

Run/
SIZE

Code
Length

0/0

0/1

Code

Run/
SIZE

Code
Length

1010

1/1

1100

00

1/2

11011

0/2

01

1/3

1111001

0/3

100

1/4

111110110

0/4

1011

1/5

11

11111110110

0/5

11010

1/6

16

1111111110000100

0/6

1111000

1/7

16

1111111110000101

0/7

11111000

1/8

16

1111111110000110

0/8

10

1111110110

1/9

16

1111111110000111

0/9

16

1111111110000010

1/A

16

1111111110001000

0/A

16

1111111110000011

15/A

More

Partial Huffman Table for AC Run/Size Pairs

Code

Such rows

JPEG Modes

Sequential Mode:
Each image is encoded in a single left-to-right, top-to-bottom scan.
The technique we have been discussing so far is an example of such a mode,
also referred to as the Baseline Sequential Mode.
It supports only 8-bit images as opposed to 12-bit images as described
before.

Lossless Mode:
Truly lossless
It is a predictive coding mechanism as opposed to the baseline mechanism which
is based on DCT and quantization(the source of the loss).

JPEG Modes
Progressive Mode: It allows a coarse version of an image to be
transmitted at a low rate, which is then progressively improved
over subsequent transmissions.

Spectral Selection : Send DC component and first few AC coefficients


first, then gradually some more ACs.

Hierarchical Mode: Used primarily to support multiple


resolutions of the same image which can be chosen from
depending on the targets capabilities.

Results

SNR

JPEG2000
JPEG 2000 (JP2) is an image compression standard and
coding system.
It was created by the Joint Photographic Experts Group
committee in 2000 with the intention of superseding their
original discrete cosine transform-based JPEG standard
(created in 1992) with a newly designed, wavelet-based
method.
JPEG 2000 code streams are regions of interest that offer
several mechanisms to support spatial random access or
region of interest access at varying degrees of granularity.
It is possible to store different parts of the same picture
using different quality.

Why another standard?

Low bit-rate compression: At low bit-rates (e.g. below


0.25bpp for highly detailed gray-level images) the distortion
in JPEG becomes unacceptable.
Lossless and lossy compression: Need for standard, which
provide lossless and lossy compression in one code stream.
Large images: JPEG doesn't compress images greater then
64x64K without tiling.
Single decompression architecture: JPEG has 44 modes,
many of them are application specific and not used by the
majority of the JPEG decoders.
Transmission in noisy environments: in JPEG quality suffers
dramatically, when bit errors are encountered.

Why another standard?(cont..)


Computer generated imaginary: JPEG is optimized for natural
images and performs badly on computer generated images.
Compound documents: JPEG is seldom used in the compression of
compound documents because of its poor performance on bi-level
(text) imagery.
More features: Support new features such as ROI and a more flexible
file format.
Avoid Complexity: JPEG2000 avoids excessive computational and
memory complexity.
Error resilience: Like JPEG 1992, JPEG 2000 is robust to bit errors
introduced by noisy communication channels, due to the coding of data
in relatively small independent blocks.

JPEG2000 Block Diagram

Source
Image
Data

Forward
Transform

Quantization

Entropy
Encoding

Compressed
Image Data

Store or
transmit
Reconstructe
d Image Data

Inverse
Transform

Dequantization

Entropy
decoding

Compressed
Image Data

JPEG2000 Encoder Block Diagram


Rate
Control

Image

Multi
component
transform

Discrete
Wavelet
Transform

Quantization

Tier-1
Encoder

ROI Mask

Figure. JPEG2000 encoder

Tier-2
Encoder

Coded
Stream

JPEG2000 Decoder Block Diagram

Coded
Stream

Tier-2
Decoder

Tier-1
Decoder

Deuantizatio
n

Figure. JPEG2000 decoder

Inverse
Wavelet
Transfor
m

inverse
Multi
component
transform

Reconstructe
d Image

JPEG2000 Encoder
Subbands

tile
DWT
Image
Component
code
block

BPC

Subband

Subband
Subband

Tile

Context
& Data

Code
block

Compressed
data
BAC

Code
block

Subband

Layer formation

Bit
stream

and data formatting

In some situations, an image may be quite large in comparison to the amount of


memory available to the codec. Consequently, it is not always feasible to code the
entire image as a single atomic unit.
To solve this problem, the codec allows an image to be broken into smaller pieces, each
of which is independently coded. More specifically, an image is partitioned into one or
more disjoint rectangular regions called tiles. Tiles have a nominal size of XTsiz YTsiz,
but those bordering on the edges of the image area may have a size which differs from
the nominal size. The tiles are numbered in raster scan order (starting at zero).

Multi-Component Transform
Part 1 of encoder allows color transformation on first
three components
Irreversible Color Transform (ICT)
The ICT is nothing more than the classic RGB-to-YCrCb color space
transform.

Reversible Color Transform (RCT)


The RCT is simply a reversible integer-to-integer approximation to the
ICT.

Wavelet Transform
Floating point 9/7 wavelet filter for lossy compression
Best performance at low bit rate
High implementation complexity, especially for hardware
Integer 5/3 wavelet filter for lossless coding
Integer arithmetic, low implementation complexity
Each row and column is filtered with a high pass and low pass

filter, followed by down-sampling by 2 (to keep the sample


rate).
The tile is then divided to sub-bands. All info (index,
position, precincts, etc.), regarding the single tile, is put
together in a contiguous stream of data called a packet.

Wavelet Transform
In JPEG2000 multiple stages

of the DWT are performed.


JPEG2000 supports from 0 to
32 stages. For natural
images, usually between 4
to 8 stages are used.

Quantization
The wavelet coefficients are quantized using a uniform
quantizer with deadzone. For each subband b, a
basic
quantizer step size b is used to quantize all
the coefficients in that subband according to:
y

q sign( y )

No quantization in lossless mode.

Coefficient Bit Modeling


Wavelet coefficients are associated with different subbands arising from the 2D separable transform applied.
These coefficients are then arranged into rectangular
blocks within each sub-band, called code-blocks.

Figure: division of sub-bands into code-blocks

Coefficient Bit Modeling (cont'd)

Significance Pass (a/(a+r))


Refinement Pass (a/(a+r))
Clean Up Pass (a)

For each bit-plane in a code-block, a


special code-block scan pattern is
used for each of three coding passes.

Example of scan pattern for a 10x5 code block

Code-blocks are then coded a bitplane at a time starting from the Most
Significant Bit-Plane to the Least
Significant Bit-Plane.
For each bit plane, there are 3 coding
passes, similar to those in EZW or
SPIHT:

3 Passes Scanning
1. Significance Propagation Pass
. If a bit is insignificant (=0) but at least one of it's eight
neighbors is significant (=1), then it is encoded.
. If the bit at the same time is a 1, it's significance flag is
set to 1 and the sign of the symbol is encoded.
2. Magnitude Refinement Pass:
.Samples which are significant and were not coded in the
significance propagation pass.
3. Clean-up Pass:
.It codes all bits which were passed over by the previous
two coding passes (insignificant bits). It is the first pass
for MSB plane.

Quality layers organization


The resulting bit streams for each code-block are
organized into quality layers. A quality layer is a
collection of some
Consecutive bit-plane coding passes from each tile.
Each code-block can contribute an arbitrary number of
bit-plane coding passes to a layer, but not all coding
passes must be assigned to a quality layer. Every
additional layer increases the image quality.

Rate Control
Rate control is the process by which the code-stream is
altered so that a target bit rate can be reached.
Once the entire image has been compressed, a postprocessing operation passes over all the compressed
blocks and determines the extent to which each block's
embedded bit stream should be truncated in order to
achieve the target bit rate.
The ideal truncation strategy is one that minimize
distortion while still reaching the target bit-rate.
The code-blocks are compressed independently, so any
bit stream truncation policy can be used.

Region-of-interest (ROI)
A ROI is a part of an image that is encoded with higher
quality than the rest of the image (the background). The
encoding is done in such a way that the information
associated with the ROI precedes the information
associated with the background.

Original Image with ROI Defined

Decoded Image with ROI Intact

Scalability and bit-stream parsing


2 important modes of
scalability:
Resolution/Spatial
Quality (SNR)

Bit-stream parsing
A combination of spatial and
quality scalability.
It is possible to progress by
spatial scalability to a given
(resolution) level and then
change the
progression by
SNR at a higher level

Resolution scalability

Resolution scalability

Resolution scalability

Resolution scalability

Quality scalability

JPEG (6.21 KB)

Original (979 KB)

JPEG 2000 (1.83 KB)

Examples

Thank You

You might also like