qmat97_iwanowski_skoneczny_szostakowski.pdf

Upload: hub23

Post on 04-Jun-2018

213 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/13/2019 qmat97_iwanowski_skoneczny_szostakowski.pdf

    1/8

    IMAGE SEGMENTATION BY ADVANCED MORPHOLOGICAL FILTERING ANDCLUSTERING

    Marcin IWANOWSKI, Sawomir SKONECZNY, Jarosaw SZOSTAKOWSKI

    Warsaw University of Technology, ul.Koszykowa 75, 00-662 Warszawa, POLAND

    ABSTRACT

    This paper is devoted to a segmentation method consisting of two steps: advanced

    morphological filtering by reconstruction and clustering by k-means algorithm. First step is

    based on morphological reconstruction and two filters are applied: opening by reconstruction

    and closing by reconstruction. This kind of operation has very important advantage from the

    point of view of segmentation - it preserves the borders of regions. Traditional filters

    (opening, closing, linear filters) remove noise, but on the other hand they cause some blur

    effects, which can be the serious obstacle for correct segmentaion. Morphological filtering by

    reconstruction has very good filtration properties without changing the shapes.

    Second step of segmentation consists of clustering. Two versions of k-means clustering

    algorithm will be described: classic and fuzzy one. First, 'crisp' version will be applied to thecases with a knowledge regarding number of clusters given a priori. Fuzzy version should be

    used when it it is difficult to define cluster number. The algorithm will automatically adapt

    number of clusters into the structure of the image. A combination of filtering by

    morphological reconstruction and clustering makes possible to consider two kind of

    information: spatial (filtering) and spectral (clustering).

    Key words: clustering, fuzzy logic, k-means, mathematical morphology, reconstruction

    INTRODUCTION

    The presented method is divided into two steps: morphological filtering nad clustering. Firststep is the preprocessing step performed in order to consider spatial dependencies in the

    image. The main areas of the image are transformed to more homogeneous. It means that all

    of the pixels with the graytone considerably lighter or darker than their background are

    removed in order to avoid misclassifications during the second, clustering step. Typical

    solution for such kind of problem is opening, closing, or linear filtering. But they change the

    shapes of regions on the image (bluring), which is the main obstacle for using this kind of

    filters in segmentation process. Segmentation should extract the shapes in the image, so each

    distortion of shape is dangerous. In order to solve this problem more advanced mathematical

    morphology is used: geodesic operators. Based on this operators two filters can be defined:

    opening by reconstruction and closing by reconstruction. They both remove lighter or darker

    pixels or areas on the image's surface, but they do not change the shapes. So they are verywell suited for the segmentation purposes.

  • 8/13/2019 qmat97_iwanowski_skoneczny_szostakowski.pdf

    2/8

    The second step of proposed method is called clustering and is destined to a clasification of

    image's pixels. To do this the k-means algorithm is used. This algorithm is iterative and

    consists of two steps: clasification and calculation of cluster centers. Each iteration gives

    better approximation of the cluster centers. The algorithm is itertively performed while the

    cluster centers are moving. Each pixel is classified to the cluster with the closest center.Clusters are represented by theirs centers, and they correspond with the regions on the image.

    Two kinds of a k-means algorithms are considered. The first one is traditional and gives as the

    result the number of clusters which is given by the user. The second is based on fuzzy logic. It

    can give as the result the number of clusters different from those given at the beginning of the

    algorithm. In this case the number of clusters is adapted to the real structure of the image. The

    algorithm starts with given number of clusters and later this number can increase or decrease

    depending on the spectral distribution of image's pixels.

    MORPHOLOGICAL FILTERING BY RECONSTRUCTION

    Mathematical morphology is a very efficient non-linear tool for signal and image processing.An introduction to mathematical morphology is to find in (Serra, 1982; Serra, 1988). In this

    paper morphological filtering by reconstruction is considered. The following part describes

    briefly theoretical background for opening and closing by reconstruction. Both operations

    belong to one group called geodesic morphological transformations (Soille, 1994).

    Geodesic dilation (erosion) of size 1 of the marker image fwith respect to the mask imageg

    where ( ) is defined as infinimum (supremum) image of mask image and marker

    image after dilation (erosion) of size one - with elementary structuring element, and is

    denoted as: ( ):

    f g

    f

    g f( ) (1

    g

    )

    g,

    g

    ) )

    ,

    .

    ) g f( ) (1

    (1) g f f( ) ( )( ) ( ) ,1 1= g g f f

    ( ) ( )( ) ( )1 1=

    Geodesic dilation (erosion) of size nconsists of nsuccesive geodesic dilations (erosions) of

    size 1:

    , (2) gn

    g g gn times

    f f ( ) ( ) ( ) ( )( ) ( .... ( )...))=

    1 1 1 gn

    g g gn times

    f f( ) ( ) ( ) ( )( ) ( .... ( )...))=

    1 1 1

    Reconstruction by dilation (reconstruction by erosion) of a mask imageffrom a marker image

    gwhere ( ) is defined as succesive geodesic dilations (erosions) offwith respect

    togperformed until idempotence and is denoted by: R (R ):

    f g f

    fg( fg (

    R f , R f (3)fg gi( ) ( )( )= fg g

    i=( ) ( )( )

    where isuch that (idempotence): , gi

    g

    if f( ) ( )( ) ( )= +1 gi

    g

    if f( ) ( )( ) ( )= +1

    More information about reconstruction is in (Soille, 1994; Vincent, 1992).

    Opening and closing by reconstruction are defined as follows:

    (4) Rn

    g

    n

    R

    n

    g

    nf R f f R f( ) ( ) ( ) * ( )( ) ( ( )), ( ) ( ( )).= =

    Unlike traditional opening and closing, opening by reconstruction and closing by

    reconstruction preserves shapes in the image. It is very important while using these operations

    as a first step of segmentation. It makes possible removal of the local peaks of gray-intensity

    without changing the borders of regions (which happens in traditional opening and closing).

  • 8/13/2019 qmat97_iwanowski_skoneczny_szostakowski.pdf

    3/8

    One of the most efficient filters are alternating sequencial filters (ASF), which are consist of

    two families of filters. Each family contains operation of the same type but of different,

    increasing size. It can be defined as follows:

    (5)ASFi i i= ( ) ( ) ( ) ( ) ( ) ( )... 2 2 1 1

    , are the families of filters, i is defined as a size of filter. In most of cases

    and represent opening and closing (Meyer and Serra, 1989; Serra and Vincent, 1992). In

    our case we use these operation by reconstruction where means closing by reconstruction

    and - opening by reconstruction. We will call this filter later ASF by reconstruction

    (ASFR):

    (6)ASFR i Ri

    R

    i

    R R R R= ( ) ( ) ( ) ( ) ( ) ( )

    ...2 2 1 1

    CLUSTERING

    Up to now a huge amount of segmentation algorithms was developed. In general one can

    divide them into two groups (Soille, 1992): based on spectral and spatial properties of the

    image. To the first group belong all the algorithms based on the intensity of image's pixels

    like e.g. clustering. Second group bases on the relationships between pixels and theirs

    neighbors. To this group belongs the most popular morphological segmentation technique -

    watershed (Beucher, 1990; Meyer and Beucher, 1990). This paper describes only first type of

    segmentation - clustering. In our case not only spectral properties are considered because first

    step - morphological filtering was performed. Those step have removed the undesirable

    intensity peaks using the spatial information, so the spatial constraints are in such a manner

    considered.Proposed clustering method bases on the k-means technique (Duda and Hart, 1973; Selim and

    Ismail 1984; luzek, 1991; Iwanowski, 1996). K-means algorithm aims at classifying each

    member of given set of input data into given number of clusters. Algorithm deals with

    distances between samples and cluster centers. This distance is iteratively minimized in two

    steps performed iteratively. First step distributes samples into the clusters, second updates

    cluster centers. Each sample is classified to the cluster which center is the nearest in given

    metric. Updating of cluster centers is performed by computing a new cluster center by placing

    it in the middle (arithmetic mean value) of all of the samples belonging to the cluster. These

    two steps are performed iteratively while clusters centers change their position. If in the last

    performed iteration cluster centers did not move, it means that operation of samples

    classification is finished. In case of applying k-means algorithm for images notions of sample

    and cluster center are represented by pixel's graytone. During the calculations the distance

    between samples and cluster centers is calculated by taking absolute value of difference

    between graytones of sample and cluster center. Cluster centers obtained finally represents

    graytones of the output image. These graytones refers to regions on the image surface.

    Whole algorithm can be written as follows:

    1. Setinitial cluster centers (output graytones).

    2. Classifypixels. Each pixel is labeled by the id number of the closest cluster.

    3. Calculatenew cluster centers (output graytones).4. If in cluster centers obtained in step 3 are different to centers obtained in previous

    iteration thengo to step 2, otherwisego to step 5.

  • 8/13/2019 qmat97_iwanowski_skoneczny_szostakowski.pdf

    4/8

    5. Using cluster centers (output graytones) classifypixels of the input image into output

    one. Change value of each pixel to the value of the closest cluster center.

    Initial cluster centers (point 2 above) can be calculated in any way. We have placed them

    equally distanced in a whole range of graytones.Next remark refers to the spectral property of this kind of segmentation. Because k-means

    does not consider neither position of pixel nor its neighbors, there is no need to make all of

    the calculations on image. Image histrogram is sufficient to do this. This solution is faster

    because it needs smaller amout of computations.

    In version of the algorithm described above number of clusters is fixed and cannot be

    changed. This solution is not always sufficient. Sometimes one would have flexible algorithm

    which can change the number of cluster according to the real situation on the image. In this

    case fuzzy version ofk-means algoriithm (fuzzy k-means - FKM) can be applied. Some fuzzy

    versions of k-means was developed. In this paper version close to (Huntsberger et al., 1985) is

    proposed. The main difference between traditional and FKM algorithm is representation of

    the result. In traditional version each point is labelled by the cluster number. Fuzzy version

    produces so called 'fuzzy partition' - a vector which includes membership values. These

    values tell us 'how much' given point is similiar to each of the clusters. This is not only

    indication of the closest cluster center but also a description of similiarity with other clusters.

    The schema of algorithm is similar to that presented above. Only some changes should be

    made. Calculation of cluster centers is performed using the following equation:

    c (7)x

    i

    ij

    m

    jj

    n

    ij

    m

    j

    n=

    =

    =

    ( )

    ( )

    1

    1

    (all symbols will be explained later)

    Classification step computes new vector with membership values and is performed for each

    pixel (indexp) as follows:

    - compute distance between pixel and cluster centers: = 1 i k d x cip p i;

    - if one or more distances dare equal to zero perform for all 1ik:

    ip ip

    ip l

    if d

    otherwise

    = =

    =

    0 0

    1 (8)

    (l- number of distances dequal to 0)

    otherwise for all 1ik:

    ipd

    d

    m

    j

    kip

    jp

    =

    =

    1

    2 1

    1

    ( ) /( ) (9)

    where: n- is the number of pixels, c - is center of i-th cluster, - is i-th sample (pixel),i xp ip -

    is the element of fuzzy partition, it describes membership value: 'how much' p-th sample

    belong to i-th cluster. Parameter m describes degree 'fuzziness' of classification (nature of

    clustering). m=1 gives 'hard' or 'crisp' clustering, bigger m give fuzzier classification.

    Presented above descriptions refers to 'pure' FKM algorithm. In order to apply it to

    segmentation some additional steps should be made. FKM algorithm is performed until

    convergence. When the fuzzy-partition elements stops changing their elements, next step is

  • 8/13/2019 qmat97_iwanowski_skoneczny_szostakowski.pdf

    5/8

    executed. Cluster centers are compared in order to check if there are clusters with centers

    close to each other. If two or more clusters have their centers close, they represent in fact one

    cluster. In this case number of clusters k decreases and FKM algorithm is performed once

    again. When number of clusters is stable next step is performed. Now all the pixels with the

    membership values high enough are classified to the clusters with the highest membershipvalue. The thresholding operation with threshold which describes how 'high' is 'high enough'

    is called -cut. All the pixels not classified (their membership values were too small to be

    classified properly) are classified once again using FKM.

    Whole algorithm can be summarized as follows:

    1. Setwhole image as a set of pixels for classification.

    2. Perform FKM:

    2a. Initialize fuzzy partition.

    2b. Generate fuzzy partition (membership values for each pixel).

    2c. Calculate new cluster centers.

    2d. If new cluster centers are different to previous ones go to step 2b.

    3. Checkif real number of clusters after FKM is equal to k

    ifyes thengo to step 4, otherwiseset k=real number of clusters andgo to 2.

    4. -cut, classify all the pixels with membership values higher than to the closest

    clusters.

    5. Ifnot all pixels were classified in step 4 thenset not-classified pixels as a new set for

    classification and go to step 2, otherwisestop the algorithm.

    RESULTS

    In order to apply proposed algorithm some experiments were carried out. We used 256-

    graytone images, resolution 256x256 pixels.

    Fig. 1. (a) - input image (mangan), (b) - after ASF of size 2, (c) - after ASFR of size 2, (d) -

    after ASFR of size 2 and k-means (k=2).

    Fig. 1. shows the results of two kinds of filtering: by ASF and by ASFR. First one consists of

    four operations: closing of size 1, opening of size 1, closing of size 2, opening of size 2 (ASF

    of size 2). It is visible that all the disturbances on the background have disappeared, but at the

    same time shapes of objects have been changed.

  • 8/13/2019 qmat97_iwanowski_skoneczny_szostakowski.pdf

    6/8

    Fig. 2. (a) - intensity of pixels from Fig. 1a, (b) - after ASFR of size 1, (c) - after ASFR of

    size 2, (d) - after ASFR of size 2 and k-means (k=2).

    Second filter gives correct result. It is ASFR filter of size 2 contained closing by

    reconstruction and opening by reconstruction (size 1 and 2). Image is filtered without any

    change of shape of objects.

    Image filtered by ASFR is much better input for k-means algorithm than image withoutfiltering. Only the important regions exists and theirs borders are unchanged. In this case

    'crisp' version of k-means algorithm was applied. Number of clusters is known - we have to

    extract darker shapes on lighter background - and is equal to 2. Result of k-means of size 2 is

    presented in Fig. 1d.

    Fig. 2. includes the 1-D views of the image from Fig. 1a made by horizontal cut of image at

    y=120. At the first image (Fig. 2a) initial image is shown - image containes a lot of local

    graytone disturbances which, from the point of view of 'pure' image analysis, represent noise.

    This noise should be removed. K-means applied directly on this image gives bad result,

    because apart from the proper areas also a lot of noise will be considered as objects.

    Next picture (Fig. 2b) shows the result of filtration by ASFR of size 1. Some smaller peaks

    disappear, but larger remain, so the size of ASFR should be increased. At the next picture(Fig. 2c) result of ASFR of size 2 is presented. All the important peaks are removed so k-

    means can be now applied. Result of this operation is shown on Fig. 2d.

    Fig. 3. Other examples: (a) granite, (b) granite after ASFR of size 2 and k-means (k=3), (c)

    cooper, (d) cooper after ASFR of size 1 and k-means (k=2).

    Fig. 3. contains other examples of proposed segmentation method also with 'crisp' k-means.

    Fig. 3a presents structure of granite. Three main areas exists on this image. This case needs

    ASFR of size 2 and k-means with k=3 - result is shown on Fig. 4b.

    Other example contains stucture of cooper (Fig. 3c.) which requires ASFR of size 1 and k-

    means (k=2) - see Fig. 3d.

    In examples shown above number of clusters was easy to define a priori. But it is sometimes

    in not possible. Number of clusters can be not available a priori. This can happen in scene

    analysis. In this case we apply fuzzy version of k-means (FKM).

  • 8/13/2019 qmat97_iwanowski_skoneczny_szostakowski.pdf

    7/8

    Fig. 4. (a) input image (scene), (b) ASFR of size 5, (c) FKM k=3, m=3, =150, (d) FKM k=5,

    m=3, =150.

    Image shown in Fig. 4a represents a scene. From the point of view of segmentation it contains

    a lot of noise, especially on the right side. ASFR is applied in order to remove possibly lot of

    noise. In this case ASFR of size 5 was applied - larger than in examples shown before,

    because the structure of noise is more complicated. Filtrated image is presented on Fig. 4b.Number of clusters can be defined here only roughly. In proposed FKM algorithm some

    parameters should be defined. Paramter k represents initial number of clusters. Parmeter m

    defines how 'fuzzy' behavior of the algorithm is (the bigger m is, the more 'fuzzy' algorithm

    is).

    Parameter indicates threshold for classified pixels. During the experiments the following

    parameters were chosen: m equal to 2 or 3, 130

  • 8/13/2019 qmat97_iwanowski_skoneczny_szostakowski.pdf

    8/8

    Authors would like to thank M. Mynarczuk from Instytut Mechaniki Grotworu PAN in

    Krakw for the set of geological images.

    REFERENCES

    S.Beucher. Segmentation d'images et morphologie mathematique. Ph.D. Thesis, School of

    Mines of Paris, June 1990.

    R.O.Duda, P.E.Hart, Pattern classification and scene analysis. Willey and Sons, 1973.

    T.L.Huntsberger, C.L.Jacobs, R.L.Cannon. Iterative fuzzy image segmentation. Pattern

    Recognition Vol.18., No.2., pp. 131-138, 1985.

    M.Iwanowski. K-means algorithm for greytone reduction. Technical Report, School of Mines

    of Paris, N-13/96/MM, 1996.

    F.Meyer, S.Beucher. Morphological Segmentation. Journal of Visual Comm. and Image

    Representaion. Vol.1, No.1, September, pp. 21-46, 1990.

    F.Meyer, J.Serra. Filters: from theory to practice. Acta Stereologica 1989; 8/2; Proceeding of5-th European Congress for Stereology, Freiburg, September 1989, pp. 503-508.

    S.Z Selim, M.A.Ismail. K-means-type algorithms: a generalised convergence theorem and

    characterisation of local otimality. IEEE Trans. Patterm Anal. Machine Intell. 6(1), pp.

    81-87, 1984.

    J.Serra. Image analysis and mathematical morphology. Academic Press, 1982.

    J.Serra, ed. Image analysis and mathematical morphology. Volume 2: theoretical advances.

    Academic Press, 1988.

    J.Serra, L.Vincent. An overview of morphological filtering. Circuits Systems Signal

    Processing Vol.11, No.1, 1992.

    P.Soille. Partitioning of multispectral images using mathematical morphology. Technical

    Report, School of Mines of Paris, N-22/92/MM, 1992.

    P.Soille. Geodesic Transformations in Mathematical Morphology: an Overview. Technical

    Report, School of Mines of Paris, N-24/94/MM, 1994.

    A.luzek. Komputerowa analiza obrazu. Wydawnictwa Politechniki Warszawskiej,

    Warszawa 1991.

    L.Vincent. Morphological Grayscale Reconstruction: Definition, Efficient Algorithm and

    Aplications in Image Analysis, IEEE Comp.Vis. and Patt.Rec., Proceedings, 1992,

    pp. 622-635