FILTER FOR DILATION AND EROSION OF IMAGES

Abstract: The invention relates to a filter for applying dilation and/or erosion operations of mathematical morphology to a W x H local neighbourhood, the width of which is W and the height H, of a two-dimensional matrix formed by discrete values, the width of which matric is x and the height y. In order to provide an operation in real time by means of a very simple structure, the filter comprises a horizontal portion for applying a dilation/erosion operation to a W x 1 local neighbourhood made to slide over the matrix and a vertical portion for applying a dilation/erosion operation to a 1 x H local neighbourhood made to slide over the matrix, whereby the portions are connected one after another, the output (MINW, MINH) of one portion being connected to the input (IH, IV) of the other portion.

Description: FILTER FOR DILATION AND EROSION OF IMAGES The present invention relates to a filter for ap¬ plying dilation and/or erosion operations of mathematical morphology to a x H local neighbourhood, the width of which is and the height H, of a two-dimensional matrix formed by discrete values, the width of the matrix being x and the height y. Mathematical morphology is a formal method of shape representation and analysis. Basic operations thereof are erosion and dilation, by chaining of which in a suitable manner it is possible to provide e.g. effec¬ tive and usable image processing methods. For instance, many applications of computer vision, such as pattern recognition, are based on the use of morphological opera¬ tors. In mathematical morphology, the basic operations process the image by means of so-called structuring ele¬ ments. A structuring element is a neighbourhood in which an operator is effective. In gray-scale morphology, dila¬ tion stands for the maximum of the local neighbourhood defined by the structuring element and erosion stands for the minimum, respectively. Basic data to be processed has been arranged in the form of a matrix, in which each line comprises x samples and the total number of lines is y. In the fol¬ lowing example, the dilation and erosion operations for basic data of the size of x=6 and y=6 are examined. The local neighbourhood is rectangular with the dimensions W=3 and H=3, where W is a horizontal and H a vertical dimension. Table 1. Erosion and dilation operations performed on basic data in neighbourhood 3*3 Basic data Erosion performed Dilation performed on basic data on basic data Traditionally, operators are realized by means of the structure of Figure 1. It comprises delay means D connected one after another to form horizontal lines, each line comprising delay means, which lines, H in number, are chained one after another in such a way that between each horizontal line is connected a delay line, the length of which is (X-W) times the delay of one delay means D. In this structure, a processing means has to be connected to each delay means D of each horizontal line, whereby the processing means has to compare WxH values with each other to find the minimum/maximum value de- sired. Thus the processing means will be quite compli¬ cated and therefore also slow. An image processing unit realized in this manner in principle is disclosed e.g. by U.S. Patent Specification 4 692 943. To solve the problems attached to such prior art filter structures and caused especially by difficulty of extension, complexity of structure and consequent slow operation, the filter of the invention is characterized in that it comprises a horizontal portion for applying a dilation/erosion operation to a x 1 local neighbourhood made to slide over the horizontal lines of the matrix and a vertical portion for applying a dilation/erosion oper¬ ation to a 1 x H local neighbourhood made to slide over the vertical lines of the matrix, whereby the portions are connected one after another, the output of one por¬ tion being connected to the input of the other portion. In this filter structure of the invention, basic data x*y is processed by a dilation or erosion operation in a local neighbourhood *H, which is made to slide over the basic data x*y. According to the method, the opera¬ tions of dilation and erosion are performed in such a way that the maximum (dilation) or the minimum (erosion) is at first searched for in a local neighbourhood *l (hori¬ zontal portion). In the result obtained in this way, the maximum (dilation) or the minimum (erosion) is then searched for in a local neighbourhood 1*H (vertical por- tion) . The performing order of the horizontal and verti¬ cal portions can also be reverse. To visualize the function of the filter, the func¬ tion of a horizontal operator performing the minimum op¬ eration (erosion) is examined as an example. The function is described in table 2. The uppermost horizontal line presents an incoming data stream delayed by one clock period (=MIN1), in which stream the minimum is searched for in a neighbourhood 5*1 in this case. Each line rep¬ resents the minimum value of a certain neighbourhood, which value can be calculated in the manner presented in the table. The arrows show from which values the minimum value is generated each time. The columns again show the situation at a certain moment. The table presents the operations required for the calculation of three succes- sive minimum values. Table 2 Operating principle of a horizontal minimum (erosion) filter operating in neighbourhood 5*1. In the method, the minimum is searched for in suc- cessive samples n, n+1, n+2, n+3, ... , n+(W-l). Sample n (= minimum in neighbourhood 1*1 = MINI = MIN{n}) is received by the input of the horizontal por¬ tion at a moment t, sample n+1 at a moment t+1 etc. Dur¬ ing t+1 the minimum is calculated from the samples n and n+1 and the result is the minimum in neighbourhood 2*1, i.e. MIN2 (=min{MINl,n+l} = min{n,n+l}). During t+2 the minimum is calculated from the samples n+2 and MIN2 and the result is the minimum in neighbourhood 3*1, i.e. MIN3 (=min{MIN2,n+2} = min{n,n+l,n+2}) . Correspondingly, dur- ing t+3 the minimum is calculated from the samples n+3 and MIN3 and the result is the minimum in neighbourhood 4*1, i.e. MIN4 (=min{MIN3, n+3}= min{n,n+l,n+2,n+3}) . By continued analysis the minimum is reached in dimension *l, where W is the horizontal dimension of the neigh- bourhood (W=5 in the example above). Because at the moment tO the minimum operations MINI(tO) = min{n+t0} MIN2(tO) = min{MINl(t0-l),n+t0} MIN3(tO) = min{MIN2(tO-l) ,n+t0} MIN4(tO) = min{MIN3(tO-l),n+tO} MINW(tO) = min{MIN( -l) (tO-1) ,n+t0} can be performed in parallel (n+tO = sample at the moment tO) , the operations can be performed by means of the hor¬ izontal portion, which is characterized in that it com¬ prises operator elements connected one after another, eaca of which operator elements consists of one comparing means and one delay means, the output of the delay means of- a preceding operator element being connected to the first input of the comparing means of the following op¬ erator element and the input of the horizontal portion being connected to the first input of the comparing means of the first operator element and also to the second in¬ put of the comparing means of each operator element, whereby the output of the Wth operator element forms the output of the horizontal portion. The operations can thus be performed in real time in such a way that the minimum in the local neighbourhood W*l is obtained at the end of the chain in each clock period. Operations to be per¬ formed at the moment tO are described in table 3. Table 3 Operations to be performed at the moment tO to-i to to+i On the other hand, the vertical operation can be performed by means of the vertical portion, which is characterized in that it comprises H operator elements connected one after another, the output of the delay means of a preceding operator element being connected to the first input of the comparing means of the following operator element, whereby the output of the Hth operator element forms the output of the vertical portion, and H delay lines with x+1 delay means connected one after another, the input of the vertical portion being con¬ nected both to the first and the second input of the com¬ paring means of the first operator element and also to the input of the first delay line and the output of each delay line being connected both to the second input of the comparing means of the following operator element and to the input of the following delay line. The function of the vertical portion is visualized in table 4. The uppermost horizontal line shows the in¬ coming data stream (from the horizontal portion) delayed by one clock period (=MIN1). In this table, the minimum (erosion) in neighbourhood 1*5 is searched for. Each line presents the minimum in a certain neighbourhood, which can be calculated in the manner shown in the table. The arrows show the route of the data stream leading to the calculation of the first neighbourhood 1*5. Table 4 Operating principle of a vertical minimum (erosion) fil¬ ter operating in neighbourhood 1*5 a) data to be processed • .Reference vector at moment tO in table 5 Reference vector in table 4 b) b) processed data In the method, the minimum is searched for in the samples n, n+x, n+2x, n+3x,..., n+(H-l)x to be obtained from the horizontal portion, where H is the vertical di¬ mension of the neighbourhood (H=5 in example above) and x is the line length of the data to be processed. Sample n is received by the input of the vertical portion (= minimum in neighbourhood 1*1 = MINI = min{n}) at the moment t, sample n+x at the moment t+1 etc. During t+1 the minimum is calculated from the samples n and n+x and the result is the minimum in neighbourhood 1*2, i.e. MIN2 (= min{MINl,n+x} = min{n,n+x}). During t+2 the mini- mum is calculated from the samples n+2x and MIN2 and the result is the minimum in neighbourhood 1*3, i.e. MIN3 (= min{MIN2, n+2x} = min{n,n+x,n+2x}) . By continued analysis the minimum is reached in neighbourhood 1*H. Because at the moment tO the minimum operations MINI(tO) = min{n+t0} MIN2(tO) = min{MINl(t0-l) ,n+t0+x-l} MIN3(tO) = min{MIN2(tO-l),n+tO+2(x-l)} MIN4(tO) = min{MIN3(tO-l),n+tO+3(x-l)} • • • MINH(tO) = min{MINH-l(tO-l) ,n+tO+(H-l) (x-1)} can be performed in parallel (n+tO = sample at the moment tO), the operations can be performed in real time. The minimum in the local neighbourhood 1*H is obtained at the end of the chain in each clock period. Operations to be performed at the moment tO are described in table 5. Table 5 Operations to be performed at the moment tO to-i to to+i The horizontal and vertical portions based on the minimum operation have been discussed above, which por¬ tions perform together the operation of erosion of math¬ ematical morphology in neighbourhood W*H. A maximum op¬ erator performing dilation can also be subjected to a similar examination. Dilation and erosion can both be performed with the same structure. The operation is reversed by changing the basic operators searching for the minimum for those searching for the maximum or vice versa. A filter according to the invention is described below in more detail with reference to the enclosed draw¬ ing, in which Figure 1 shows the structure of a prior art fil¬ ter, Figure 2 shows the structure of a horizontal por¬ tion of a filter according to the invention, and Figure 3 shows the structure of a vertical portion of the filter according to the invention. Figure 2 shows the structure of a horizontal por- tion of a filter according to the invention. This hori¬ zontal portion comprises operator elements, the number of which is W and each of which consists of one comparing means min and one delay means D, the operator elements being connected one after another in such a way that the output of the delay means D of a preceding operator ele¬ ment is connected to the first input of the comparing means min of the following operator element. The input IH of the horizontal portion is connected to the first input of the comparing means min of the first operator element and also to the second input of the comparing means min of each operator element. Thus each operator element re- ceives simultaneously the value coming to its input IH and the result of the operation (for instance minimum) of the preceding operator element delayed in each operator element approximately by the delay of the delay means D, i.e. in practice most usually by one clock period. The output of the horizontal portion of Figure 2 is formed by the output MINW of the Wth operator element. This rep¬ resents the minimum or maximum values searched for in the portions including W successive samples, which portions have been allowed to slide over the one after another organized horizontal lines of the basic data matrix. Figure 3 shows the structure of a vertical portion of a filter according to the invention. This vertical portion comprises operator elements, the number of which is H and which are similar to those in Figure 2, the op- erator elements being connected one after another in such a way that the output of the delay means D of a preceding operator element is connected to the first input of the comparing means of the following operator element. The output of the Hth operator element forms the output MINH of the vertical portion. The vertical portion further comprises delay lines, the number of which is H and each of which comprises x+1 delay means D connected one after another, the input IV of the vertical portion being con¬ nected both to the first and the second input of the com- paring means min of the first operator element and also to the input of the first delay line. On the other hand, the output of each delay line is connected both to the " second input of the comparing means min of the following operator element and to the input of the following delay line. By means of this vertical portion, the erosion or dilation process can be applied to sets including H sam¬ ple values below each other of the vertical rows of the basic data matrix or to find the minimum or maximum value of each of the sets. A very substantial property of the filter ac¬ cording to the invention is the possibility of connecting horizontal and vertical portions forming the filter one after another in a desired manner. The most conventional way is to connect one horizontal portion and one vertical portion to each other, whereby the filter processes a segment of a basic data matrix. When such a filter suited for processing a reactangular segment is realized as a concrete component, such as an integrated circuit, the problem easily emerges that the sphere of influence of the circuit, i.e. the dimensions of the segments thereof are not sufficient for the application planned. As to these dimensions, however, the filter of the invention can be extended very easily by connecting filter struc¬ tures capable of processing a certain segment one after another in such a way that the horizontal portions there¬ of and the vertical portions, respectively, are connected one after another, which provides a filter structure the dimensions of the processing neighbourhood of which are equal to the sum of the dimensions of the parts thereof. For instance, when two filters capable of processing a WxH segment are connected one after another in this way, a filter is provided the dimensions of the processing neighbourhood of which are 2Wx2H. To make a connection like this possible, the circuit of Figure 2 shows beside its input IH another input MIN and beside its output another output IHO. To make such a chaining of horizontal portions possible, it is also necessary to break off the connection between the input IH of the horizontal portion and the first input of the comparing means of the first operator element, which now gets its own input MIN. On the other hand, the other output IHO relates to the line through which the other inputs of all operator elements are supplied with respective initial value. By connecting the horizontal portion of the second filter after the horizontal portion of the first filter, the horizontal portion can be extended to continue quite like the chain shown in Figure 2, whereby its length increases in the proportion with the number of operator elements of this increased horizontal portion. A similar chaining can be realized also with the vertical portions shown in Figure 3. Then the output MINH of a preceding vertical portion is connected to the input IV of the following vertical portion, and on the other hand, the output DLO of the last delay line is connected to the input DLI of the delay line of the vertical por¬ tion of the following filter. This input DLI thus con¬ nected to the input of the first delay line of the verti¬ cal portion is then naturally disconnected from the first input IV of the first operator element of the vertical portion in question. Further, it shall be noted that filters according to the invention can be connected one after another also in many other ways, e.g. in such a way that an operation of erosion is at first applied to the basic data by means of a filter according to the invention, and immediately after that, an operation of dilation by means of a sim¬ ilar filter, but now naturally arranged to search for maximums. Consequently, arbitrary numbers of filters ac¬ cording to the invention, both dilation and erosion fil- ters, can be connected one after another in an arbitrary manner without disturbing the function of the filters. In this way, images filtered in different ways can be prod¬ uced for instance in image processing, which images, say subtracted from each other, bring forward the very prop- erty searched for with special emphasis. In the filter according to the invention, a di¬ vision of the operators into separate horizontal and ver¬ tical portions in the local neighbourhood W*H decreases the number of necessary maximum/minimum operators (dila- tion/erosion operators) from W*H to W+H compared with the traditional structure of realization. Further, a division of the operators into horizon¬ tal and vertical portions decreases the extent of wiring required for the realization of electronics or IC in the proportion (W+H)/(W*H) compared with the traditional so¬ lution. The operating and realizing principle of the fil¬ ter according to the invention makes a flexible modular extension from the neighbourhood 1*1 till the neighbour- hood W*H possible, in which W and H are optional positive integers. A restriction is caused only by the dimensions of the basic data to be processed, so that W≤x and H≤y. The neighbourhood W*H can easily be configurated to neighbourhood W X *H 1 , in which 1<W 1 ≤W and l≤H-≤H. This property makes a versatile effective image segmentation for instance in image processing possible. An advantage of the filter is its capability of eliminating unnecessary data samples whenever it is ob¬ served that they cannot be maximums (dilation) or mini- mums (erosion) of the neighbourhood W*H, which decreases the amount of the data to be processed. Due to this, the method is very quick, the delay is defined only by the time required for one maximum/minimum operation. The operations can be performed in real time. If, for ins- tance, a line camera is used for producing an image, no separate extensive image memory is needed for storing the data to be processed. The filter suits especially well for image processing (pattern recognition, image segmen¬ tation) and decreases remarkably the realization costs compared with conventional solutions. The filter of the invention has above been de¬ scribed by means of one exemplifying structure only and it is understandable that it could be changed to some extent without differing from the scope of protection defined by the enclosed claims, however.

