Generation of root signals of two dimensional median filters

Generation of root signals of two dimensional median filters

Signal Processing 18 (1989) 269-276 Elsevier Science Publishers B.V. 269 GENERATION OF ROOT SIGNALS OF TWO D I M E N S I O N A L M E D I A N FILTERS...

742KB Sizes 0 Downloads 37 Views

Signal Processing 18 (1989) 269-276 Elsevier Science Publishers B.V.

269

GENERATION OF ROOT SIGNALS OF TWO D I M E N S I O N A L M E D I A N FILTERS* Hans-Ullrich D O H L E R lnstitut fiir Nachrichtentechnik, Technische Universitiit Braunschweig, D-3300 Braunschweig, Schleinitzstr. 23, Fed, Rep. Germany

Received 11 October 1988 Revised 2 June 1989

Abstract. The generation of root signals of a two dimensional median filter with an arbitrarily specified window shape is treated in terms of a single special binary root signal that has been called the smallest surviving object (SSO). There is a unique relation between the window shape and the SSO, and a method has been developed for transforming the window shape into the SSO. It is illustrated by some examples that the concept of the SSO can be useful in image modelling and image segmentation. Zusammenfassung. Die Generierung von Ursignalen (englisch: root signals) zweidimensionaler Medianfilter mit beliebiger Fernsterform wird beschrieben. Die Darstellung stiitzt sich auf ein spezielles bin~ires Ursignal, das das kleinste iiberlebensf'~ihige Objekt (SSO) eines gegebenen Medianfilters genannt wird. Es wird gezeigt, dab es eine eindeutige Transformation der Fensterform des Medianfilters in das kleinste iiberlebensf'fihige Objekt gibt und es wird ein Algorithmus angegeben, der diese Transformation erm6glicht. Anhand einiger Beispiele wird gezeigt, dal3 das beschriebene Verfahren vorteilhaft fiir Zwecket der Bildmodellierung und Bildsegmentierung eingesetzt werden kann.

R~sum~. On drcrit une mrthode de grnrration des signaux invariants (anglais: root signals) par rapport b. un filtre de mrdiane avec une fen~tre quelconque. Ce procrd6 est bas6 sur un signal binaire sprcial, qu'on appelle le plus petit objet capable de survivre (SSO) relatif fi un filtre de mrdiane donnr. On prouve qu'on peut drfinir une transformation univoque qui m~ne de la forme de la fen&re utilisire pour le filtre de mrdiane fi l'objet minimal capable de survivre, et I'on drcrit I'algorithme pour accomplir cette transformation. On montre aussi, par moyen de quelques exemples, que la mrthode proposre peut ~tre employre avantageusement aux buts du modelage et de la segmentation d'image.

Keywords. Median filters, stack filters, root signals, fixed points, SSO, signal modelling, image segmentation.

1. Introduction Repeated median filtering of an arbitrary input signal in general yields an output signal, which cannot be affected by further median filtering. Such signals, which are invariant to median filtering, are * This work was supported by the Deutsche Forschungsgemeinschaft (DFG) as part in the research program: "Methoden und Prozessorarchitekturen fiir hochkomplexe Signalverarbeitung in intelligenten Systemen'" 0165-1684/89/$3.50 © 1989, Elsevier Science Publishers B.V.

called root signals or fixed points of the median filter. In many picture processing and image segmentation tasks, it can be appropriate to model the image signal in terms of the root signals of adequately chosen median filters. Every quantized discrete signal can be regarded as a stack of discrete binary magnitude slices, which is frequently referred to as threshold decomposition of the signal [4]. The application of nonlinear rank order filters, especially

270

H.-U. D6hler / Root signals of 2-D median filters

minimum, maximum, and median filters on the given input signal, yields the same result, as does the separate application of the corresponding binary filter operation to each magnitude slice, and the subsequent stacking of all filtered slices (stack filter) [6]. Thus, there is a great simplification for rank order operators. Sorting of numbers in the filter window simplifies to counting points. Concerning hardware realizations and parallel hardware architectures, it seems that generally, counting operations can be performed much more effectively than sorting operations, and therefore the importance of stack filters will increase together with the increasing interest in parallel architectures for picture processing applications. The structures of root signals for one dimensional and separable two dimensional median filters have already been discussed by many authors [1, 4, 7-10]. On the other hand there is not much literature about true two dimensional median filter roots. In [10] there are few examples for root signals of windows up to 5 x 5 pixels. In the following contribution, rules are given for the generation of roots of median filters with arbitrarily shaped windows. In contrast to commonly applied median filters with square or rectangular windows, the shape of the examined filter windows is considerably less restricted. Thus, due to a newly introduced free parameter (the shape of the median window) also the shape and the size of the corresponding root signals is less restricted. Finally, some examples for the application of root signal generation in image segmentation are given. Without imposing restrictions on the universal validity, we only consider the structure of binary root signals of two dimensional median filters. We restrict our discussion to non oscillating signals, which we call compact root signals. Oscillations with periods less than the width of the median window (stripe, checker board patterns and others) will not be discussed. Our aim is the determination of the smallest compact pattern, that is a root signal of a median filter with arbitrarily specified window shape. We call that pattern the smallest surviving object (SSO) Signal Processing

