Signal Processing 18 (1989) 231-237 Elsevier Science Publishers B.V.
231
PROCESSING OF DIGITAL IMAGES USING PHASE CONTRAST FILTERS R E A L I Z E D AS 2-D IIR F I L T E R S * M.A. SID-AHMED and J.J. SOLTIS Electrical Engineering Department, University of Windsor, Windsor, Ontario, N9B 3P4, Canada
Received 20 January 1988 Revised 11 November 198g and 2 February 1989
Abstract. Phase contrast filters (PCF) are utilized in optical processing systems to enhance objects in images with phase gradients. In this paper a class of PCFs are realized as two-dimensional recursive digital filters. The filters are designed using the least square approach and applied on a variety of images. The digital approach is less expensive and more flexible than the coherent image forming system.
Zusammenfassung. Phasenkontrastfilter (PKF) sind nfitzlich in optischen Verarbeitungssystemen zur Verbesserung von Objekten in Bildern mit Phasengradienten. In dieser Arbeit wird eine Klasse von PKF als zweidimensionale rekursive digitale Filter realisiert. Die Filter werden fiber einen Minimalen Fehlerquadratansatz entworfen und auf eine Vielzahl yon Bildern angewendet. Der digitale Ansatz ist weniger aufwendig und flexibler als das koh/irente Bildformungssystem. R6sum6. Les filtres ~ contraste de phase (en anglais phase contrast filters (PCF)) sont utilis6s dans les syst~mes de traitement optique pour la mis en valeurs d'objets dans des images ayant des gradients de phase. Ce texte d6crit la r6alisation d'une classe de PCF ~ l'aide filtres bidimensionnels r6cursifs. Ces filtres sont calcul6s par une m6thode des moindres carr6s et ont 6t6 appliqu6s h toutes sortes d'images. L'approche num6rique s'av6re moins cofiteuse et plus flexible que les syst6mes /l synth~se d'images coh6rentes.
Keywords. Digital filter, digital image, Fourier transform, phase gradient, Sobel operators.
I. Introduction
and
Phase contrast filters (PCF) have been utilized in optical data processing to render visible an object with phase gradients [3]. A PCF has the function 1, /~(U, V) =
--1
if',/u2+v 2<~ Wc, ifx/uZ+v 2 > we.
(1)
where wc represents the critical frequency. This filter function when expressed in amplitude and phase is given by A(u, v) = 1 * This work was supported by a grant from Natural Science and Engineering Research Council of Canada. 0165-1684/89/$3.50 O 1989, Elsevier Science Publishers B.V.
~b(u,v)= j" O, if~/u-~u2<~o~, -~-, ifx/u2+ v : > ~o~.
(2)
Spatial optical filters can be utilized to implement such a characteristic, however the setup is less flexible and more expensive than a digital implementation. Recursive digital filters can be designed to meet the above specification, allowing greater flexibility in the selection wc and the variations of ~b(u, v) and A(u, v) along the u - v plane. Such filters could be implemented in software, or if real-time processing is required then hardware realization could be utilized [5, 6]. Fig. 1 shows an arrangement for which the PCF can be utilized to emphasize the high frequency
M.A. Sid-Ahmed, J.S. Soltis / Image processing with phase contrast filters
232
x
_1
(n ,m)
Hu,v
+ lYnm' -G
g (n ,m)
g,,,,,-
d,,'-
I
Fig. 1. Image enhancement using a phase contrast filter (PCF).
components in a digital image. The magnitude and phase specifications of the PCF are shown in Fig. 2. The arrangement of Fig. 1 is utilized in the examples presented in Section 4. A digitized version of the original image or scene, x . . . . is passed through an all-pass 2-D digital filter to provide the idealized phase shift shown in Fig. 2. In a circularly symmetric manner, frequencies below a selectable critical frequency toc have 0 ° phase shift, whereas those above Wc suffer n~r of phase shift, where n is odd and is related to the order of the filter. Again, from Fig. 1, this phase filtered image y(n, m) is now subtracted from the original image to produce the resultant g(n, m). A rich flexibility is offered by the selection of toc and the filter order. The above method could be simulated using the FFT algorithm, however, the utilization of 2-D recursive digital filters could provide advantages in computational speed and storage requirement. Since in images the phase carries most of the information [2], and since results reported in the literature on image restoration [1] show that a phase-only image with a constant Fourier transform magnitude results in better restoration than
a magnitude-only image with no estimate of the phase, then it is only reasonable to assume that filtering through phase shaping (PCF) would also yield better results than traditional filtering that operate only on the Fourier transform magnitude and provide a constant group delay.
2. Filter d e s i g n
The design technique utilized minimizes the error between the ideal impulse response, obtained from the magnitude and phase specifications, and the general case impulse response of a 2-D digital filter of order N. With magnitude and phase specified over the entire frequency plane the impulse response is immediately attainable. The filter frequency response can be separated into real and imaginary components R and I, and discretized by sampling over the wl-w2 plane as R (w,,,, w2,,) } I (w,,,,
oa2~,) - u,
v = 0, 1, 2 , . . . ,
K - 1,
where K is the number of samples taken over w~ and 0)2 with the sampling increment equal to ~r/K.
IH(u,v) I = Arg (H(u,v))
1.
I I I I
I
Tr
[@(u,v) ~
- n'n"
CO C
D(u,v)
D(u,v) = (u2+v2) 1/2
Fig. 2. Magnitude and phase characteristics of H(u, v). Signal Processing
(3)
11" i
D(u,v)
M.A. Sid-Ahmed, J.S. Soltis / Imageprocessingwithphase contrastfilters TO obtain the impulse response h(n, m), the inverse FFT is applied to H(to~,,, w2o). For simplification let (4) U ~ 031u , /.)
=
The general equation for a 2-D digital filter of order N is given by
H(z,, z2)
Y(zl, z2) =
X(z,, z2)
(5)
(O2v ,
N
N
E E
therefore
a O z l - ' z 2-j
i=Oj=O
H(u, v) = R(u, v) + j I ( u , v).
N
(6)
In order to guarantee that h(n,m) is real, the condition that H ( u , v) be Hermitian symmetric [2] must be met. The Hermitian symmetry conditions are given by R(u, v) = R ( K - u, K - v),
(7)
I(u, v) = - I ( K - u, K - v),
(8)
R(u +½K, v ) = R(u, K - v ) ,
(9)
with boo = 1.
N
E E boz~-' z2-j
i=0j=0
(11) The 2-D difference equation for y(n, m) can be written as N
I(u +½K, v) = - I ( u , K - v),
233
N
y(n,m)= ~ ~ aox(n-i,m-j) i=0 j=0 N
N
- E ~ b~y(n- i, m - j ) .
(10)
(12)
i=0j=0
i+j¢O
for u,v=O, 1 , 2 , . . . , ½ K - 1 . H(u, v) is defined over an array of size K x K. In order to maintain the desired H(u, v) and the required symmetry conditions, H(u, v) must be extended to size P x P where P = 2K. The extended array is shown in Fig. 3. Quadrant 1 contains the original K × K samples of H(u, v). Quadrant 3 is obtained by applying (7) and (8) with K replaced by P = 2K. Quadrant 2 is a mirror image of 1, and quadrant 4 is obtained by the application of (9) and (10) with K replaced by P=2K. The result of the application of the I D F T to the extended array is a real impulse response of size P x P. However, the desired ideal K x K impulse response is contained in the first K x K samples of the P × P array. K-I
2K-I
To obtain the impulse response of the general case the input becomes
x(n, rn)--> 6(n, m), where 6(n, m) is the 2-D unit impulse 1, 0,
6(n, m ) =
K-I
E= E
K-1
E [ h ( n , m ) - h l ( n , rn)]2,
n~O m=O
therefore K-1
K-I
ao6(n - i, m - j )
E
n~O m=0 4
(13)
An error function E is formed between the ideal impulse response, denoted h~(n, m), and the general case impulse response
E=E l
n=m=O, otherwise.
i=0j=0 N
N
- Z ~ b•hl( n - i , m - j )
K-I
i=Oj=0
2
3
2K-I
Fig. 3. Extended response for H(u, v) to obtain Hermitian symmetry.
- hi(n, m)]2.
(14)
Minimization of the error function E requires obtaining the partial derivatives with respect to the coefficients % and bo. E is minimum when its VoL 18, No. 3, November 1989
234
M.A. Sid-Ahmed, J.S. Soltis / Image processing with phase contrast filters
derivatives with respect to the cofficients are equal to zero. The result of the above process is a 2 ( N + 1) 2 - 1 system of linear equations which can be solved for the coefficients a0 and b~. When solving the linear set of equations the assumption of a causal system is used, that is,
h(n,m)=O,
for n or m < 0 .
(15)
The question of stability of the filter is addressed prior to the design. The impulse of the desired filter is displayed c~ver a mesh of 128 × 128. If the impulse decays to very small values as n a n d / o r m approaches 128, the assumption is made that the filter designed by the above method will be stable. The final proof, however, lies in applying the designed filter to various images. The PCF technique is accomplished by applying the designed filter H(u, v) to a digital image x(n, rn) of size SxS. The filtered image is expressed as N
N
y(n,m)= ~ ~ aijx(n-i,m-j) i:Oj:O N
N
- • Z b~y(n-i, m-j), i=oj=o i+j¢O
n,m=O, 1 , 2 , . . . , S - 1 .
(16)
The enhanced image g(n, m) is obtained by taking the absolute value of the difference between the original image and the filtered image, (see Fig. 1).
g(n, m)=[ y(n, m)-x(n, m)I, n, m = 0 , 1 , 2 , . . . , S - 1
(17)
3. Results of the design approach The filter design technique presented in the previous section was used to design filters of various orders. The coefficients for a first order filter are shown in Table 1, for selected values of toc. Signal Processing
Table 1 Filter coefficients u s e d for t h e P C F t e c h n i q u e
aoo aol alo art boo bol blo bll
w c = 1.0
toc = 1.75
-3.095840 2.396338 2.396338 1.553688 1.0 -0.616835 -0.616835 0.446490
- 1.634320 1.328521 1.328521 -0.237538 1.0 -0.224075 -0.224075 0.252944
4. Results of filtered images The results obtained in this section utilizes the block diagram of Fig. 1. Fig. 4(a) shows a portion of a chest X-ray. Fig. 4(b) is the result obtained after filtering using the PCF with toc= 1.0 and whose coefficients are given in Table 1. Fig. 5(a) shows the original image of the top surface of a car piston head. Fig. 5(b) is the filtered image using an IIR PCF filter (tOc= 1.0), which clearly delineates the surface finish. It is interesting to note that both results (Figs. 4(b) and 5(b)) were obtained with just a first-order IIR PCF filter. Fig. 6(a) is a binary image of some Arabic letters. Fig. 6(b) is the filtered image using the first order IIR PCF filter of Table 1 (toc= 1.75). In this image the borders of the various letters have been extracted. Fig. 7 shows a comparison between the Sobel operators and PCF with oJc = 1.4 for edge extraction. It is clear that the PCF provides a finer edge than the Sobel operator. Figs. 4 and 6 are digitized image of size 512 x 512 pixels. Figs. 4 and 5 have 256 possible gray levels (8 bits/pixel). A PCF realized as 1 × 1 recursive digital filter requires seven multiplications/pixels, and one scan of the image to achieve the final result. Sobel operators, which are a form of matched filtering, requires less operations but, however, do not offer the flexibility that a PCF does. The PCF offers the flexibility of adjusting toc to obtain the desired
M.A. Sid-Ahmed, J.S. Soltis / Image processing with phase contrast filters
235
i! i
Fig. 4. (a) A portion of a chest X-ray. (b) Enhanced image using a phase contrast filter (PCF) with toc = 1.0.
Fig. 5. (a) Top surface of a car piston head. (b) Enhanced image of Fig. 5(a), using a phase contrast filter (PCF) with toc = 1.0. 5. Other PCF specifications
result. A variety of results, which range from image enhancement (Figs. 4 and 5) to edge extraction (Fig. 6) demonstrate the advantage of having such a flexibility not offered by matched filtering, toc could be adjusted to yield thinner edges than the Sobel operators as demonstrated in Fig. 7. Both types of filtering (match or PCF) can be made to operate in real time (30 frames/sec for a 512 x 512 pixel image) by either realizing them in hardware [5, 6], or simulating them on a computer designed specifically for image processing such as the C L I P 4 [4]. The images presented in this paper were filtered on an 8 M H z I B M - A T with a frame grabber, and required about 1 min. of execution time for images of size 512 x 512 pixels.
Apart from the PCF specified in Fig. 2, one could select various other types of phase specifications to yield in the arrangement of Fig. 1 such filters as band-pass, band-reject, etc. Figs. 8(a) and 8(b) show the phase specifications for a band-pass type filter and a band-reject type filter respectively. Such specifications could be realized as I I R filters and implemented via software or hardware realization.
6. Conclusion Digital phase contrast filters have been designed as I I R filters and implemented on a variety of images. The digital approach offers flexibility and Vol. 18, No. 3, November 1989
236
M.A. Sid-Ahmed, J,S. Soltis / Image processing with phase contrast filters
b Fig. 6. (a) Arabic letters. (b) Enhanced border of Fig. 6(a), using a phase contrast filter (PCF) with toc= 1.75.
Fig. 7. (a) Original image. (b) Imaged processed by Sobel operators. (c) Image processed by a phase contrast filter (PCF) with toc = 1.4. Signal Processing
M.A. Sid-Ahmed, J.S. Soltis / Image processing with phase contrast filters
237
IT
(u,v)
oJ c2 /~
c1
T i
~--
2
a
¸
7T
~b (u,v)
~0 cI
W
T c2
0 -I I
:~ 7r
i
b Fig. 8. (a) Phase specification for a band-pass type filter. (b) Phase specification for a band-reject type filter.
ease of implementation unattainable by the optical
processing scheme. Digital filters can easily be designed to approximate specifications of PCFs by a least-squares fit approach. Acknowledgment The authors wish to thank M. Srdanovic for his assistance in developing the computer program for designing 2-D filters.
References
[2]
T.S. Huang, J.W. Burnett and A.G. Deczky, "The importance of phase in image processing filters", IEEE Trans. Acoust.. Speech, Signal Process. Vol. 23, No. 6, December 1975. [3] A.W. Lohmann and D.P. Paris, "Computer generated spatial filters for coherent optical data processing", Appl. Opt., Vol. 7, No. 4, April 1968, pp. 651-655. [4] K. Preston and M. Duff, Modern Cellular Automata, Theory and Applications, Plenum Press, New York, 1984. [5] A. Shah, M.A. Sid-Ahmed and G.A. Jullien, "A proposed hardware structure for 2-D recursive digital filters using RNS", IEEE Trans. Circuits Syst., Vol. CAS-32, March 1985, pp. 285-289. [6] M.A. Sid-Ahmed, "Serial architecture for the implementation of 2-D digital filters and for template matching in digital images", 30th Midwest Syrup. Circuits Syst., August 1987.
[1] D.E. Dudgeon and R.M. Mersereau, Multi-Dimensional Digital Signal Processing, Prentice Hall, Englewood Cliffs, N J, 1984. Vol. 18, No. 3, November 1989