AN EFFICIENT IMPLEMENTATION TECHNIQUE OF ADAPTIVE MORPHOLOGICAL OPERATIONS S. FEJES and F. VAJDA
Department of Information Technology, KFKI Research Institute for Measurement and Computing Techniques of the Hungarian Academy of Sciences, P.O.Box 49, 1525 Budapest, Hungary.
Abstract. In the paper the implementation aspects of mathematical morphology based on a new
formalization of the window operation is presented. The proposed technique called the Reverse Window Operation (RWO) can also be applied to adaptive morphological operations. In order to reduce the control complexity an algorithm is proposed, which uses a region-based parameter modi cation for the structuring element adaptation. Finally, an application of a data-dependent processing technique using the adaptive lter scheme is demonstrated.
Key words: Mathematical morphology, Adaptive ltering, Reverse window-operation, Envelope scan method, Control region optimization, Region-based parameter adaptation.
1. Introduction Facing with challenges related to image processing the problems are multifold. Even if an ecient algorithm is already available, an ecient implementation has to be also used in many applications. Due to the large amount of data to be processed and the often strict time constraints (real time applications) only dedicated architectures can count. Therefore, the special relationship between the algorithms and the architectures needs a totally new approach and technology of the design phase. In the rst section of the paper a brief overview is given on the dominant elements of adaptive ltering and its applications to morphological operations. The next section presents an ecient implementation for morphological operations. Based on a noval alternative of the window operation (Reverse Window Operation, RWO [1]) and a technique called the Envelope Scan Method (ESM, [2]) an architecture is proposed for both binary and gray scale operations. The proposed architecture can directly support exible adaptation of the Structuring Element (SE). It is discussed in the fourth section in details. In this section an algorithm is also introduced providing a reduction method of the number of control parameters (" lter taps"). In the last section an input data-driven lter scheme is demonstrated.
2. Adaptive Techniques in Morphological Processing Adaptive ltering is a favorable tool for advanced data processing. The adaptive approach is able to deal with unknown statistics of the signal, which can be very
THIS WORK WAS PARTLY SUPPORTED BY OTKA GRANT NO. T4044.
S. FEJES AND F. VAJDA tn
t n+1
tn
α
a.)
t n+1 β
"inactive"pixel in a window pixel under read operation pixel under write operation
b.)
Fig. 1. Window operations: the traditionalscheme (a) and the Reverse Window Operation (RWO) (b).
useful when dealing with extremely variant signal/image environment, such as noise ltering, image enhancement, etc. Nonlinear lters (stack lters, such as median lters, rank-order lters or morphological lters, etc.) with adaptive features has been becoming a new area in addition to the traditional adaptive linear ltering. Morphological lters belong to a special class of stack lters. They can be characterized by the properties of threshold decomposition, stacking, idempotence and increasing operators [3, 4, 5, 6]. Adaptive approach in morphological processing can be de ned on several levels. The elementary adaptation step may refer to individual pixels, regions or even pictures, as well. Each form of adaptivity provides dierent grade of adaptive behavior. On the other hand, as far as the adaptation process is concerned there are two main approaches. According to the rst one, a training set is used to get the optimal ltering for a given type of data. In this case the input is supposed to be stationary, which may be a strong restriction to many applications. In contrast, the second method is applied to run-time data, i.e., the lter is continuously optimized to the current statistics of the input. In addition, data-driven techniques can also be interpreted as special cases of adaptive processing. According to this scheme, the parameter is not adjusted by the error signal deduced from the dierence between the output and a reference signal, but by the input itself.
3. Implementation of Morphological Operations 3.1. Alternative Formulation of the Window Operations
Many image manipulation techniques are based on window operations [7], in which a certain region of pixels is scanned and according to a window function one output pixel is generated. As an alternative form of the window operation, the Reverse Window Operation (RWO, [1]) scans only one central pixel, upon which the new value of a whole region is de ned taking into account the template (window) function (see Fig. 1.). Although, the two methods are not equivalent in a stricter sense, both can be applied to morphological operations. Considering e.g. the Minkowski addition (dilation) X B = maxfxi?j + bj ; jB g; (1) which can be directly represented by Fig. 1.a, if the window function represents the fmaxg operation. In contrast, using the RWO-scheme the fmaxg operation becomes
IMPLEMENTATION OF ADAPTIVE MORPHOLOGICAL OPERATIONS
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
Fig. 2. The proposed systolic array based on the RWO-principle. The operation is a Minkowski addition (dilation) using at SE
unnecessary. It is due to the fact, that the consecutive write operations superimpose each other in the sense that a smaller value cannot overwrite a greater one. The same principle can be applied to the Minkowski subtraction (erosion) considering the duality principle of erosion and dilation. 3.2. Implementation of the Binary Morphological Operations
Using a systolic array [8] an ecient implementation of morphological operations can be obtained based on the RWO-principle. In binary case, the function of the
at SE is represented by OR-gates (at dilation) or AND-gates (at erosion) inserted into the data-path according to the binary template of the SE (see Fig.2). 3.3. Gray Scale Operations
The threshold decomposition of morphological operations can make it feasable to de ne an architecture for gray scales by combining several layers of the binary array. Applying the Envelope Scan Method (ESM, [1, 2]) the number of elementary operations can be strongly reduced. This method is based on the fact that the operations have to be calculated only on the envelope of the gray scales. It can be proved, that the operations on internal (lower) gray levels, i.e., not on the top surface, have no eect on the output. To force the SE hover on the top gray level a template control unit has to be connected to the le of binary systolic arrays. On each layer the cross section of the SE's template (or umbra under a given altitude) is partitioned into regions. Each region corresponds to a given gray level of the 3D SE. They have to be activated on every layer by one according to the required "altitude", which is de ned by the top surface of the pixel currently being read. This pixel position should correspond to the reference point of the SE. When dealing with several gray levels the global control line of a binary layer (Fig.2) is split into several region activation lines (see also Section 4.3) to achieve the proper template control.
S. FEJES AND F. VAJDA
4. Adaptation of the Structuring Element According to the general scheme the adaptive approach tries to optimize the lter parameters to minimize the given error criterion (e.g., Mean Square Error (MSE) or Mean Absolute Error (MAE), [9, 3]). At morphological operations the most obvious way of adaptation is the optimization of the Structuring Element (SE). Let us investigate the algorithm of the Least Mean Squares (LMS), dyi ; b0i = bi + 2(di ? yi ) db
(2)
j
where bj stands for the parameter to be optimized, b0j represents the new value, is the convergence parameter, yi and di denote the output and the reference signal, dy has to respectively. Foe example at the Minkowski addition (Eq.1) the gradient db be computed for the maxfg operation, which in turn, cannot be directly applied. In order to solve this problem the relationship between the input and the output of a morphological processing scheme has to be investigated in terms of a gradient. Using the de nition of the Equation 1 with a small modi cation: i j
yi = xi?m + bm , where m 2 B;
(3)
where m is the index of the element, which causes the summation term to reach its
maximum, it can be concluded, that
dyi = 1 if j=m 0 otherwise dbj
An exact mathematical proof of the problem can be found in [9]. Finally, from Equations 2 and 3 it is obvious, that b0m = bm + 2(di ? yi ) and b0i = bi , where m 6= i:
(4)
It shows, that the application of the LMS for morphological operation can be expressed in a very simple form. Referring to [9] again, an algorithm is proposed for the adaptation of at SE. According to this method the adaptation of the at SE can be treated the similar way as that of the 3D, but the parameters have to be normed to binary values "0" or "1". 4.1. The Adaptation Algorithm using the RWO
The architecture proposed in Section 3 can be extended to adaptive operations, however, the RWO-principle does not support individual parameter adaptation. On the contrary, the adaptation based on a RWO-scheme should be applied rather to regions introduced in Section 3.3. The use of regions can be useful to reduce the control complexity of the adaptation algorithm. Therefore, a systematic method has to be found to de ne the parameter control regions of the given adaptive morphological operation.
IMPLEMENTATION OF ADAPTIVE MORPHOLOGICAL OPERATIONS
4.2. Reducing Control Complexity of Morphological Operations
In order to reduce the degree of freedom of the lter parameter control a training set of the input data has to be investigated. During the adaptation process the individually, but "nearly" identically controlled lter parameters could be adjusted as a whole. Before de ning an algorithm for the parameter partitions the basic notations have to be introduced. Let B be the support of the SE with N*N individual parameters. I order to assemble all important data about the parameter modi cation the variations of the SEs templates have to be investigated. Therefore, the parameter settings of the "fundamental" structuring elements that can be the most important from the adaptation point of view are recorded. Let B be denote the set of these SE'. Furthermore, the row vector bTi consists of the individual parameter settings of each SE in the following way: bTi = (bi;1; :::bi;N 2 ), where bTi 2 B and i = 1; : : :; n: (5) Our nal goal is to de ne the set P of partitions Rk in a way, that if Rk 2 B, then Rk \ Rl = ; ,if k 6= l, where k; l = 1; : : :; nR; (6) i.e., the regions (partitions) have to be disjunct sets included by the support. nR denotes the number of regions obtained by the partitioning process. In order to unify individual lter parameters into a region their activation, i.e., the coincidence of their activation has to be taken into consideration. Therefore, let us introduce the dierential matrix Di by the following de nition: Di = [dkl]i, where dikl = (bik ? bil )2 , and k; l = 1; : : :; N 2: (7) The ith dierential matrix describes the coincidence of each parameter activation of the ith SE template. However, not one but all the SE templates have to be taken into consideration to obtain the region partitioning valid for the whole adaptation process. Consequently, of each element of the set fDi g the maximum has to be selected at a parameter position to get a statistics for the series of the SE templates considering the deviation of the activation of the given parameter pair: = [kl ] = [kT ], where kl = maxfdikl g, i = 1; : : :; n: (8) Taking Equations 5-8 the rule of the region partitioning can be formalized. Let p and q be two parameter locations in the support B. In addition, P = fRk g denotes the region distribution at an error limit of . Then 8p; q 2 Rk , if and only if pq < : (9) According to Equation 9 a simple algorithm can be constructed to partition the parameter locations (the individual supports) into regions. As far as the optimal distribution of the regions is concerned, there seems to be no analytical guarantee to reach the optimum concerning the possible least number of regions that meets the error criterion . In order to get better results special techniques, such as e.g. simulated annealing could also by applied.
S. FEJES AND F. VAJDA
Fig. 3. The region optimization process of 3D SE. The individual SE parameters (on the left) have been merged into regions according to error limits 1 and 2 , respectively.
The scheme of the partitioning for 3D SEs is showed in Fig.3. The error level determines the granularity of the regions. The higher the error limit is the less number of regions can be created, but of course, with less accuracy and convergency of the adaptation process. As far as the stability of the region-controlled adaptation is concerned the study of the convergency behaviour in terms of the error limit is currently in the focus of further researches. 4.3. An Architecture for Adaptive Morphological Operations
The architecture proposed in Section 3 can be applied to adaptive operations with special care. The relationship between the output and the input of an operation based on the RWO-principle is not known. Therefore, additional identical arrays called region activation pipelines have to be added to the original scheme (see Fig.4). Each activation pipeline is assigned to one control region of the at SE or to that of a cross section in case of a 3D SE. The pipelines have no pixel input, their outputs are determined solely by the activation of the region they have been assigned to. Receiving a pixel at the output of the processor array the current value(s) of the binary region activation pipeline(s) signalize the region(s), by which the current pixel was resulted (see also Equation 3). These outputs are then processed by the adaptation unit, which activates the selected regions by feeding back the error signal to close the adaptation loop. Extending the architecture to 3D SE the output becomes a vector y i of the individual decision values of each binary layer according to the threshold decomposition principle. In this case, however, the output must obey the stacking constraint, therefore, the adaptation algorithm supervises each individual output bit. In [3] an operation called Swap is proposed to enforce the output according to the constraint. If an output bit violates the rule, i.e., yik < yil ; if k > l, then a swap operation is executed. It is continued until no output bit violates the constraint. Unfortunately, this algorithm can be complex and time consuming in case of large number of gray levels. Therefore, more simple methods (e.g. correction of the constraint violation
IMPLEMENTATION OF ADAPTIVE MORPHOLOGICAL OPERATIONS
Fig. 4. The basic binary processor array is extended with 3 region activationpipelines to book-keep the source of the current output. 0 and 1 are currently being activated, while 2 is inactive.
by simple overwrite operation) could also be applied. However, in these cases a strongly decreased convergency may have to be considered.
5. Applications on Images In Fig.5 a special application of adaptive lters (it can also be referred to as open loop adaptation scheme) is presented. A camera picture sequence of street trac (left top) has been recorded. Following the extraction of the foreground (i.e., vehicles in the selected trac lane) a sophisticated segmentation can be obtained by a maskdriven "open loop adaptation" [10]. The modi cation of the size of the SE (disc) is performed by a region-controlled adaptive lter using an input mask. The size of the applied SE has to correspond to the sizes of the objets decreasing by the distance to obtain optimal solution. In contrast, elementary operations would need a number of steps to gain the same result.
6. Conclusions Adaptive morphological operations have been studied concerning implementation aspects. A new implementation and adaptation scheme has been proposed using the principle of the Reverse Window Operation. This alternative formulation of the window operation provides not only an ecient implementation for "stationary" morphological operations or operation sequences, but it can also support adaptive applications. In order to reduce the control complexity of the adaptation process a systematic method has been presented for the reduction of the parameter space. According to this method a region-based parameter control is applied. Finally, an application of a data-driven morphological operation is demonstrated using the proposed region-based lter scheme.
References 1. S. Fejes and F. Vajda. New pipelined image processor for morphological operations. In Proceedings of the Workshop on Design Methodologies for microelectronics and signal processing,
S. FEJES AND F. VAJDA
Fig. 5. Input data-drivenapplicationof an adaptive lter based on region-basedparametercontrol. The input image (top left), the extracted foreground (top right), the input mask (bottom left) for the size-control of the SE (closing) and the properly segmented vehicles (bottom right). pages 63{71, Gliwice-Cracow, Poland, October 20-23 1993. 2. F. Vajda and S. Fejes. An ecient morphology architecture. Orlando, Florida, April 4-8 1994. Signal Processing, Sensor Fusion and Target Recognition III of the SPIE's International Symposium on Optical Engineering and Photonics in Aerospace Sensing. 3. T.M. Sellke J.H. Lin and E.J. Coyle. Adaptive stack ltering under the mean absolute error criterion. IEEE Trans. Acoust., Speech, Signal Processing, ASSP-38(6):938{954, June 1992. 4. J. Serra. Image analysis and mathematical morphology, volume 1. Academic Press, 1982. 5. J. Serra, editor. Image analysis and mathematical morphology, volume 2. Academic Press, 1988. Theoretical advances. 6. P. Maragos and R.W. Schafer. Morphological lters - part i. and ii. ... IEEE Trans. Acoust., Speech, Signal Processing, ASSP-35:1153{1184, 1987. 7. F. Vajda. Application and implementation of window-based image processing algorithms. Microprocessing and Microprogramming, 30:447{454, 1990. 8. S.Y. Kung. VLSI array processors. Academic Press, 1988. 9. P. Salembier. Structuring element adaptation for morphological lters. Journal of Visual Communication and Image Representation, 3(2):115{136, June 1992. 10. S. Fejes and Z.Fazekas. Digital image processing in trac control. KFKI Internal Report, March 1994.