13
Signal Processing 19 (1990) 233-245 233 Elsevier SHORT COMMUNICATION DISCRETE COSINE TRANSFORM FILTERING B. CHITPRASERT* and K.R. RAO Department of Electrical Engineering, The University of Texas at Arlington, Arlington, TX 76010, U.S.A. Received 16 December 1987 Revised 3 July 1989 Abstract. The circular convolution-multiplication relationships for the discrete cosine transform (DCT) similar to that for the discrete Fourier transform (DFT) are developed. The relations are valid only if the filter frequency response is real and even. Two fairly simple relations are developed in this paper. The second relation is simpler than the first one. The multiplication of the DCT of signal sequence and the DFT of filter sequence results in circular convolution of the folded signal sequence and the filter sequence. Thus, it may be used to filter an image in frequency domain as an approximation of the circular convolution in spatial domain. Zusammenfassung. Chen und Fralick entwickelten eine Beziehung zwischen Multiplikation und Faltung bei der diskreten Cosinus-Transformation (DCT) ~ihnlich der yon der diskreten Fourier-Transformation (DFT) bekannten. Die genannte Beziehung ist jedoch ziemlich kompliziert. Der vorliegende Beitrag entwickelt eine einfache Multiplikations-Fahungs- Beziehung fiir die DCT. R6sum6. Dans cet article on d6veloppe pour la transform6e en cosinus discrete (DCT) des relations de convolution- multiplication circulaires semblables/t celles existant pour la transform6e de Fourier discrete (DFT). Ces relations ne sont valides que si la r6ponse en fr6quence du filtre est r6elle et paire. Deux relations tr~s simples sont d6velopp6es, la deuxi~me 6tant plus simple que la premiere. Le produit de la DCT du signal avec la DFT du filtre a pour r6sultat une convolution circulaire du signal repli6 et du filtre, Ceci peut donc ~tre utilis6 pour le filtrage d'une image dans le domaine fr6quentiel en tant qu'approximation d'une convolution circulaire dans le domaine spatial. Keywords. DCT, image compression, filtering. I. Introduction In image compression, an image is in general divided into small sub-blocks for processing. In some algorithms, the sub-blocks are discrete cosine transformed block by block. In some cases, it might be convenient to perform the filtering by multiplication in spectral domain. However the DCT is not the real part of the DFT but is related in a complicated manner. The circular convolution-multiplication property for the DFT has been extended to the DCT by Chen and Fralick [2]. They have shown that multiplication in the DCT domain results in the circular convolution of three spatial sequences. Its application to filtering of images based on sub-block transform processing has been demonstrated. Ngan and Clarke [4] have applied this property to low-pass filtering of images. However, the convolution-multiplication relationship developed in [2] is quite cumbersome. The purpose of this paper is to develop a simple convolution-multiplication relationship for the DCT filtering when a real and even frequency response filter is used. * Now with Compression Labs, Inc. San Jose, CA 95134, U.S.A. 0165-1684/90/$3.50 © 1990, Elsevier Science Publishers B.V.

Discrete cosine transform filtering

Embed Size (px)

Citation preview

Page 1: Discrete cosine transform filtering

Signal Processing 19 (1990) 233-245 233 Elsevier

SHORT C O M M U N I C A T I O N

D I S C R E T E C O S I N E T R A N S F O R M F I L T E R I N G

B. CHITPRASERT* and K.R. RAO Department of Electrical Engineering, The University of Texas at Arlington, Arlington, TX 76010, U.S.A.

Received 16 December 1987 Revised 3 July 1989

Abstract. The circular convolut ion-mult ipl icat ion relationships for the discrete cosine transform (DCT) similar to that for the discrete Fourier transform (DFT) are developed. The relations are valid only if the filter frequency response is real and even. Two fairly simple relations are developed in this paper. The second relation is simpler than the first one. The multiplication of the DCT of signal sequence and the DFT of filter sequence results in circular convolution of the folded signal sequence and the filter sequence. Thus, it may be used to filter an image in frequency domain as an approximation of the circular convolution in spatial domain.

Zusammenfassung. Chen und Fralick entwickelten eine Beziehung zwischen Multiplikation und Faltung bei der diskreten Cosinus-Transformat ion (DCT) ~ihnlich der yon der diskreten Fourier-Transformation (DFT) bekannten. Die genannte Beziehung ist jedoch ziemlich kompliziert. Der vorliegende Beitrag entwickelt eine einfache Mult ipl ikat ions-Fahungs- Beziehung fiir die DCT.

