# 2. Integer transform - 丁建均

Electronics - Devices

Nov 27, 2013 (4 years and 5 months ago)

123 views

Integer Transform

A tutorial

B98901179 Lun
-
Kai Hsu (

)

Department of Eletrical Engineering,

National Taiwan University

Jian
-
Jiun

Ding

Content

Abstract

1.

Introduction

2.

Integer transform

3.

4.

How to convert to integer transform

4.1
Truncation

4.2
The criteria to measure the conversion

4.3 Some example
s

of integer transforms

5. Integer transform methods

5.1
Prototype matrix

5.2 Lifting scheme

5.3 Triangular matrix scheme

5.4 Improved triangular

6.
Discussion

7. Conclusion

8. Reference

Abst
ract

In this report, we first explain what is integer transform and why we need it.
Integer transforms
transforms that matrix elements can be represent as
summation of integer power of 2. Integer transform can
improv
e the efficiency of
digital
signal processing and is important in VLSI design
. There are 4 methods
that we can convert a non
-
intege transform t
o a integer transform.

1.

Introduction

In this report, we will introfuce integer transform thoroughly. First of all, let’s go
through some key ideas and get the big picture.

What is “integer transform”?

Originally, it refers to the operation that input and are output are both “integer”.
The modified definition says that integer transform is the operation that both
input and output are “summations of power of 2”. W will give a more detail
explanation and e
xample later.

Why do we need integer transform?

The advantage of integer transform is that we can use the fixed
-
point processor
to implement it exactly. Therefore , it requires less computation time and less
cost for implementation. The fixed
-
point proces
sor will be explained later.

While integer transform has such merits, many popular operations are
non
-
integer transform, for example: discrete fourier transform(DFT), wavelet
transform, etc.

So the problem is
how do we convert a non
-
integer transform into

an integer
transform?

The second half of this report will focus on how to achieve this goal,
what algorithm do we have.

The remainder of this report is organized as follows: in section 2, …….

2.
Integer transform

Integer transforms are operations that
both input and output are summations of
powers of 2. For example
,


=
3

is a integer transform since 3 = 1+2. Also,


=

7
16

is a integer transform because 7/16 = 1/16 + 1/8 + 1/4.

If we write the integer transform in the matrix form
y

=
A

x

(
A
is a N
-
by
-
N
matrix), we must have

[

,

]
=

𝑘
2

𝑘

k =
-
inf ~ inf, a
k

= 0 or 1. Or equivalently,

[

,

]
=


2
𝑏

where C is a integer.

For example,


=

,

=
[

5
4
1
2
1
4
3
4
1
7
4
1
2

1
4

1
4
]

is a integer transform. However,


=

10
+
9
10

255

is not a integer transfor
m.

3.

As we mention in section 1, the advantage of integer transform is that we can use
the fixed point processor to implement it exactly.

But what is fixed
-
point processor?
A fixed point number has a specific number of
bits (or digits) reserved for the integer part (the part to the left of the
point

“.”
) and a specific number of bits reserved for the fractional
part (the part to the right of the

point). No matter how large or small your
number is, it will always use the same number of bits for each portion.

The
opposite is the floating point.

The fixed point is easy to perform operatoins and thus require less computation
time and less cost for i
mplementation.

4.
How to convert to integer transform

Unfortunately, most transforms are not integer transforms since the elements in
matrix are hard to be of the form

/
2
𝑏
. For example, in discrete cosine
transform(DCT)

[

,

]
=

𝑘
𝑚
cos

(
2
𝜋 
/
𝑁
)

In the RGB
-
to
-
YcbCr transform,

=
[
0
.
299
0
.
587
0
.
114
0
.
5

0
.
419

0
.
081

0
.
169

0
.
331
0
.
5
]

not a integer transform either.

If we want to exploit the advantage of integer transform, we need to convert
them to integer transforms.

How do we convert a non
-
integer trans
form into an
integer transform?

