國立臺灣大學電機資訊學院
College of Electrical Engineering and Computer Science
National Taiwan University
Time-Frequency Analysis and Wavelet Transform Tutorial
Tier 1 and Tier 2 Encoding Techniques for JPEG 2000
林沛諄
Pei-Chun Lin
課程指導教授:丁建均 博士
Advisor: Jian-Jiun Ding, Ph.D.
中華民國 102 年 1 月
January , 2012
CONTENTS
CONTENTS .......................................................................................................................i
LIST OF FIGURES .......................................................................................................... ii
LIST OF TABLES ........................................................................................................... iii
Chapter 1
Introduction ..................................................................................................1
1.1 JPEG(Joint Photographic Experts Group) ...............................................1
1.2 JPEG 2000 ..........................................................................................................2
Chapter 2
JPEG 2000 architecture ................................................................................4
Chapter 3
EBCOT - Tier 1 ............................................................................................ 6
Bibliography .................................................................................................................... 19
i
LIST OF FIGURES
Fig. 1-1 The color pixel sampling example[2]. .................................................................2
Fig. 1-2 DCT-Based Encoder Processing Steps.[1] ........................................................... 2
Fig. 1-3 JPEG 2000 architecture........................................................................................ 3
Fig. 2-1 The three stage 2D DWT[3]. ...............................................................................4
Fig. 2-2 The image after twice 2D DWT composition. ..................................................... 5
Fig. 3-1 Code-block part[4]. .............................................................................................. 6
Fig. 3-2 The bit-plane at n=5[4]. ....................................................................................... 7
Fig. 3-3 Fraction bit-planes coding. ..................................................................................8
Fig. 3-4 The EBCOT code-block flow. .............................................................................9
Fig. 3-5 The current coding bit and its eight neighbors[5]. .............................................10
ii
LIST OF TABLES
Table- 3-1 Context assignment table for zero coding. ..................................................... 11
iii
Chapter 1
Introduction
As the utility rate of the computer growing, lots of important data are transferred to
image data and save in the computer. Due to the increasing traffic caused by multimedia
information and digitized form of representation of images. To compress these large
data. There are some format to save the image such as JPEG(Joint Photographic
Experts Group), GIF(Graphics Interchange Format), BMP(Business process
management)......etc.
1.1
JPEG(Joint Photographic Experts Group)
JPEG is the abbreviation of Joint Photographic Experts Group, it is also a
compress algorithm which proposed by this group. The image usually save as the file
format named JPEG File Interchange Format, and we usually called it as JPEG.
For typical image unit streams is use RGB color model. In the image processing,
we use another color model called YCbCr. Eqn.( 1.1 ) is the transfer function of the two
color model, where Y is the luminance and Cb and Cr are the chrominance.
( 1.1 )
After change the model to YCbCr, the following is for pixel sampling by 4:2:0. The
JPEG compression system is based on the Discrete Cosine Transform (DCT). Fig. 1-2
shows the key processing steps which are the heart of the DCT-based modes of
operation. For a image data, we will divide the image into 8×8 sample blocks.
1
Fig. 1-1 The color pixel sampling example[2].
Fig. 1-2 DCT-Based Encoder Processing Steps.[1]
For people's eyes, the best compression ratio that people won't think the image has
lossless is 8 for gray level image and 16 for color image.
1.2
JPEG 2000
Due to increasing demand for amazing graphic design in low-band applications.
We need better image compression system. After applying Discrete Wavelet Transform
(DWT) for image compression, we get better compression ratio. JPEG 2000 is also
create by the Joint Photographic Experts Group, which based on the JPEG architecture,
2
and then added following important factors to JPEG's standards.
It added wavelet transform algorithm (wavelet-based algorithm) to the existing
JPEG compression algorithm, with this algorithm people won't figure out the difference
in the compression ratio of 25:1 at gray level and 50:1 at color image. And at the
compression ratio of 100:1, the image is hard to identify when using JPEG algorithm,
but still can be identify by using JPEG 2000 compression algorithm.
Comparative to the JPEG format, the JPEG 2000 compression cam provide a better
performance and without loss. The size of JPEG 2000 is about half of the original image
without lossless. So lots of technology and physiology which needs high image quality
are starting using JPEG 2000.
Fig. 1-3 JPEG 2000 architecture.
And in this tutorial we will focus on the Tier 1 and Tier 2 Encoding Techniques for
JPEG 2000.
3
Chapter 2
JPEG 2000 architecture
Fig. 2-1 The three stage 2D DWT[3].
In Fig. 1-3 shows, the original image will go through the Forward Multicomponect
Transformation. The Forward Multicomponect Transformation will let the image
transfer from RGB to YCbCr, and entered into the 2D wavelet transform. The 2D
discrete wavelet transform will let the original image into LL, HL, LH and LL four parts.
4
The LL sub-band represents a 2:1 sub-sampled in both vertical and horizontal directions.
The other sub-bands represent a down-sampled residual version of the original image,
and the LL can again be decomposed into four parts.
Fig. 2-2 The image after twice 2D DWT composition.
Wavelet transform can be followed by a quantization step in lossy compression.
Quantization can reduces the bit depth of Wavelete coefficients at the expenses of
precision. Two different quantization procedures are allowed by the standard: scalar
quantization, and Trellis-coded quantization. Scalar quantization consists of a simple
truncation of less significant bits, often obtained by right shifting wavelet coefficients’
magnitude.
And the main core of JPEG 2000 is the coding engine, Embedded Block Coding
with Optimized Truncation (EBCOT). In general, the EBCOT contains two parts,
Tier-1 and Tier-2. Tier-1 is a complete arithmetic encoder, which divides quantized
sub-bands composed of wavelet coefficients into code blocks, and encodes code blocks
into independent embedded bit-streams. There are three parts in the Tier-1 encode,
which consists of bit-plane conversion, fractional bit-plane coding, and binary
arithmetic coding.
5
Chapter 3
EBCOT - Tier-1
Wavelet sub-bands are partitioned into small code- blocks (to not be confused with
tiles) which in turn are coded by bit-planes. The EBCOT coder is a bit-plane coder. ON
each bit-plane, there are three coding passes: Significance Propagation, Magnitude
Refinement and Cleanup pass. And there are four coding primitives are used : the
Run-Length(RL) primitive, Zero Coding(ZC)primitive, the Magnitude Refinement
(MR) and the Sign Coding(SC) primitive.
Bit-plane reduced the data required to describe a series of sample values in binary
form. The first step in the scheme is to consider groups of M consecutive samples. Each
group contains M×N bits if it takes N bits to describe each sample. The next step is to
consider each group to be composed of N sequences of M like-order bits. That is, the
Nth-order bit of each sample is taken to form an M-bit sequence, called a bit plane.
Fig. 3-1 Code-block part[4].
6
The EBCOT for the JPEG 2000 is also a block coder, which codes the wavelet
coefficients by blocks. The blocks we use are 64×64 in general. Fig. 3-1 shows a code
block example. This block is in a LH sub-band, which represent wavelet coefficients
values after quantization. These coefficients are scan with the column wise order by
columns of four coefficients and strip by strip. The first line of coefficients belongs to
the previous strip. The last one belongs to the next strip. In Fig. 3-1 the biggest
coefficient is 61 which at the (4,7). So there are 6 bit-planes in the code-block (26=64).
In this case, there are numbered from 0 to 5; the MSB(most significant bit) is 5. Fig.
3-2 shows the bit-plane at n = 5.
Fig. 3-2 The bit-plane at n=5[4].
The EBCOT algorithm starts coding process when the first time to met the
non-zero bit-plane, and will skips the all-zero bit-plane.
7
Fractional Bit-plane coding
The Fractional Bit-plane coding has three coding plane, Significance Propagation
Pass(Pass 1), Magnitude Refinement Pass(Pass 2) and Clean Up Pass (Pass 3).
The EBCOT algorithm is to put the coefficients in a code block. And encoded from
most significant bit (MSB) to the least significant bit (LSB) in the one of three coding
passes.
Fig. 3-3 Fraction bit-planes coding.
During the coding process, every bit-plane will scan by these three passes. Every
bit on the bit-plane will be coded by one of the three passes. If the bit had been coded
by one pass, the other two passes will skip the bit. Every time we scan the current bit,
we will go to check its 8 neighborhood. If the bit is significant, we will set its
coefficient to 1, and if it is insignificant we will set its coefficient to 0
8
Fig. 3-4 The EBCOT code-block flow.
Three types of the coding pass
Significance Propagation Pass
Significance Propagation Pass focus on the coefficients-bits that are insignificant
but have at least one of eight neighbors being significant. The most proper coefficients
becoming significant are searched and encoded in Significance Propagation Pass. The
zero coding and sign coding operations are used in this pass.
9
Fig. 3-5 The current coding bit and its eight neighbors[5].
Magnitude Refinement Pass
During the Magnitude Refinement Pass, the magnitude bit of a coefficient that are
not coded by the Significance Propagation Pass. The coefficient bits have been
significant in the last bit-planes. The magnitude refinement coding is used in this pass.
Clean Up Pass
This pass is the most important pass. When the bit had not coded by the
Significance Propagation Pass and Magnitude Refinement Pass. This pass will coded
those bits. The run-length coding、zero coding and sign-coding are used at different
case.
Four types of the coding operator
The EBCOT context modeling assigns the coefficients-bits a context with different
coding operations depending on the pass type and the significant state of eight
neighbor-bits. As Fig. 3-5 The current coding bit and its eight neighbors[5].Fig. 3-5
10
shows, we assign numbers to the eight neighbor-bits.
Zero Coding(ZC)
Zero coding is used in the Significance Propagation Pass and the Clean Up pass.
There are 9 different contexts which describe nine different cases with its neighbors.
Note that if the current coding coefficient-bit lies beyond the boundary of code block,
its neighbors are taken as insignificant for context assignment.
As the Table- 3-1 shows, it is a table with the different context label. LL, LH , HL
and HH are the sub-bands which comes from the DWT.
is the sum of significant
neighbors in horizontal(number 4 and 5 in Fig. 3-5).
is the sum of significant
neighbors in vertical(number 2 and 7 in Fig. 3-5).
is the sum of significant
neighbors in diagonal directions(number 1, 3, 6 and 8 in Fig. 3-5). And the x means
don't care.
Table- 3-1 Context assignment table for zero coding[5].
11
Sign Coding(SC)
Sign coding is used in the Significance Propagation Pass and the Clean Up pass. If
a coefficient turns from insignificant to significant, the sign coding operator will
classify it into 5 different context labels from 10 to 13. The decision of contexts in SC is
depend upon the sign and the significance of the horizontal and vertical neighbors as
shows in Table- 3-2 and Table- 3-3.
Table- 3-2 Sign contribution for sign coding[5].
Table- 3-3 The Context Label table for the sign coding[5].
12
At the Table- 3-3, the XOR bit is used to generate the output of the EBCOT context
modeling, output = sign bit ⊕ XOR bit.
Run-Length Coding (RLC)
The operator is used for the Clean Up pass. the run-length coding is enable when
the following conditions are true. The first condition is the four consecutive coefficients
in the same stripe are insignificant. The second condition is The neighbors for the
consecutive four coefficients must be insignificant, too. That means the start of four
continuous bit is 4n+1. Use run-length coding replace of zero coding can efficiently to
reduce the output of the context label.
Fig. 3-6 Current coding bits and their neighbors for RLC operation.
Magnitude Refinement (MR)
The magnitude refinement operator is used for magnitude refinement pass. While
the scanned bit is already significant by the previous bit-plane. And it will check the
significant state for 8 neighbors. There are three context label as Table- 3-4 shows.
13
Table- 3-4 Context assignment table for magnitude refinement.
14
Chapter 4
EBCOT - Tier-2
Tier-2 is following with the Tier-1 encoding system. It is also the finally process of
the JPEG 2000. Tier-2 is packaged the information from Tier-1 called as packetization.
This process is use packet as unit. And we must to know about Precinct and Layer, too.
Fig. 4-1 Precinct is compose by the same dpi of the code block in the HL, LH and LL
sub-band.
As Fig. 4-1 shows, the precinct is compose by the same dpi of the code block in the
15
HL, LH and LL sub-band. We can use the precinct to control the dpi and the error when
we restored the image. And the Packet means the combine of bit-stream form Tier-1 is
the code-block in the same precinct. The Layer means the combine is from different
precinct.
The bit-stream from every code block can be truncate from any-point. So JPEG
2000 allowed usage to assign the compression ratio, and use Post-Compression
Rate-Distortion control (PCRD) to optimize the best cut-off point at every code block.
Fig. 4-2 The JPEG 2000 processes.
Post-Compression Rate-Distortion
After EBCOT , it will output a bit-stream. The bit-stream is combine with the
current bit-plane's three passes' context label. We define {ni} is the set of the truncate
point of the code-block Bi.
means the length of the from ni-1 to ni.
is the loss
of the image after rebuilt. So the losses of the whole image is:
And the reasonable length is:
where
is target bit-rate.
With Largrange multiplier method, use PCRG optimization algorithms to find the
best truncate point to approach target bit-rate at each code block. And get the minimum
16
value at following cost function:
‧
where
means use
as the threshold of the slope to find the best truncation point.
Following is the algorithm to find the best truncation point.
Optimization of
Initialize
for given
=0
For t= 1,2,...,Zi ;( Zi is the last truncation point)
Set ΔR=
andΔD=
If ΔD/ΔR>
replace
(This step guarantees that
Set
for all n t)
=
To find the best
with different
in the algorithm. We will run the algorithm several times
. The set Hi is to collect the feasible truncation point.
We define the slope Si(n) for every truncation point as:
and we also can get truncation points which in the set Hi if and only if
and
where t>h. Above to the condition, we can get
with 0=
we can get the feasible truncation point in the set
17
. So
with following algorithm when we
know the threshold of
Optimization of
.
over
Let j=0
While j+1<
and
J++
Set
With this algorithm, we can get the truncation point to control the loss and the image
size.
18
Bibliography
[1]
Gregory K. Wallace, “THE JPEG STILL PICTURE COMPRESSION
STANDARD,” in IEEE Transactions on Consumer Electronics, Vol. 38, No. 1,
FEBRUARY 1992
[2]
SoC Design Lab, "JPEG 簡介" 2004
[3]
David Taubman, Erik Ordentlich, Marcelo Weinberger, Gadiel Seroussi
"Embedded Block Coding in JPEG2000", in Signal Processing: Image
Communication Vol.17 (2002) 49–72
[4]
Xavier Delaunay , "EBCOT coding passes explained on a detailed example"
[5]
林桂蘭, "
JPEG2000 靜態影像編碼系統之分析與架構設計", master thesis,
2002
[6]
“JPEG,” available in http://en.wikipedia.org/wiki/JPEG
[7]
“JPEG2000,”
[8]
“YCbCr,” available in http://en.wikipedia.org/wiki/YCbCr#Technical_details
available in http://en.wikipedia.org/wiki/JPEG2000
19
© Copyright 2026 Paperzz