of a median filter. We give rules for the generation of SSO for median filters and we present an algorithm for the realization of that generation.

2. Digital region, digital straight line and digitial convexity In this section we give some helpful definitions and rules of discrete digital geometry (Fig. 1). The regular decomposition of the Euclidian plane into disjoint square cells of unit area is called a cellular mosaic of the plane. The central point of each cell is called a lattice point. Each cell, which is frequently referred to as pixel or pel, is associated with its integer coordinates x, y of its corresponding lattice point and with its color (black (1) or white (0)). A finite set of connected cells with the same color is called a digital region R. Its complem e n t / ~ containing all points, which are not in R is called the background of R. The area, i.e., the number of cells belonging to R, is called A(R). The subset of points in R, each of which has at least one of its four neighbours belonging to the background, is called contour C(R). The connected path through all contour points in C(R) can be coded by the well known contour code (Freeman code). A connected path through a set of contour points of R is called positive, if and only if the points of R lie on the left side of the path, and negative otherwise. The intersection of cell edges belonging to C(R) and to the background is called boundary B(R). A digitial region is called digital convex, if and only if every pair of points P~ and P2 in C(R) have the so called chord property [3, 5], i.e., the area between the continuous line segment g~2 and the boundary B(R) must not contain lattice points belonging to the background (Fig. l(a)). A contour path is called a straight line segment, if and only if it has the chord property and all of its points lie left of or at least on the continuous line segment gt2 (Fig. l(b) and (c)). We call the digital line segment G~2 the image of gl2, and gt2 the preimage of G12. A digital region

H.-U. D6hler / Root signals of 2-D median filters Distal

C o n v e x

R e , o n

271

G12

R









.













.

.



°

°







,





°

°

°

°











.

°



°

°

°

°

a

G12 .

°

.

°

.

°

.

.



.

.

.

.



.



.



.



.

.

b

¢

Fig. 1. Digital region R. (a) Convex digital region R. (b) and (c) Examples for the digital line segment from P, to ~ .

R is called a digital polygon, if its contour is composed of digital straight line segments.

3. From the median filter window to the smallest surviving object

2.1. Computation of the contour points of digital straight lines

Let R be a digital region and W be a median filter window with area

For the generation of the SSO we need a rule to compute the digital straight line segments from vertice to vertice of a digital polygon. We know that there are many different algorithms to generate straight line segments. The method presented here is based upon the chord property of digital straight line segments. Let g~2 be a continuous line segment from Pl(x~,y~) to P2(x2,y2). Then the discrete points Pi(xi, yi) of the digital straight line segment G~2 with positive path from P~ to P2 are specified by Xl