4.1
Truncation

The easiest way to convert to integer transform is to round each element to a
near number which is the summation of powers of 2. For example, 0.299 is close
to 5/16 = 0.3125, so we can truncate the
above
RGB
-
to
-
YcbCr transform to


=
[
5
/
16
9
/
16
2
/
16
8
/
16

7
/
16

1
/
16

3
/
16

5
/
16
8
/
16
]

as well as the inverse transform

1
=
[
1
1
.
4017

0
.
0009
1

0
.
7142

0
.
3437
1
0
.
0010
1
.
7722
]


~
=
[
16
/
16
22
/
16
0
16
/
16

11
/
16

5
/
16
16
/
16
0
28
/
16
]

Although the elemets’ values are close before and

after the truncation, we lost
some important properties. For example, the reversibility:

1
=
𝐼

but




~

𝐼

We need some critetia to measure is it a good conversion to integer transform.

4.2 The criteria to measure the conversion

We need someth
ing other than absolute difference of corresponding elemets. The
criteria are listed as follows.

(1) Integerization

It is the most important goal while doing the conversion.


[

,

]
=

𝑏
𝑘
2
𝑘


~
[

,

]
=

𝑏
~
𝑘
2
𝑘

W
ithout

integerization, it would not be a

integer transform.

(2) Reversibility




~
=
𝐼

It is what the truncation method not considers. However, it is also very importatn
since we
always
want
to convert both forward transform and inverse transform.

(3) Accuracy



𝜎
,


~

𝜎

1

1

Thi
s is a intuitive one that truncation takes into consider. We want the integer
transform be similar to the original transform so that we can use it as the
approximation of original transform and take advantage of the property of
integer transform. The
𝜎

is

that we can scale the transform (so we unscale it by
𝜎

1

in inverse transform).

(4) Bit constraint

The denominator 2
k

should not be too large. The goal of integer transform is to
perform operatoin easily. A too large denominator is hard to store and op
erate.

(5) Less complexity

Similarlu, we don’t want a complex algorithm to convert it. If we take a lot of time
to convert a transform to integer transform, it may not worth to do it.

The goal of
integer transform is to reduce computation time.

4.3 Som
e example
s

of integer transforms

Let’s take a look at some integer transforms.

In JPEG 2000 standard, the RGB
-
to
-
YCbCr is approximated by