R6sum6. Dans cet article on d6veloppe pour la transform6e en cosinus discrete (DCT) des relations de convolut ion- multiplication circulaires semblables / t celles existant pour la transform6e de Fourier discrete (DFT). Ces relations ne sont valides que si la r6ponse en fr6quence du filtre est r6elle et paire. Deux relations tr~s simples sont d6velopp6es, la deuxi~me 6tant plus simple que la premiere. Le produit de la DCT du signal avec la DFT du filtre a pour r6sultat une convolution circulaire du signal repli6 et du filtre, Ceci peut donc ~tre utilis6 pour le filtrage d 'une image dans le domaine fr6quentiel en tant qu 'approximat ion d 'une convolution circulaire dans le domaine spatial.

Keywords. DCT, image compression, filtering.

I. Introduction

In image compression, an image is in general divided into small sub-blocks for processing. In some algorithms, the sub-blocks are discrete cosine transformed block by block. In some cases, it might be convenient to perform the filtering by multiplication in spectral domain. However the DCT is not the real part of the DFT but is related in a complicated manner.

The circular convolution-multiplication property for the DFT has been extended to the DCT by Chen and Fralick [2]. They have shown that multiplication in the DCT domain results in the circular convolution of three spatial sequences. Its application to filtering of images based on sub-block transform processing has been demonstrated. Ngan and Clarke [4] have applied this property to low-pass filtering of images. However, the convolution-multiplication relationship developed in [2] is quite cumbersome. The purpose of this paper is to develop a simple convolution-multiplication relationship for the DCT filtering when a real and even frequency response filter is used.

* Now with Compress ion Labs, Inc. San Jose, CA 95134, U.S.A.

0165-1684/90/$3.50 © 1990, Elsevier Science Publishers B.V.

Page 2: Discrete cosine transform filtering

234 B. Chitprasert, K.R. Rao / Discrete cosine tran.~form filtering

In the first approach, a multiplication in spectral domain results in a circular convolution in spatial

domain plus a constant or DC term. The second approach is even simpler. The multiplication of the DCT of signal sequence and the DFT of filter sequence results in circular convolution of the folded signal

sequence and the filter sequence. The derivations are shown in the next section. The experimental results of using the second relationship are shown in Section 3.

2. Circular convolution-multiplication relationship

2.1. Relationship between the DCT and the DFT

The one dimenshional DCT [1] of a real sequence x(n) of length N and its inverse can be defined as

2 N , f(2n+l)~k] X¢(k)=~C(k) Z x(n)cos . . . .=,, L 2-N ] , k = 0 , 1, , N - 1 (1)

and

where

N-, [(2n + 1)~rk] x ( n ) = k y~o C(k)X~(k)c°sL ~ ] , n = 0 , 1 , . . . , N - 1 , (2)

then

if

W~(k)= X~(k)Hc(k),

w ( n ) = ~ (n ) * g ( n ) * z (n ) , (8) Signal Processing

(7)