Claims: Claims : 1. A filter for applying dilation and/or erosion operations of mathematical morphology to a W x H local neighbourhood, the width of which is W and the height H, of a two-dimensional matrix formed by discrete values, the width of the matrix being x and the height y, c h a r a c t e r i z e d in that it comprises a hori¬ zontal portion for applying a dilation/erosion operation to a W x 1 local neighbourhood made to slide over the matrix and a vertical portion for applying a dilation/ erosion operation to a 1 x H local neighbourhood made to slide over the matrix, whereby the portions are connected one after another, the output (MINW, MINH) of one portion being connected to the input (IH, IV) of the other por¬ tion. 2. A filter according to claim 1 comprising delay means (D) providing a mutually similar delay and means (min) comparing two respective values with each other and producing the minimum/maximum of these values at their output, respectively, c h a r a c t e r i z e d in that the horizontal portion comprises: W operator elements connected one after another, each of which operator elements consists of one comparing means (min) and one delay means (D), the output of the delay means (D) of a preceding operator element being connected to the first input of the comparing means (min) of the following operator element and the input (IH) of the horizontal portion being connected to the first input of the comparing means (min) of the first operator ele¬ ment and also to the second input of the comparing means (min) of each operator element, whereby the output (MINW) of the Wth operator element forms the output of the hori¬ zontal portion, and the vertical portion comprises: H operator elements connected one after another the output of the delay means (D) of a preceding operato element being connected to the first input of the com paring means (min) of the following operator element whereby the output of the Hth operator element forms th output (MINH) of the vertical portion, and H delay lines with x+1 delay means (D) connecte one after another, the input (IV) of the vertical portio being connected both to the first and the second input o the comparing means (min) of the first operator elemen and also to the input of the first delay line and th output of each delay line being connected both to th second input of the comparing means (min) of the follow ing operator element and to the input of the followin delay line.

Inventors: PIIRONEN TIMO, SARKKINEN TIMO, TIENSYRJAE KARI, PIIRONEN, TIMO, SARKKINEN, TIMO, TIENSYRJAE, KARI
Applicants: RAUTARUUKKI OY, VALTION TEKNILLINEN, VALTION TEKNILLINEN TUTKIMUSKESKUS
Application year: 1992
Main classification: G06F15
IPC codes: G06T5