=
[
0
.
299
0
.
587
0
.
114
0
.
5

0
.
419

0
.
081

0
.
169

0
.
331
0
.
5


=
[
0
.
25
0
.
5
0
.
25
1

1
0
0

1
1
]

and

1
=
[
1
1
.
4017

0
.
0009
1

0
.
7142

0
.
3437
1
0
.
0010
1
.
7722
]


~
=
[
1
0
.
75

0
.
25
1

0
.
25

0
.
25
1

0
.
25
0
.
75
]

Note that the conversion is not that similar compare to the truncation method
mentioned before, but it satisfies the reversibility property




~
=
𝐼

Another example is the conversion of
DCT becomes the Walsh transform:

In
MPEG
-
4

=
[
]


=
[
]

Note that we scale a ratio of 2 here.

5. Integer transform methods

In this section, we introduce 4 groups of methods to convert
integer transform.
They are

(1)

Prototype matrix method, which is
suitable for 2, 4, 8 and 16
-
point DCT, DST,
DFT

(2)

Lifting scheme, which is
suitable for 2
k
-
point DCT, DST, DFT

(3)

Triangular matrix scheme, suitable for any matrices and satisfies criterion 1
and criterion 2

(4)

Improved triangular
, suitable for any matrices and satisfies all criteria

5.1 Prototype matrix

The spirit of prototype matrix is: let the

prototype

looks like the original
transform.

As we mentioned before, this method can only used on a limited transform. Let’s
take 8
-
p
oint DCT as an example:

We can then scale it and let a
1

= 0.9808, a
2

= 0.8315, a
3

= 0.5566, a
4

= 0.1951,

b
1

= 0.9239, b
2

= 0.3827. These are the parameters that need to be determined
later.

The matrix becomes

There are 2 constraints.

(1)

We want to preserve the ordering relationships within the same row. Since
0.9808 > 0.8315 > 0.5566 > 0.1951, we force

a
1

>

a
2

> a
3

> a
4
.
Similarly, we have b
1

> b
2

(2)




𝑇
=

,

D is a diagonal matrix (nonzero only on the diagonal).

We convert 0.7010 to 1 because we can do scaling.
The constr
aint looks simple,
but acually there are 56 equations. (The reason is that D is 8
-
by
-
8, so there are
64
-

8 = 56 elements must be zero, hence 56 equations must hold)

Fortunately, if the transform i
s , for example, DCT, the 56 constraints all reduce to
one equation
:

1

2

2

4

1

3

3

4
=
0

because DCT transform has high symmetry.

A example of the converted DCT transform is:

1

=

5
,

2

=

3
,

3

=

2
,

4

=

1
,


1

=

3
,


2
=

1

Si
nce this Prototype Matrix Method requires the transform matrix to have a very
high symmetry, it is only suitable for a limited number of transforms, i.e. the
sinussoid type transforms (Fourier, cosine, sine, and Hartley transforms) with N
= 2 , 4, 8, or 16
.

Otherwise, the constraints are too complicated to solve. The number of
unknowns is too large.

5.2 Lifting scheme

This method is a milestone based on a very influential paper (citation 2345):

The lifting scheme: a constr
uction of second generation
wavelets
”. More
information can be found in this paper: “
The binDCT: fast multiplierless
approximation of the DCT
”.

The idea of this method is that if a
upper
-
triangle
matrix has all 1’s at the
diagonal, it will be reversible after quantization. For examp
le:

,

.

1 1 1 1 1 1 1 1
5 3 2 1 1 2 3 5
3 1 1 3 3 1 1 3
3 1 5 2 2 5 1 3
1 1 1 1 1 1 1 1
2 5 1 3 3 1 5 2
1 3 3 1 1 3 3 1
1 2 3 5 5 3 2 1
 
 
   
 
   
 
 
   
 

 
   
 
   
 
 
   
 
   
 
B
1 3.14
0 1
 

 
 
A
1 3
0 1
 

 
 
B
1
1 3.14
0 1

 

 
 
A
B

1

3
0
1

We have
, the property that we desire.

Therefore, we want to decompose a transform matrix to a multiplication of
several
upper
-
triangle
matrices with 1’s at diagonal.

For a general 2
-
by
-
2 matrix,

=
[




]

we can assume witho
ut loss of generality that is has deteterminant equals 1.

Then we can decompose it as follows
:

Then we
quantize

each
element to the form

b/2^c

We will have

where

The upper
-
triangle with diagonal equals 1 is also easy to inverse
:

B

B

I
1 ( 1)/1 0 1 ( 1)/
0 1 1 0 1
a b a c d c
c d c
 
       
 
       
       
A
3
1
2
1
3
2
1 0
1/2
1/2
/2 1
0 1
0 1
k
k
k

 
 
 

 
 
 
 
 
 
B
3 1 2 3
1 2 1
2 3
2
3 1 2 3
1 2 1
2 3
2
1
2 2 2 2
1
2 2
k k k k
k k k
k k
k
 
 


 

 
  
 

 
 

 
 
1
1
( 1)//2,
k
a c

 
2
2
/2,
k
c

3
3
( 1)//2,
k
d c

 
B

1

3
/
2
k
3
0
1

1
0

2
/
2
k
2
1

1

1
/
2
k
1
0
1

3 2 3 1 2 3
1
2 2 1
3 2 3 1 2 3
1
2 2 1
1
2 2 2 2
1
2 2
k k k k k k
k
k k k
  

 
  

 
   
 

 
 
 
 
 
How can we generalize this method to larger matrix?

We first observe that

implies y
1

= ax
1

+ bx
2

, y
2
= cx
1

+ dx
2
. We can represent it as

x
1

y
1

with multiplication

a,
x
2

y
1
with multiplicaiton d, the same as y
1

= ax
1

+ bx
2

, y
2
= cx
1

+ dx
2
.

can thus be represented as

It means the process of multiplying with A can be decomposed to 3 steps:

(1)

y
1

= 1*x
1

+ (a
-
1)/c * x
2

,
y
2

= x
2

1 1
2 2
y x
a b
y x
c d
   
 

   
 
 
   
1 ( 1)/1 0 1 ( 1)/
0 1 1 0 1
a b a c d c
c d c
 
       
 
       
       
A

x
1

x
2

y
1

y
2

a

b

c

d

(2)

y
1

= x
1

, y
2
= c*x
1

+ x
2

(3)

y
1

= x
1

+ (d
-
1)/c * x
2

, y
2

= x
2

The concatenation of this three steps is equivalent to multiplying with

=
[




]

We can generalize this process to
2^k

point matrix using butterflies. For
example, a 8
-
by
-
8 matrix can be decomposed as

Then we can use the same technique to convert all 2
-
by
-
2 matrices.

The advantages of this lifting scheme are:

(1)

Easy to design (avoiding solving the
N
(
N
-
1) orthogonali
ty constraint)

(2)

Flexibility:

1
/2
k
1
,

2
/2
k
2
,

3
/2
k
3
,
are free to choose

(3)

The fast algorithm of the original non
-
integer transform can be preserved

This method is suitable for 2^k point discrete Fourier, cosine, sine, Hartley,
wavelet transforms.

However, what if the size of the transform is not a power of 2 ? We can adopt the
following method.

5.3 Triangular matrix scheme

As we just mentioned, we want to generalize the lifting scheme to any size of
matrices. The method is the following triangula
r matrix scheme.

First of all, without loss of generality we can assume that the determinant of a
matrix A is a power of 2. (If not, we can do scaling).
Then A can be decomposed
as:

=
𝐿𝑈𝑆

where

(1)

D is a diagonal matrix

(2)

L is a lower triangular matrix

(3)

U is a upper triangular matrix

(4)

S is nonzero only at diagonal and the lowest row

We can easily quantize A to integer transform by quantizing L, U, S respectively.


=

𝐿
1
𝑈
1
𝑆
1
.

Moreover, the inverse tranfrom is also easy:



1
=

𝑆
1

1
𝑈
1

1
𝐿
1

1


1
.

The triangular matrix scheme can be analog to the lifting scheme
,

.

(1)

L is a lower triangular matrix similar to
the

[
1
0

1
]

(2)

U is a upper triangular matrix similar to the

A

a
b
c
d

1
(
a

1
)
/
c
0
1

1
0
c
1

1
(
d

1
)
/
c
0
1

[
1

1

0
1
]

𝑟

[
1
(


1
)
/

0
1
]

(3)

D is a diagonal matrix which release

the constraint that the determinant must
be 1.

The triangular matrix decomposing is easy to compute, as will as its inverse
transform, therefore meets the criteria 1 and 2. What we want next is to improve
it so that all the criteria can be met. We will d
iscuss how to improve it in the next
subsection.

5.4 Improved triangular

As we mentioned before, triangular matrix scheme doen not meet the following
criteria:

(1)

accuracy

(2)

complexity

Let’s discuss it one by one

5.4.1
Further improvement: Accuracy

We hope that the converted integer transform is closed to the original transform.
That is we want the difference of A(original matrix) and B(integer matrix) to be
small.

=
𝐿𝑈𝑆


=

𝐿
1
𝑈
1
𝑆
1

The difference can be approximated as the first order diffe
rence:



𝐿𝑈
(
𝑆

𝑆
1
)
+

𝐿
(
𝑈

𝑈
1
)
𝑆
+

(
𝐿

𝐿
1
)
𝑈𝑆
.

So the difference depends on the differnce of each U, L, S after quantization. It
seems that we have nothing to do because U, L, S is detemined by decomposition
of A. In fact, we can do better.

The

idea is that we can permute the rows and columns so that it “may” have
better accuracy. The equation can be formulated as follows:


=
𝐿𝑈𝑆
,

where
P

is a row permutation matrix and
Q

is a column permutation matrix.
Instead of decompose A, we decompose PAQ. There should be a choice of P and Q
that have good accuracy.


=
𝐿𝑈𝑆
,


=

𝐿
1
𝑈
1
𝑆
1


=

𝑇

𝐿
1
𝑈
1
𝑆
1

𝑇

A systematical way to determine
P

and
Q

can be found at [5].

5.4.2 Further improvement: Complexity

The complexity is actually not a serious issue. It may seems that 3 triangular
matrices take a long computation. In fact, we can implement the upper triangular
matrix and lower triangular matrix in the same time.

5.4.3 Further improvement

We can further generalize the method by release the constraint that the diagonal
must be 1’s.

This technique is called scaled lifting scheme or scaled triangular matrix scheme.
More detail can be found at [6]

6.
Discussion

The integer transform can be applied to the color transform, such as RGB to
YCbCr Transform:

We can converted this transform to a integer transform:

The accuracy is very satisfying. The original transform has NRMSE (normalized
root mean square error
) in JPEG 2000 : 20.83%. The integer transform has only
0.1687% NRMSE.

Next, let’s show another example of integer transform with high accuracy:

0.299 0.587 0.114
0.5 0.419 0.081
0.169 0.331 0.5
 
 
  
 
 
 
 
A

We can see that the integer version is indistinguisha
ble with the original version
of 210
-
point DFT.

7. Conclusion

The integer transform can apparently improv
e the efficiency of digital
signal
processing and is important in VLSI design.

In this report, we introduce what is integer transform, why we need

integer
transform and explain the method to convert a non
-
integer transform matrix to
be a integer transform.

8
.
Reference

[1]
W. Sweldens, “The lifting scheme: a constr
uction of second generation
wavelets,”
Applied Comput. Harmon. Anal.
,
vol. 3, no. 2, pp. 186
-
200,
1996.

[2]
T. D. Tran, “The binDCT: fast multiplierless approximation of the DCT,”

IEEE
Signal Proc. Lett.
, vol. 7, no. 6, pp. 141
-
144, June 2000.

[3]
S. Oraintara, Y. J. Chen, and T. Q. Nguyen, “Integer fast Fourier transform”
,
IEEE
Trans. Signal Processing
, vol. 50, no. 3, pp. 607
-
618, March 2002.

[4]
P. Hao and Q. Shi., “Matrix factorizations for reversible integer mapping”,

IEEE Trans. Signal Processing
, vol. 49, no. 10, pp. 2314
-
2324, Oct. 2001.

[5]
S. C. Pei and J. J. Ding, “Improved reversible integer transform”,
ISCAS
,
pp.
1091
-
1094, May 2006.

[6]
S. C. Pei and J. J. Ding, “Scaled lifting sch
eme and generalized reversible
integer transform,”
ISCAS
, pp. 3203
-
3206, May

2007.

[7]
S. C. Pei and J.
J. Ding, “Reversible integer color transform,”
IEEE Trans

on
Image Processing
, vol. 16, no. 6
, pp. 1686
-
1690, June 2007.

[8
]

S. C. Pei and J. J. Ding, “Improved reversible integer
-
to
-
integer color

transforms,”
IEEE International Conference on Image Proc
essing
,

Nov. 2009.
]

[9] Integer to Integer Transform

,