i [

,

• . . , X2,

xl + { ( y i - y l ) A x / A y J ,

Xi =

X 1 +

and Ay > 0, [ ( y , - - y l ) A X / A y ] ,

Y~,..-,Y2, y, + [ ( x , - x t ) A y / A x ] ,

Yi

=

if Inyl ~ IAxl, if layl > [Axl if lay I > IAxt and Ay < 0, if

IAyl >IAx[,

with

no{I,2,...}.

(1)

Further it is assumed that W has a central symmetric shape. If R is a root signal of the median filter with W, then for every point P of R the condition

A(WnR)p>n,

i f P = 1,

A(WnR)p>n,

ifP=O,

(2)

has to be valid. To compute the complete set of all binary root signals a ficticious method could first determine all the invariant patterns in the interior of the window, and then compute all combinations of these patterns for which the median condition holds true. Concerning the large number z with

if [Ay I ~< IIAxl and Ax > 0,

y, + [(X, --Xl)Ay/AxJ,

if IAyl ~
with

Ax=x~-x~

A(W)=2n+I

and

Ay=y2--yl.

and v = [uJ next integer value with v ~< u, v = [u ] next integer value with v/> u.

it seems impossible, already for small windows, to compute all these invariant patterns in limited time. Therefore our approach is restricted on a special root signal, which we call the smallest surviving object (SSO) of a median filter. This SSO is a convex digital polygon without holes. The rule to obtain the SSO results from the following two propositions concerning root signal properties of simple digital regions. Vol.

18,

No.

3, November

1989

H.-U. D6hler / Root signals of 2-D median filters

272

Assume an infinite digital region R without holes, bounded on one side by a digital straight line G. We refer to such a region R as an infinite digital half plane. The straight line g with an arbitrary slope ~, i.e., the angle between g and the x-axis, is called the preimage of G. Proposition 1. Every infinite digital half plane R,

bounded by a digital straight line G of arbitrary slope ~, is root signal of every central symmetric median window.

Proposition 2. Every intersection of two infinite

digital half planes R~ and R 2 , bounded by two digital straight lines G, and G2, is root signal of every central symmetric median window, if the preimages g, and g2 are consecutive straight lines of W with respect to their slopes. Proof 2. Let 2k, >/2 and 2k2/> 2 be the number of black points of the discrete lines lying exactly on their continuous preimages. Like in the proof of Proposition 1 we can write A(WnR1)p=n+l+k

Proof 1. Let G be the bounding digital line of R,

which is the image of the continuous line g running through the center of the median window. Further let k/> 0 be the number of black points in (3, lying exactly on g. Then the number of black points in the interior of the window is determined by

A ( W c h R ) p =½(2n+ l - k - 1 ) + k

+l

=n+½k+l>n and (2) is fulfilled.

and

A( W n R1 n

A(WnRI~R2)

R~ ooooooo I ooooooo I Io • • • o _ e J ~ ~

a

A( W c~ R,)p - e - kl ,

R2) P =

where e/> 0 denotes the number of lattice points lying truly in the interior of the continuous triangle A bounded by g,, g2 and the border of W (see Fig. 2). It follows that

[]

Let W be a central symmetric median window, and let R1 and R~ be two infinite digital half planes, bounded by G, and G2. It is assumed, that the preimages gl and g2 have a slope of ~, and ~2, with ~, < ~2. Further it is assumed that gl and g2 are running through P, the centre of W, and each of them have at least two other points in common with W. The pair of straight lines g~ and g2 we call consecutive lines of W with respect to their slopes, if there exists no lattice point lying truly in the interior of the triangle A, bounded by g~, g2 and the border of W (see Fig. 2).

1

n+ l + k , - e

p =

n

and e< 1

so

e =0,

i.e., the interior of za must not contain any lattice point. Therefore g, and g2 have to be consecutive straight lines segments of W with respect to their slopes. [] Combining Propositions 1 and 2 we obtain the rule for the generation of the smallest surviving object of a median filter with given central symmetric window W:

R~ ooooooo oooooo~ no o o o o ~ ,

/

R~ n R2 g2

A

i

b

c

Fig. 2. Median condition for the intersection of two digital half planes R t and R 2. Signal Processing

-kl>

H.-U. D6hler / Root signals of 2-D median fitters

Proposition 3. The contour of the SSO results from the linkage of all possible straight line segments that connect the center of the window with some other lattice point within the window. This linkage must be done in such a manner that all straight line segments are sorted with respect their slopes. I f there are segments with the same slope, only the longest of them is to be considered.

4. Algorithm for the computation of the SSO We are now able to formulate the complete algorithm for the computation of the smallest sur-

Window •

.



°

,

,

.

,

.

.

,

.

.

.

a Polygon •

.

.

°

.

.

,

,

.

°

.



,

273

viving object of a given median filter with a central symmetric window (see Fig. 3): Step 1. For every point of the window assume a straight line segment starting at the center of the window. (See Fig. 3(a).) Step 2. Sort these straight line segments according to their slopes. If there are different segments with the same slope, only the longest of them is to be considered. Step 3. Link this sorted list of straight line segments to form a polygon. Due to the postulated central symmetric window, it will be a closed polygon (see Fig. 3(b)). Step 4. Compute the contour points of the digital polygon. Using the algorithm presented in Section 2.1, compute the contour points of all digital straight line segments of the polygon. The linkage of all these computed digital straight line segments specifies the contour of the desired SSO (see Fig. 3(c)).

5. Examples for the SSO



°

.

.

.

,

.

°

.

.

°

,

.

b SSO •

.

l

l

.

I

°

O

,

I

,

J

.

J

.

l

l

,

~

°

.

,

~

1

°

0

C Fig. 3. Algorithm for the generation of the smallest surviving object (SSO) of a median filter. (a) Median window with all line segments through the center. (b) Resulting polygon. (c) Resulting digital polygon, the smallest surviving object (SSO).

Using the algorithm formulated in Section 4, we computed the SSOs of the commonly used median filters with square window shape. In Fig. 4(a) the SSOs are shown and in Fig. 4(b) the edge length D of the bounding square is plotted versus the edge lengths N of the windows. It is shown that the size D grows approximately quadratic with the window size, or in other words, D is approximately proportional to the window area. That result caused us to moolfy the median window shapes. If the area of the windows grows in a linear manner, the size of the associated SSOs should also grow nearly linear. The only restriction on the windows used is, that their points are symmetrically arranged with respect to their center. Fig. 5(a) shows the resulting SSO and Fig. 5(b) the corresponding windows. Fig. 5(c) shows a plot of the size D of SSO versus the area of the windows. Vol. 18, No. 3, November1989

H.-U. DShler / Root signals of 2-D median fihers

274

ml3

O

O m2~

(

m2S

m+~

O0

m~9

53q)

m12t

I0000

[]

I000 Q

m13

m9

D 100



10

1

b 3

T

ii

15

19

23

27

31

35

39

N

Fig. 4. SSOs of s q u a r e m e d i a n w i n d o w s . (a) SSOs of w i n d o w s with N × N = 3 x 3 , . . . , 13 × 13. (b) Size D o f SSOs versus N.

11

III

Ill

I1!

6. Examples for image segmentation |

.= imam

Fig. 6(a) shows a synthetic binary image, which contains disks of ditterent diameter. These disks we refer to as the interesting part of the image. This part is disturbed by a superposed random noise which we refer to as the noisy part of the image. Image segmentation aims for the separation of the interesting part from the noisy part. As shown in Fig. 6(b) repeated median filtering can solve this problem. The results are shown for median windows with areas of 5 to 17 pixels. These are the same windows as used in Section 5. The larger the median window size, the larger the smallest disk remaining in the segmented image. The Signal Processing

mR

:

ill

liB

50 40 30 D 20 10 0

5

9

¢

13 17 21 25 29 33 37 41 45 49 53 57 61 65

A(W) Fig. 5. SSOs o f m e d i a n w i n d o w s with A ( W ) = 5 . . . . . 65. (a) S h a p e of SSOs. (b) S h a p e of c o r r e s p o n d i n g m e d i a n w i n d o w s . (c) Size D of SSOs versus the w i n d o w area A ( W ) .

H.-U. Di~hler / Root signals of 2-D median filters

275

median filters can also be used for image segmentation tasks. The appliction here can be the separation of objects of equal size but different orientation. Two examples are illustrated in Fig. 7. The square objects in the input image can be easily

llIIIIIlll IIIIIllIII IiOO|||||| |J|||I||||

IIIIIIIIII

IIIIII|III III

•4••6•444~

444~44~44~ -..

.

.-

.

..

'."

. ,;

.

• i..-i

.~.

$' ~

• • I~. ....

'e.'..~.'IU..

.'.

'4L.



• b

IlmlllIIII UlllIIllml IIIiJIllII

qJ



44•4@444•@ 4••~@@~@•@

NINOOW=m9

--

|





~:

44•4@@4@•4

IIIn

NimI NnNI IIII

IIII IIII IIII IIII IIII

IIII IIII IIII IIII IIII

•I N I N N N n

4••••••••4

~IHOObl= m~

IINI

•INN •Inn IInI

44~ ~0~44444~• ~••444•44

i

~440~0•0• D~44

I

WINDOW: mm9..~r

IIIIJIIIII IIII|IIIII IIII|II•II

e eeoeo o e o iooooooooooo



t~

@~444444 44~@@•@••• @••4•••••• 4••@@••••4

0~40044~

IIIIIIIIII IIII|IIIII IIII|II••I

WINDOW: m17

44~4@4$~••

o e O 0 0 0

$













0,0



6

ooooo0 o I O O 0 0 mOO000 mOO000



•••••••••4 44•4@44•44

J

/

/

/

/

IIllll

tt~4

f

/ / / / / /

Fig. 6, Segmentation by repeated median filtering with different windows. (a) Synthetic binary image with superposed random noise. (b) Results of filtering with windows of A(W) = 5, 9, 13, 17.

WIHDOWI mmg_fl / / / / / /

size of the smallest remaining object in the segmented image can be easily adjusted by the median window size. To do this adjustment, knowledge about the SSO of the respective median window is a helpful tool. As can be seen from Fig. 6(b), not only the size of the smallest remaining object but also the smoothness of the resulting contour depend upon the window size. Hence, median filters can be useful in modelling smooth contours, and also can provide means for extracting smooth contours for many images. Oriented shapes of median windows produce oriented shapes of SSOs. Such orientation sensitive

/ / / / f / f

I

/ / / / / /

J ~ / / / f

/ / / / / /

/ /

f

J



J

J

Fig. 7. Segmentation by repeated median filtering with the direction sensitive median filter windows. (a) Squares of different orientation: input image, output image, corresponding window. (b) Lines of different orientation: input image, output image, corresponding window. V o l . 18, N o . 3 , N o v e m b e r

1989

276

H.-U. D6hler / Root signals of 2-D median filters

separated by different m e d i a n windows. The resulting output image and the c o r r e s p o n d i n g median filter windows are shown in Fig. 7(a). Also different thin linear objects with different orientation can be separated by appropriately adjusted m e d i a n filter w i n d o w s as shown in Fig. 7(b).

given objects in their sets o f root signals. The solution to this problem could be referred to as optimal m e d i a n or m a t c h e d m e d i a n filtering for image preprocessing and segmentation and will be treated in a forthcoming paper.

References 7. Conclusion We presented a m e t h o d to specify the root signal structure o f truly two dimensional median filters. O u r description was based u p o n the so called smallest surviving object (SSO) o f a median filter. We formulated an algorithm for the generation o f the SSO for median filters with central symmetric windows. The application o f median filter roots for image segmentation was illustrated by some examples. M a n y real images can be regarded as a superposition o f two parts, the interesting part, which contains objects with k n o w n size, shape and orientation, and the noisy part o f the image. If the interesting part can be characterized in terms o f any SSOs o f m e d i a n filters, or as a u n i o n o f some SSOs, we can solve the segmentation task by repeated m e d i a n filtering with the c o r r e s p o n d i n g m e d i a n windows. We presented a m e t h o d to obtain the SSO from a given m e d i a n window. But there is also m u c h interest concerning the opposite direction from real images containing objects o f given size, shape, and orientation, to the c o r r e s p o n d i n g median filter windows. These m e d i a n filters should contain the

[1] J. Astola et al., "On root structures of median and mediantype filters", IEEE Trans. Acoust. Speech, Signal Process., Vol. ASSP-35, 1987, pp. 1199-1201. [2] R. Brons, "Linguistic methods fordescriptionofastraight line on a grid", Comput. Graphics Image Process., Vol. CGIP-3, 1974, pp. 48-62. [3] H.-U. D6hler and P. Zamperoni, "Compact contour codes for convex binary patterns", Signal Process., Vol. 8, Elsevier, Amsterdam, 1985, pp. 23-29. [4] J. Fitch, et al., "Median filtering by threshold decomposition", IEEE Trans. Acoust. Speech, Signal Process., Vol. ASSP-32, 1984, pp. 1183-1188. [5] C.E. Kim and A. Rosenfeld, "On the convexity of digital regions", Proc. 5th ICPR, Miami Beach, 1980, pp. 10101015. [6] P. Maragos and R.W. Schafer, "Morphological filters-Part I I: Their relations to median, order-statistic, and stack filters", IEEE Trans. Acoust. Speech, Signal Process., Vol. ASSP-35, 1987, pp. 1170-1184. [7] A. Nieminen et al.,"Anew class of detail-preserving filters for image processing", IEEE Trans. Pattern Anal Mach. Intell., Vol. PAMI-9, 1987, pp. 74-90. [8] Th.A. Nodes and N.C. Gallagher, "Median filter: Some modifications and their properties", IEEE Trans. Acoust. Speech, Signal Process., Vol. ASSP-30, 1982, pp. 739-746. [9] Th.A. Nodes and N.C. Gallagher, "Two dimensional root structures and convergence properties of the separable median filter", Trans. Acoust. Speech, Signal Process., Vol. ASSP-31, 1983, pp. 1350-1365. [10] S.G. Tyan, "Median filtering: Deterministic properties", in: T.S. Huang ed., Two-dimensional Digital Signal Processing II, Springer, New York, 1981, pp. 205-209.