= (1/x/2, k - -0 , C(k) 1 . 1 , k = l , 2 , . . . , N - 1 . (3)

For a symmetrical or folded (about n = - ½ ) sequence defined as follows:

( x ( n ) , n = 0, 1 , . . . , N - 1, ~(n)

L x ( - 1 - n), n - - - N , - N + I , . . . , - 1 , (4)

it can be shown that

Xc(k)=2C(k)exp(~Nk)f(F(k), k = 0 , 1 . . . . . N - l , (5)

where the DFT of the folded sequence can be written as

1 N-, {-j2~rnk'~ )(F(k) = ~ "~ .=• N ~(n) e x p ~ } , k = - N , - N + I , . . . , N - 1 . (6)

2.2. Convolution-multiplication of Chen and Fralick [2]

By extending the definition of C(k) in (3) beyond the range k = 0 through N - 1 to be zero, Chen and Fralick [2] have shown that

Page 3: Discrete cosine transform filtering

B. Chitprasert, K.R. Rao / Discrete cosine transform .filtering 235

where

1 1)" ] s i n [ ( w / 4 ) ( 2 n - 1

Here the '* ' denotes the circular convolution operator.

2.3. First approach to develop the simple relation

Similar to the DFT, which has periodic spectrum, the DCT outside the range k = 0 through N - 1 need

not be zero. The C(k) is defined differently from (3) as follows:

~ ' C ( - k ) = 1, k = - N , - N + I . . . . , - 1 , C(k)=[1/x/2, k = 0 . (10)

Due to the cosine function in (1) and from (10), the DCT of any real sequence is an even function, i.e.,

Xc(k)=Xc(-k), k = - l , - 2 , . . , , - N + l ( l l )

and X c ( - N ) = 0. The DCT is now defined in the range of k = - N through N - 1. It can be shown that (see Appendix A)

Xc(k)=2C(k)exp F(k), k = - N , - N + I , . . . , N - 1 . (12)

The simple convolution-mult ipl icat ion relationship to be derived requires the frequency response of the filter to be real and even. I f the impulse response of the filter h(n) is real and even, i.e., h(n) = h(-n), then the DFT of h(n) is real and even [5]. One example of this is the modulation transfer function of the human visual system [3]. The first approach to this derivation proceeds as follows:

if

Xc(k)HF(k) Yc(k)- C2(k) , k = - N , - N + I , . . . , N - 1 , (13)

where Hv(k) = H F ( - k ) and is real, then

y(n)=[~(n)*h(n)]+XF(O)Hv(O), n=O, 1 , . . . , N - 1 . (14)

Proof Using (12), Yc(k) from (13) can be expressed as

2 exp(~-Nk) f(~(k)Hv(k) Yc(k)- , k = - N , - N + I , . . . , N - 1 . (15)

C(k)

It can be seen from (13) that Yc(k) is real and from (10) and (11) that it is even, i.e., Yc(k)= Yc(-k). The inverse DCT of Yc(k) can be written as follows:

N , [ ( 2 n + l ) T r k ] y ( n ) = • C(k)Yc(k)cos n = 0 , 1 , N - l , (16)

k=o 2 N J ' " ' "

o

Y(n)=2kk=o C(k)Y~(k)C°Sk 2N _1 +k=~+l C(k)Y~(k)c°sL 21V J

[(2n+ + C ( - N ) Yc(-N) cos L 7N _1 ' (17)

Vol. 19, NO. ~, March 1990

Page 4: Discrete cosine transform filtering

236 B. Chitprasert, K.R. Rao / Discrete cosine transform filtering

where the last term is zero due to the cosine function. Combining all terms in (17) into one summation yields

1 [- s - , [(2n + 1)nrk'] ] Y(n)=zLk_-E-,,,C(k)Y~(k)COS[ 2-ff J+C(O) Y~(O).. (18)

Since C(k) and Yc(k) are real, y(n) can be expressed as

{ N-, {j(2n+l)wk,] ~ y ( n ) = ~ R e k=~NC(k)Y~(k)exp~ - ~-]~ -)~+ C(0)Y~(0). (19)

Substitution of Yc(k) from (13) in (19) results in

_ ~ f N-~ X¢(k)HF(k) exp( j (2n+ 1)~rk'~ +X~(0)HF(0). (20) Y(n)=2Rel, k--S C(k) \ 2N /J 2C(0)

Combining (12) and (20) leads to

{ N-, , /{j2~rnk' } y ( n ) = R e Y. ffF(k)Hv(k)exp|--j-~l +f(v(O)Hv(O). (21)

k = - N

The first term in (21) can be recognized as the IDFT, i.e.,

y(n) = Re{IDFT[ f(v( k )nv(k) ]} + )(F(0) HF(0)

= Re{~(n) * h(n)}+f~v(O)H~(O)

=~(n)*h(n)+f (v(0)Hv(0) , n=O, 1 . . . . , N - 1 .

Note that y(n) is defined for 2N points but has only N distinct values.

Even though this convolution-multiplication relationship is fairly simple, the presence of the DC term makes it difficult for applications in filtering. A more careful consideration leads to the second approach described in the following section.

2.4. Second approach

If

then

Yc(k)=X¢(k)HF(k), k = - N , - N + I , . . . , N - 1 , (22)

Proof Since Yc(k) in (22) is real and even, its inverse DCT can be written as in (20). Substitution of Yc(k) from (22) in (19) yields

1 {N i (j(2n+I)~rk~+Ic(o)xc(O)HF(O). (24) y ( n ) = ~ R e kZNC(k)X~(k)Hv(k)exp\ 2N ]J 2

Substitution of Xc(k) from (12) in (24) yields

{ N-~ [j2avnk'~ ] ^ y(n) = Re k=~N C2(k)f~v(k)HF(k) e x p ~ - - ~ ] ; + C2(O)XF(O)Hv(O). (25)

Signal Processing

y(n)=~(n)*h(n), n=O, 1 , . . . ,N -1 . (23)

Page 5: Discrete cosine transform filtering

B. Chitprasert, K.R. Rao / Discrete cosine transform filtering

Since the last term in (25) is real, it can be included inside the brackets, i.e.,

R e I ~ ' " + y ( n ) = tk= N C2(k)XF(k)Hv(k) e x p ( J 2 2 ~ ) C2(0)~'F(0)HF(0)} k=-ZN'f(F(k)H~(k)exp\ 2 N ] J = R e

237

= Re{IDFT[.~v(k)HF(k)]}

= Re{~(n) * h(n)}

= ~ ( n ) * h ( n ) , n = 0 , 1 , . . . , N - 1 . (26)

This second approach yields a simpler result than the first one since it does not contain an additional term. Thus it is adopted in our experiments on image filtering which is shown in the next section.

The convolution-multiplication property defined in (22) and (23) can be extended to the two-dimensional case as follows:

if

Y c ( k , m ) = X c ( k , m ) H v ( k , m ) , k , m = - N , - N + I , . . . , N - 1 , (27)

where Hv(k, m) = Hv( -k , - m ) = Hv( -k , m) = Hv(k, - m ) and is real, then

y ( n , l ) = £ ( n , l ) * h ( n , l ) , n , / = 0 , 1 . . . . , N - l , (28)

where the two-dimensional symmetrical sequence, £(n, l) is defined similar to (4).

3. E x p e r i m e n t a l r e su l t s

The convolution-multiplication property defined in (22) and (23) may be used in filtering the images. A series of computer simulations has been carried out. The source images are 256 x 256 pixels of 'Lena' and 240 x 256 pixeis of 'Baboon' , each with 8 bit resolution. Block size of 8 × 8 is arbitrarily selected. The filters used are the 3 x 3 separable low-pass filter and high-pass filter. Since the filters are separable, they can be separated into two identical one-dimensional filters. The one-dimensional version of the low-pass filter used is as follows:

hLp = (0.25 0.5 0.25). (29)

The one-dimensional version of the high-pass filter is

hHp= (--0.0625 1.125 --0.0625). (30)

Each filter is Fourier transformed by the 16 point DFT. The resulting frequency responses are real and even. The one-dimensional DFT of the low-pass filter is shown in Fig. 1. Figure 2 depicts the one- dimensional DFT of the high-pas filter. The two-dimensional frequency responses are created by multiplication of the one-dimensional versions. The 8 × 8 DCT of the test images are multiplied by the filter matrices. The inverse 8 x 8 DCT is performed. The block diagram for the DCT filtering is shown in Fig. 3. The original images are shown in Fig. 4. Figure 5 shows the low-pass filtered images using (27). The high-pass filtered images using (27) are shown in Fig. 6. The spatial linear convolution is conducted as the reference case. The results of the spatial low-pass and spatial high-pass filtering are shown in Figs. 7 and 8 respectively.

Vol. 19, No. 3, March 1990

Page 6: Discrete cosine transform filtering

DFT of low-pass filter (0.25 0.5 0.25) 1.2

A v " I -

A .lg "r

1.0'

0.8'

0 .6-

0.4'

0.2'

0.0 I I I I

0 1 2 3 4 i i 5 6 7

Fig. 1. The one-dimensional DFT of the low-pass filter.

DFT of high-pass filter (-0.0625 1.125 -0.0625) 1.3

1.2

1.1

1.0 I i i i i i i

1 2 3 4 5 6

k

Fig . 2. T h e o n e - d i m e n s i o n a l D F T o f the h i g h - p a s s fi lter.

238 B. Chitprasert, K.R. Rao / Discrete cosine transform filtering

D i g i t a l COSINE FILTER ~ COSINE i m a g e TRANSFORM I } TRANSFORM

Fig. 3. Block diagram of the discrete cosine transform filtering.

4. Conclusions

In image processing, several operations are performed on sub-blocks of data. If the filtering in the DCT domain is required and the filter frequency response is real and even, then the filtering operation can be approximated by multiplication in the spectral domain. The resulting spatial operation is not the N-point circular convolut ion o f the original sequence and the filter sequence. It is the 2N-point circular convolut ion of the folded sequence and only N points of the convolut ion are used. By doing this, the aliasing of the circular convolut ion is likely to reduce due to the continuity of the folded sequence (in comparison to N-point periodic sequence). It can be seen from the experiments that the results are close to those of the linear convolution. DCT filtering may be applied to noise suppression or image enhancement.

Signal Processing

Page 7: Discrete cosine transform filtering

B. Chitprasert, K.R. Rao / Discrete cosine transform filtering 239

Fig. 4. The original images.

Vol, 19, No. 3, March 199(I

Page 8: Discrete cosine transform filtering

240 B. Chitprasert, K.R. Rao / Discrete cosine transform filtering

Fig. 5. The low-pass filtered images using (27).

Signal Processing

Page 9: Discrete cosine transform filtering

B. Chitprasert, K.R. Rao / Discrete cosine transform filtering 241

Fig. 6. The high-pass filtered images using (27).

Vo[. 19, No. 3, March 1990

Page 10: Discrete cosine transform filtering

242 B. Chitprasert, K.R. Rao / Discrete cosine transform filtering

Fig. 7. The low-pass filtered images using linear convolution.

Signal Processing

Page 11: Discrete cosine transform filtering

B. Chitprasert, K.R. Rao / Discrete cosine transform filtering 243

Fig. 8. The high-pass filtered images using linear convolution.

Vol. 19, No. 3, M a r c h 1990

Page 12: Discrete cosine transform filtering

244

Acknowledgment

B. Chitprasert, K.R. Rao / Discrete cosine transform fihering

The authors would like to thank the engineers at Compressions Labs, Inc. who have reviewed this paper and have provided helpful comments. Special thanks are due to Dr. W. H. Chen who has permitted the use of computers and display devices.

Appendix A

The relationship between the DCT and DFT is described in this appendix. The DFT of a real symmetrical sequence of length 2N can be written as

1 s-, [-j2wnk'~ 2 F ( k ) = ~ . = _ N E ~ ( n ) e x p ~ ) , k = - N , - N + I , . . . , N - 1 ,

where

~x(n), n =0, 1,..., N - 1, x(n)=[x(-1-n), n = - N , - N + I , . . . , - 1 .

The summation in (A.1) can be split in two terms, i.e.,

' { ( ) ex -j2Trnk N-1 x ( - 1 - n ) p ~ + Y~ )(F(k) = ~-~ .=~-N .=o

Let m = - ( n + 1) in the first summation, then

[-j2"rrnk'~ ] x(,)

1 f N , (j2.rr(m+l)k) N I {-j2wnk'~} Xv(k)=-~l~_oX(rn)exp\~--I~ + ~_o x(n) exp ~ - - ~ - - - J •

Combining summation yields

1 (rv-, [exp(j(n+_Nl_).rrk)+exp(_j.nk'~q } XF(k) = 2-N I. ,~-0 x(n) \ - - - - ~ ] j j ,

ex ,

)(F(k) = exp ,}o x( n ) cos .

Multiply (A.5) by 2C(k), to obtain

2C(k) exp\ 2N / = ~ C ( k ) ~0cos ~-1~ j = X c ( k ) ,

for k = - N , - N + I , . . . , N - I , which is (12).

(A.1)

A.2)

(A.3)

(A.4)

(A.5)

(A.6)

References

[1] N. Ahmed, T. Natarajan and K.R. Rao, "Discrete cosine transform", IEEE Trans. Comput., Vol. C-23, January 1974, pp. 90-93. [2] W.H. Chen and S.C. Fralick, "Image enhancement using cosine transform filtering", Image Sci. Math. Syrup., Monterey, CA,

November 1976.

Signal Processing

Page 13: Discrete cosine transform filtering

B. Chitprasert, K.R. Rao / Discrete cosine tran.~form .filtering 245

[3] J.L. Mannos and D.J. Sakrison, "The effects of a visual fidelity criterion on the encoding of images", IEEE Trans. Inform. Theory, Vol. IT-20, July 1974, pp. 525-536.

[4] K.N. Ngan and R.J. Clarke, "Lowpass filtering in the cosine transform domain", lnternat. Conf. on Communi, Seattle, WA, June 1980, pp. 31.7.1-31.7.5.

[5] H.V. Sorensen et al., "Real-valued fast Fourier transform algorithms", IEEE Trans. Acoust. Speech Signal Process., Vol. ASSP-35, June 1987, pp. 849-863.

Vol 19, No. 3, March 1990