Documente Academic
Documente Profesional
Documente Cultură
6, JUNE 2007
Correspondence
Reversible Integer Color Transform TABLE I
PARAMETERS OF THE REVERSIBLE INTEGER COLOR TRANSFORMS (PART 1)
Soo-Chang Pei and Jian-Jiun Ding
I. INTRODUCTION
In color image processing, there are a variety of color-coordinate
systems. Most of them consist of three components. Some popular and
well-known ones are RGB, Karhunen–Loeve average (KLA), highest
ability for color decorrelation, IV1 V2 , YCb Cr , DCT, YUV, and YIQ
[1], [2]. In many applications, we usually have to transform one color
coordinate system into another one. The transformation is done by a 3
2 3 matrix. For example, the RGB-to-KLA transform is [2]
0:54933 0:60238 0:57912
AKLA = 0:80429 00 19322 00 56194
: : : (1)
0:22661 00 77447 00 59063
: :
II. PREVIOUS WORKS ABOUT INTEGER TRANSFORMS
AND MATRIX FACTORIZATION
Since the entries of color transform matrices are usually not of binary In [2], the reversible integer RGB-to-KLA transform was introduced.
form, we should use the floating-point processor to implement them. In [3], the reversible integer RGB-to-YCb Cr was developed. Then,
When using the fixed-point processor, we should approximate them by in [4]–[6], [14], Hao, Shi, and Chen used a systematic way based on
binary matrices. Unfortunately, the approximate2d matrices are always matrix factorization to derive the integer color transforms.
irreversible. For example, suppose that we apply rounding to approxi- Matrix factorization is an important problem in linear algebra [12].
A R
mate KLA by a binary matrix, i.e., KLA = round( KLA 2k )20k A In [9]–[11], the ways that use three triangular matrices to decompose a
S
and KLA = round( KLA A01 (2k )20k . From computer experiments, unitary matrix were proposed. In [13], the way to decompose a matrix
we find that into a product of one-row matrices was also proposed. In [4]–[6], [14],
Hao, Shi, and Chen apply these matrix decomposition methods to de-
SKLA 1 RKLA 6= I no matter how large k is: (2) rive the reversible integer color transforms.
In this paper, we improve the previous works about integer color
Thus, after approximating a color transform by sums of powers of two, transform derivation. Our algorithm is also based on matrix decompo-
the reversibility property is always lost. It affects the performances of sition. The improvement is that the proposed algorithm can achieve all
many image processing applications. For example, we usually hide the the following five goals at the same time.
watermark in the least significant bit. If we cannot recover the original • [Goal 1] The integer color transform should be reversible.
image, even if only the least significant bit is wrong, the watermark will • [Goal 2] No floating-point processor is required for both the for-
be destroyed. ward and the inverse transforms.
If we want to preserve the reversibility property, we should use • [Goal 3] The bit-length of the output should be constrained.
a floating-point processor, which is more time-consuming and in- • [Goal 4] Less complexity for implementation
efficient. To overcome this problem, some integer color transforms • [Goal 5] Accuracy: The integer transforms should well approxi-
used for approximating noninteger color transforms were developed mate the original transform.
[2]–[6], [14], [15]. Compared with the works in [2] and [3], the integer color transforms
derived here are much more accurate (see Section VII). Compared with
the advanced works in [4]–[6], [14], the improvements are: 1) the ways
Manuscript received May 4, 2006; revised January 16, 2007. This work was to save the number of time cycles for implementation (Section IV) and
supported by the National Science Council, R.O.C., under Contracts 93-2219-E- 2) the method to analyze the accuracy by normalized root mean square
002-004 and NSC 93-2752-E-002-006-PAE. The associate editor coordinating error are proposed (Section V). 3) The closed-form solutions of coef-
the review of this paper and approving it for publication was Dr. G. Marcu. ficients are shown. 4) Instead of 61, the entries of diagonal matrices
can be 62k . Moreover, two diagonal matrices were applied. Since our
The authors are with the Department of Electrical Engineering, National
Taiwan University, Taipei, Taiwan 10617, R.O.C. (e-mail: pei@cc.ee.ntu.
edu.tw; djj@cc.ee.ntu.edu.tw). algorithm is more general, the integer color transform with even higher
Digital Object Identifier 10.1109/TIP.2007.896617 accuracy can be obtained. 5) We use our algorithm to derive the integer
C
choices for . In theory, we can set pk (the upper bound of km ) to
C
infinite, i.e., there are infinite choices for . However, from our exper-
iments, the probability that the optimal integer transform is obtained
when km has a large value is very small. Thus, in (7), setting pk = 2
is usually sufficient to find the optimal integer transform. In this case,
there are 31 104 choices for . C
Then, applying the lifting scheme and the single-row elementary re-
versible matrix scheme [6], [7] with several modifications, we can de-
C
compose into four one-row matrices
C T 4 T 3 T2 T1
= (9)
t1 t2
1
t2 = 0 (t1 z 2 + z1 ) (10)
z1 c21 c22 01 0c23
1 0 c33
=
z2 c31 c32
cm1n are the entries of C (11)
1 0 0
y y
and least significant bits of 1 are 2k and 2k , then those of 1 are
k and 2k , where k k + log and k k + log . Since
2 3 1 2 4 2 2 We then use binary values gn to approximate tn
y
k3 0 k4 + 1 k1 0 k2 + 1, the number of bits of is almost the same as
y
that of 1 . Thus, scaling just shifts the dynamic range in density values
gn = Qb (tn ); n = 1; 2; . . . ::; 8 (15)
and does not enlarge or shorten it.
Then we do permutation, scaling, and sign changing operations for
A where Qb is a truncation operation, which throws the bits that are less
than 20b
C D1P1AP2D2
= (4) 1 b
Qb 6 dn 20n = 6 dn 20n ( dn = 0 or 1): (16)
where P1 is a row-permuting matrix and P2 is a column-permuting n=01 n=01
matrix. In each row and column of a permuting matrix, only one entry
is 1 and others are 0. D1 and D2 are diagonal matrices
Then we derive the reversible integer transform B that approximates
D1 [m; m] = 6 20k A from
D2 [m; m] = 6 2k (m = 1; 2; and 3) (5)
B PT1 D1V4V3 V2 V1 D2 P2T
= (17)
D1 or 2 [m; n] = 0 when m 6= n: (6)
V1 V2
2
1 0 0 1 g7 g8
V3 = 0 1 0 ; V4 = 0 1 0 : (18)
0 km pk (7) g5 g6 1 0 0 1
1688 IEEE TRANSACTIONS ON IMAGE PROCESSING, VOL. 16, NO. 6, JUNE 2007
Theorem 1: In (17), B
is a binary matrix that approximates . A in hardware), and multiplying 20k (just doing bit shifting) does not re-
Moreover, we can define the inverse integer transform as 0 = B quire any time cycle. Then, in (18), each of 1 , 2 , 3 , and 4 requiresV V V V
PD V V V V D P
2 2
01 01 01 01 01 01 1 . It is easy to prove that
1 2 3 4 1 three time cycles. For example, in (22), to implement 1 , we must cal- V
(1) culate l1 = g1 x1 [2] in the first time cycle, calculate l1 = l1 + g2 x1 [3]
B0 B = I : (19) in the second time cycle, and calculate x2 [1] = x1 [1] + Qr fl1 g in the
third time cycle. Thus, we need 12 time cycles to implement the integer
(2) Since the inverse of a binary one-row matrix is also a binary color transform if we apply (17) and (18) directly.
one-row matrix However, from the facts that
1 two adjacent one-row matrix can be
implemented together and
2 if r is larger than q1 where 20q is the
1 0 g1 0 g2
least significant bit of x1 [1], then (22) is equivalent to
V101 = 0 1 0
0 0 1 x2 [1] = x1 [1] + Qr f1g x1 [2] + g2 x1 [3] g
1 0 0 = Qr f x1 [1] + g1 x1 [2] + g2 x 1 [3]g (25)
V201 = 0 3 g 1 0 g4
1
g5
0 g7
g6
0
1
g8
where f =D P x T
2 2 : (26)
V01 =4 0 1 0 (20) Step 2)
0 0 1 f [1] = Qr0k f f [1] + g2 f [3] g
B
therefore, 0 is bound to be a binary matrix and the first two f [2] = f [2] + g4 f [3]; f [3] = f [3]: (27)
goals listed in Section II are satisfied.
Step 3)
f [1] = f [1]; f [2] = Qr 0k f f [2] + g3 f [1] g
f [3] = f [3] + g5 f [1]: (28)
IV. BIT CONSTRAINT
Then we try to satisfy Goals 3–5 in Section II. Note that, in (15)–(18), Step 4)
if the least significant bit of gn is 20b , and 20a and 20c are the least
f [1] = f [1] + g7 f [2]; f [2] = f [2]
x
significant bits of and ( = z z Bx), then f [3] = Qr0k f f [3] + g6 f [2] g : (29)
Step 5)
c = a + 4b: (21)
f [1] = Qr0k f f [1] + g8 f [3] g ; f [2] = f [2]; f [3] = f [3]
z
Thus, the bit-length of is much longer than that of . For example, if x z = P1T D1f (30)
the least significant bit of gn is 1=28 , then h2 = h1 + 32. To solve the
V V V
problem, we can convert 1 , 2 , 3 and 4 in (18) into addition- V where Qr is defined in (16) and km , gm , 1 , 2 , 1 , and 2 are D D P P
truncation operations. For example, we can convert 2 = 1 1 into x Vx defined in Section III. The process of the inverse integer color trans-
form is as follows.
x2 [1] =x1 [1] + Qr f g1 x1 [2] + g2 x1 [3] g Step 1)
f [1] = f [1] 0 g7 f [2]; f [2] = f [2]; f [3] = f [3]
x2 [2] =x1 [2]; x2 [3] = x1 [3]; Qr is defined in (16): (22)
where f = D101P1z : (31)
Note that, if the least significant bit of x1 [m]; x2 [1], and gn are 20q ,
0q , and 20b , respectively, then q2 = max[q1 ; min(r; q1 + b)]. If we Step 2)
2 f [1] = Qr0k f f [1] 0 g8 f [3] g ; f [2] = f [2]
set r to satisfy that q1 r < q1 + b and b > 0, then
f [3] = f [3] 0 g6 f [2]: (32)
q2 = r (independent of b): (23)
Step 3)
That is, the least significant bit of x2 [1] is increased from 20q 0b to
f [1] = f [1]; f [2] = f [2] 0 g3 f [1]
2
0r and the bit length is reduced. Although the bit length is reduced, f [3] = Qr0k f f [3] 0 g5 f [1] g : (33)
the reversibility property is preserved. For example, in (22), if we
x x
want to recover 1 from 2 , then we can apply
Step 4)
f [1] = f [1] 0 g2 f [3]; f [2] = Qr 0k f f [2] 0 g4 f [3] g
x1 [1] = x2 [1] 0 Qr f g1 x2 [2] + g2 x2 [3] g f [3] = f [3]: (34)
x = P2D201x1 : (35)
V. TIME CYCLE PROBLEM AND IMPLEMENTATION
We can prove that
There is another problem for implementing the integer color trans- Theorem 2: If 20a is the least significant bit of , 20b is the least x
form. That is, too many time cycles are required. Suppose that in each significant bit of gn , and
time cycle we can only do one addition and one multiplication in each
entry. Quantization (just throwing bits), permuting (just twisting circuit a r a + b + kn 0 km ; b > km 0 kn for any m; n; (36)
IEEE TRANSACTIONS ON IMAGE PROCESSING, VOL. 16, NO. 6, JUNE 2007 1689
then the least significant bit of the output z is Theorem 3: The error of the integer color transform can be approx-
imated by [from (42) and (43)]
20r (independent of b): (37)
z 0 y P1TD1 T4T3 T211 + P1TD1 T4 T312
Therefore, for our algorithm, if b is sufficient large such that (36) is + P1TD1 T413 + P1T D114
satisfied, then the least significant bit of the output is determined by
how many bits are preserved by the truncation operation Q and is in- + P1TD1 T4 T3 T2 r1 D2 P2Tx
dependent of b. That is, in (15), no matter how many bits we use for + P1TD1 T4 T3 r2 T1 D2 P2Tx
t
approximating n , the least significant bit of the output is remained + P1TD1 T4 r3 T2 T1 D2 P2Tx
to be .r + P1TD1 r4 T3 T2 T1 D2 P2Tx: (44)
Note that both the forward and inverse integer color transforms re-
quire only five time cycles. Moreover, only three storages are re- 1) The truncations in Steps 2)–5) cause P1 D1 T4 T3 T21 1 ,
T
[1] [2] [3]
quired during the process (for f , f , and f ). Thus, if we use P1T D1T4 T312 , P1TD1 T413 , and P1TD114 , respectively.
(26)–(35) for implementing the integer color transform, Goals 3 and 4 2) Quantizing T1 , T2 , T3 , and T4 into V1 , V2 ,
in Section II are satisfied. VT3 , and V4 cause PT1TD1 T4T3T2r1D2 P2TTx,
P1 D1T4 T3r2T1D2 P2 x, P1 D1 T4r3 T2 T1D2 P2 x,
T
and P1T D1 r4 T3 T2 T1 D2 P2T x, respectively.
There are some things to be noticed.
A) From Theorem 2, the least significant bit of z is independent of
VI. ACCURACY ANALYSIS
Then we discuss the problem of accuracy, i.e., Goal 5 in Section II. b. Thus, in (15) we can choose a large b. If b is very large, then
Note that, in Steps 2)–5), the truncation operation Qr0k is equivalent r r r r
1 , 2 , 3 , and 4 are very small and the last four terms in
to adding a small number (44) can be ignored
Qr0k fag = a + ; where 0 20r+k 01 20r+k 01 : (38) z 0 y P1TD1 T4T3 T211 + P1TD1 T4T312
If the input of Qr0k is not known, can be treated as a random +P1T D1 T413 + P1TD114 : (45)
variable that uniformly distributes in (0 0r+k 01 , 0r+k 01 ) and
2 2 For example, for the case of the integer KLA transform, when
r =0and b =8
, the last four terms affect only 8.05% of error.
[ ] = 0;
E [ 2 ] = 40r+k =12
E (39)
When r =0and b = 12 , these terms contribute only 0.07% of
error.
x
Note that in this case the error is independent of the input .
where E means the expected value. Thus, the process in (26)–(30) can T T T
B) From (44) and (45), we can see that the entries of 1 , 2 , 3 ,
be rewritten as T
and 4 affect the error of approximation. Especially, from (45),
z = P D1 V4 V3 V2 V1D P x + 11
T T T T T T
the entries of 3 and 4 have larger effects than 1 and 2 .
1 2 2 P P D
Thus, to make error small, we should adjust 1 , 2 , 1 , and
+112 ] + 13 g + 14 ) (40) D2 to make the values of t5 , t6 , t7 , and t8 in (13) and (14) as
where Vk is defined in (18) and 11 , 12 , 13 , and 14 are 3 2 1 random
small as possible.
C) After the integer transform is designed, we can use (44) together
vectors
with the following equation to estimate the normalized root mean
11 [2] = 11 [3] = 12 [1] = 12 [3] square error (NRMSE):
V4 V3 V2 V1 0 T4 T3 T2 T1 b = 8; r = 0: (47)
= (T4 + r4 )(T3 + r3 )(T2 + r2 )(T1 + r1 )
0 T4 T3 T2 T1 Then, from Theorem 2, the least significant bit of the output is
T4 T3 T2 r 1 + T4 T3 r 2 T1 + T4 r 3 T2 T1
+ r 4 T3 T2 T1 : (43) 200 = 1: (48)
1690 IEEE TRANSACTIONS ON IMAGE PROCESSING, VOL. 16, NO. 6, JUNE 2007
Therefore, the least significant bits of both the input and the output data
are 1. We also suppose that the input signal is uniformly distributed in
Step 2)
f[1] = 02 f [1] + 641 [3] 256g
Q f f =
E
2
( [ ]) = 127 52
x n : : (49)
Step 3)
f [1] = [1] [2] = 01 f [2] 0 115 [1] 256g
f ; f Q f f =
Using (49) together with (39), (44), (46), and the fact that yT y = f [3] = [3] + 21 [1] 64
f f = : (57)
xT AT Ax, we can calculate the NRMSE. We try to convert the ten Step 4)
f [1] = [1] 0 57 [2] 256 [2] = [2]
f f = ; f f
color transforms in (50)–(54) into reversible integer transforms. The
results are shown in Table I and II, where gk k D1 , D2 , P1 , ( = 1 8) f [3] = 0 f [3] + 73 [2] 128g
Q f f = : (58)
and P2 are the parameters, diagonal matrix, and permuting matrices
using in the processes of (26)–(30) (for the forward transform) and
Step 5)
z [1] = [2] 2 [2] = [3]
f = ; z f
(31)–(35) (for the inverse transform) z [3] = 02 f [1] + 193 [3] 256g 4
Q f f = = : (59)
(1) RGB to KLA Note that, in Tables I and II, the NRMSEs of all the integer color trans-
0 8185 0 8975 0 8629
: : : forms are smaller than 0.3%. In contrast, the NRMSE of the simple
1 1984 00 2879 00 8373
: : : integer RGB-to-KLA transform in [2] is 68.80%. The NRMSE of the
0 3376 01 1539 00 8800
: : : YC C
integer RGB-to- b r transform in [3] is 41.14%. For the integer
(2)RGB to IV1 V2 RGB-to-DCT transform in [5], the NRMSE is 0.3363% if we also
1p 1p 1p choose r =0 =8
and b . For the RGB-to-DCT transform, we derive
01 p 6 01 p6 2 6
= = = (50) NRMSE = 0 2679%
: : (60)
1 6 01 6 0
[ ]j in (5) can be nonunitary and that
= =
(9) RGB to RC GC BC [6] P. Hao and Q. Shi, “Matrix factorizations for reversible Integer map-
ping,” IEEE Trans. Signal Process., vol. 49, no. 10, pp. 2314–2324,
1 609 00 447 00 104
: : : Oct. 2001.
00 058 0 977 0 051
: : :
[7] S. Oraintara, Y. J. Chen, and T. Q. Nguyen, “Integer fast Fourier trans-
[13] B. Chen and A. Kaufman, “3D volume rotation using shear trans-
forms,” Graph. Models, vol. 62, pp. 308–322, 2000.
[14] P. Hao, “Customizable triangular factorizations of matrices,” Lin. Al-
gebra Appl., vol. 382, pp. 135–154, May 2004.
[15] S. C. Pei and J. J. Ding, “Reversible integer color transform with bit-
constraint,” in Proc. Int. Conf. Image Processing, 2005, vol. 3, pp.
964–967.
Fig. 1. Two 3 2 3 pixel patterns with same DRDM distortion score [11].