brain tumor detection

141
BRAIN TUMOR DETECTION USING COLOR SPACED K MEANS CLUSTERING SEGMENTATION 1

Upload: vanya13111515

Post on 19-Nov-2014

113 views

Category:

Documents


2 download

DESCRIPTION

kmeans clustering

TRANSCRIPT

1

BRAIN TUMOR DETECTION USING COLOR SPACED K MEANS CLUSTERING SEGMENTATION

2

Abstract:In this project ,we propose a color based segmentation method that uses the K means clustering technique to track tumor objects in magnetic resonance (MR) brain images. The key concept in this color based segmentation algorithm with k means means to convert a given gray level MR image in to a color space image and then separate the position of tumor objects from other items of an MR image by using K means clustering And histogram clustering .Experiments demonstrates that the method can successfully achieve segmentation for MR brain images to help pathologists distinguish exactly lesion size and region.

3

INTRODUCTIONAn Introduction to Image SegmentationImage segmentation is the partition of an image into a set of non-overlapping regions whose union is the entire image. In the simplest case, one would only have an object region and a background region. A region cannot be declared a segment unless it is completely surrounded by edge pixels. It is not an easy task to make it known to a computer what characteristics constitutes a meaningful segmentation. For this reason, a set of rules in general segmentation procedures is required: Regions of an image segmentation should be uniform and homogeneous with respect to some characteristic (eg grey level or texture). Region interiors should be simple and without many holes. Adjacent regions of a segmentation should have significantly varying values with respect to the characteristic on which they are uniform. Boundaries of each segment should be simple, not ragged, and must be spatially accurate. Magnetic resonance imaging (MRI) is often the medical imaging method of choice when soft tissue delineation is necessary. This is especially true for any attempt to segment brain tissues, normal or abnormal. Image segmentation is a tool that has been applied to medical imaging modalities to differentiate tissue types for purposes of volume measurement and visualization. Healthy brain tissue can generally be classified into three broad tissue types on the basis of an MR image. Magnetic resonance imaging (MRI), computed tomography (CT), digital mammography, and other imaging modalities provide an effective means for noninvasive mapping the anatomy of a subject. These technologies have greatly increased knowledge of normal and diseased anatomy for medical research and are a critical component in diagnosis and treatment planning. With the increasing size

4 and number of medical images, the use of computers in facilitating their processing and analysis has become necessary. In particular, computer algorithms for the delineation of anatomical structures and other regions of interest are a key component in assisting and automating specific radiological tasks. These algorithms, called image segmentation algorithms, play a vital role in numerous biomedical imaging applications such as the quantification of tissue volumes , diagnosis , localization of pathology , study of anatomical structure , treatment planning , partial volume correction of functional imaging data , and computer integrated surgery . Image Segmentation is the process of identifying features in images and marking them as distinct from one another. These features can be things like grey and white matter in an MRI of the brain or individual organs in an MR or CT image. Magnetic resonance imaging (MRI) provides detailed images of living tissues, and is used for both brain and body human studies. Data obtained from MR images is used for detecting tissue deformities such as cancers and injuries; MR is also used extensively in studies of brain pathology, where regions of interest (ROIs) are often examined in detail, for example in multiple sclerosis (MS) studies. In order to perform good quantitative studies, ROIs within the brain must be well defined. In traditional methods, a skilled operator manually outlines the ROIs using a mouse or cursor. More recently, computer-assisted methods have been used for specific tasks such as extraction of MS lesions from MRI brain scans , or extraction of the cerebral ventricles in schizophrenia studies . Many of these computer-assisted tasks require segmentation of the whole brain from the head. Classically, image segmentation is defined as the partitioning of an image into nonoverlapping, constituent regions that are homogeneous with respect to some characteristic such as intensity or texture. If the domain of the image is given by, then the segmentation problem is to determine the sets whose union is the

entire domain . Thus, the sets that make up a segmentation must satisfy

5 where and each Sk is connected. Ideally, a segmentation

method finds those sets that correspond to distinct anatomical structures or regions of interest in the image. When the constraint that regions be connected is removed, then determining the sets Sk is called pixel classification, and the sets themselves are called classes. Pixel classification, rather than classical segmentation, is often a desirable goal in medical images, particularly when disconnected regions belonging to the same tissue class require identification. Determination of the total number of classes K in pixel classification can be a difficult problem . Often, the value of K is assumed to be known based on prior knowledge of the anatomy being considered. For example, in the segmentation of magnetic-resonance (MR) brain images, it is common to assume that the K = 3, corresponding to gray-matter, white-matter, and cerebrospinal-fluid tissue classes In many image processing tasks, segmentation is an important step toward the analysis phase. It allows quantification and visualization of the objects of interest. They concluded that segmentation of medical images is still a difficult task and fully automatic segmentation procedures are far from satisfying in many realistic situations. Merely when the intensity or structure of the object differs significantly from the surroundings, segmentation is obvious. In all other situations manual tracing of the object boundaries by an expert seems to be the only valid truth but its undoubtedly a very time-consuming task. On MR data, fully automatic image segmentation techniques have been developed which can be subdivided in two major classes: 1. 2. gray scale single image segmentation multispectral segmentation

Gray scale single image segmentationThe most intuitive approach is the threshold-based segmentation method where the threshold is chosen globally or locally . The method is restricted to relative simple structures and is hindered by variability of anatomical structures as well as image artefacts. Other approaches make use of edge detection for image segmentation . These however suffer from over or under segmentation, induced by improper

6 threshold selection . In addition, the edges found are usually not closed such that edge linking techniques are further required.

Multispectral segmentationSegmentation techniques using clustering techniques like k-means clustering , adaptive hierarchical clustering , fuzzy k-means , etc. are applied [. Like all unsupervised segmentation techniques, multispectral data analysis is fully automatic and superior in reproducibility, but it can only be exploited when the MR characteristics of the object of interest differ significantly from those of the surrounding structures. On the other hand, results of supervised segmentation are less reproducible but the segmentation process can be controlled by the operator. We choose for a semiautomatic single image segmentation procedure for 3D MR images in which user interaction is allowed to control the segmentation process and in which data is preprocessed as far as possible such that the posterior userinteraction time is strongly reduced

Problems Associated with MR medical image segmentation:Methods for performing segmentations vary widely depending on the specific application, imaging modality, and other factors. For example, the segmentation of brain tissue has different requirements from the segmentation of the liver. General imaging artifacts such as noise, partial volume effects, and motion can also have significant consequences on the performance of segmentation algorithms. furthermore, each imaging modality has its own idiosyncrasies with which to contend. There is currently no single segmentation method that yields acceptable results for every medical image that are more general and can be applied to a variety of data. However, methods that are specialized to particular applications can often achieve better performance by taking into account prior knowledge. Selection of an appropriate approach to a segmentation problem can therefore be a difficult dilemma. Many issues inherent to medical imagery make segmentation a difficult task. The objects to be segmented from medical imagery are true (rather than

7 approximate) anatomical structures, which are often non-rigid and complex in shape, and exhibit considerable variability from person to person. Moreover, there are no explicit shape models yet available that fully captures the deformations in anatomy. Magnetic resonance images are further complicated due to the limitations in the imaging equipment that lead to a non-linear gain artifact in the images. In addition, the signal is degraded by motion artifacts due to voluntary or involuntary movement of the patient during the scanning process.

Importance of Image segmentation Fully automatic brain tissue classification from magnetic resonance images (MRI) is of great importance for research and clinical studies of the normal and diseased human brain Segmentation of medical imagery is a challenging problem due to the Accurate and robust tissue classification is the basis for many applications such complexity of the images as the quantitative analysis of tissue volume in healthy and diseased populations

Echo MR slice

8

Categories of image segmentationAccurate segmentation of magnetic resonance (MR) images of the brain is of interest in the study of many brain disorders. A review of some of the current approaches in the tissue segmentation of MR brain images. We broadly divided current MR brain image segmentation algorithms into three categories: 1. 2. 3. Classification based Region based Contour based Magnetic resonance imaging (MRI) provides rich three-dimensional (3D) information about the human soft tissue anatomy . It reveals fine details of anatomy, and yet is noninvasive and does not require ionizing radiation such as r -rays. It is a highly flexible technique where contrast between one tissue and another in an image can be varied simply by varying the way the image is made. For example, by altering radio-frequency (RF) and gradient pulses, and by carefully choosing relaxation timings, it is possible to highlight different components in the object being imaged and produce high contrast images. The rich anatomy information provided by MRI has made it an indispensable tool for medical diagnosis in recent years Applications that use the morphologic contents of MRI frequently require segmentation of the image volume into tissue types. For example, accurate segmentation of MR images of the brain is of interest in the study of many brain disorders. In multiple sclerosis, quantification of white matter lesions is necessary for drug treatment assessment volumetric analysis of gray matter (GM), white matter (WM) and cerebrospinal fluid (CSF) is important to characterize morphological differences between subjects Such studies typically involve vast amount of data. Currently, in many clinical studies segmentation is still mainly manual or strongly supervised by a human expert. The level of operator supervision impacts the performance of the segmentation method in terms of time consumption, leading to infeasible procedures for large datasets. Manual segmentation also shows large intra- and inter-observer variability, making the

9 segmentation irreproducible and deteriorating the precision of the analysis of the segmentation. Hence, there is a real need for automated MRI segmentation tools. The automatic segmentation of MR images has been an area of intense study. However, this task has proven problematic, due to the many artifacts in the imaging process. Some of the current approaches in the tissue segmentation of MR brain images. We provide a mathematical formulation of the MRI segmentation problem, and an overview of various MRI segmentation methods, which we have broadly divided into three categories: classification-based, region-based, and contour-based

Classification-Based SegmentationIn classification-based segmentation, voxels are classified and labeled as belonging to a particular tissue class according to a certain criterion. The simplest technique is based on thresholding. Thresholding algorithm attempts to determine a threshold value which separates the desired classes. Iterative thresholding used to distinguish brain tissues from others in axial MR slices. Starting at set values, thresholds for the head and the brain are then iteratively adjusted based on the geometry of resulting masks. Although thresholding algorithm is simple and computationally very fast, it is very sensitive to INU artifact and noise in MR images. The automatic determination of a suitable threshold could be problematic if there is severe overlap between the intensities of different tissue types due to noise and intensity inhomogeneities. Instead of using simple thresholding in earlier classification-based segmentation work, statistical classification based segmentation has been the method of choice in more recent time. Statistical classification has the advantage of being more robust, as well as having a rigorous mathematical foundation in stochastic theory. In statistical classification methods, the probability density function of tissue intensity for different tissue classes are often modeled parametrically as a mixture of Gaussians, usually one Gaussian function per tissue class. In order to incorporate local contextual information, Markov random field (MRF) regularization is often employed as well. The MRF regularization allows

10 one to model the spatial interactions between neighboring voxels. The bias field estimation problem is cast in a Bayesian framework and the expectationmaximization (EM) algorithm is used to estimate the inhomogeneity and the tissue classes. However, their method needs to be supplied with the tissue class conditional intensity models, which are typically constructed manually from training data. They also did not consider neighborhood dependencies for the tissue segmentation. algorithm by using MRF to introduce context or dependency among neighboring voxels. Propose to use a 3-step EM algorithm, which interleaves voxel classification, class distribution parameter estimation, and bias field estimation. Instead of using manually constructed tissue class conditional intensity models, their method employs digital brain atlas with a priori probability maps for each tissue class to automatically construct intensity models for each individual scan being processed. The brain tissue classes are modeled as finite Gaussian mixtures with MRF regularization to account for contextual information and the bias field is modeled as a fourth order least square polynomial fit. It also use the Gaussian mixture to model the three brain tissue classes. The biological variations of a particular tissue class are accounted for in their statistical model by assuming that the mean intensities of the tissue classes are slowly varying spatial functions. The magnetic field in homogeneities modify both the mean tissue intensities and the noise variances in a similar manner. To account for the smoothness and piecewise contiguous nature of the tissue regions, they use a 3D MRF as a prior. Consider the statistical segmentation of multispectral MR brain image. In their work, the intensity distributions of the brain tissues are again modeled as a mixture of Gaussians. They use a robust version of the EM algorithm called logistic EM algorithm to estimate the model parameters, and use MRF to incorporate prior knowledge into the segmentation process. Another major class of voxel classification techniques uses clustering-based method. Clustering is a popular unsupervised classification method and has found many applications in pattern classification and image segmentation. Clustering algorithm attempts to classify a voxel to a tissue class by using the notion of similarity to the class.

11

Region-Based SegmentationThe shape of an object can be described in terms of its boundary or the region it occupies. Image region belonging to an object generally have homogeneous characteristics, e.g. similar in intensity or texture. Region-based segmentation techniques attempt to segment an image by identifying the various homogeneous regions that correspond to different objects in an image. Unlike clustering methods, region-based methods explicitly consider spatial interactions between neighboring voxels. In its simplest form, region growing methods usually start by locating some seeds representing distinct regions in the image . The seeds are then grown until they eventually cover the entire image. The region growing process is therefore governed by a rule that describe the growth mechanism and a rule that check the homogeneity of the regions at each growth step. Region growing technique has been applied to MRI segmentation. A semi-automatic, interactive MRI segmentation algorithm was developed that employ simple region growing technique for lesion segmentation. In , an automatic statistical region growing algorithm based on a robust estimation of local region mean and variance for every voxel on the image was proposed for MRI segmentation. The best region growing parameters are automatically found via the minimization of a cost functional. Furthermore, relaxation labeling, region splitting, and constrained region merging were used to improve the quality of the MRI segmentation. The determination of an appropriate region homogeneity criterion is an important factor in region growing segmentation methods. However, such homogeneity criterion may be difficult to obtain a priori. An adaptive region growing method is proposed where the homogeneity criterion is learned automatically from characteristics of the region to be segmented while searching for the region. Other region-based segmentation techniques, 1. Split-and-merge based segmentation and

12 2. Watershed based segmentation have also been proposed for MRI segmentation.

1.

Split-and-merge based segmentationIn the split-and-merge technique, an image is first split into many small regions during the splitting stage according to a rule, and then the regions are merged if they are similar enough to produce the final segmentation. 2. Watershed-based segmentation In the watershed-based segmentation, the gradient magnitude image is considered as a topographic relief where the brightness value of each voxel corresponds to a physical elevation. An immersion based approach is used to calculate the watersheds. The operation can be described by imagine that holes are pierced in each local minimum of the topographic relief. Then, the surface is slowly immersed in water, which causes a flooding of all the catchment basins, starting from the basin associated with the global minimum. As soon as two catchment basins begin to merge, a dam is built. The procedure results in a partitioning of the image in many catchment basins of which the borders define the watersheds. To reduce over-segmentation, the image is smoothed by 3D adaptive anisotropic diffusion prior to watershed operation. Semi-automatic merging of volume primitives returned by the watershed operation is then used to produce the final segmentation.

Contour-Based SegmentationContour-based segmentation approach assumes that the different objects in an image can be segmented by detecting their boundaries. Whereas region-based techniques attempt to capitalize on homogeneity properties within regions in an image, boundary-based techniques rely on the gradient features near an object boundary as a guide. Hence, contourbased segmentation methods that rely on detecting edges in the image is inherently more prone to noise and image artifacts. Sophisticated pre- and post-processing is often needed to achieve a satisfactory segmentation result.

13 Two types of contour-based techniques :

Edge detection segmentation:MR image segmentation based on edge detection has been proposed , where a combination of Marr-Hildreth operator for edge detection and morphological operations for the refinement of the detected edges is used to segment 3D MR images. A boundary tracing method is proposed, where the operator clicks a pixel in a region to be outlined and the method then finds the boundary starting from that point. The method is, however, restricted to segmentation of large, well defined structures, but not to distinguish fine tissue types. Edge-based segmentation methods usually suffer from over or undersegmentation, induced by improper threshold selection . In addition, the edges found are usually not closed and complicated edge linking techniques are further required.

Active contour based segmentation:Active contour deforms to fit the objects shape by minimizing (among others) a gradient dependent attraction force while at the same time maintaining the smoothness of the contour shape. Thus, unlike edge detection, active contour methods are much more robust to noise as the requirements for contour smoothness and contour continuity act as a type of regularization. Another advantage of this approach is that prior knowledge about the objects shape can be built into the contour parameterization process. However, active contour based algorithms usually require initialization of the contour close to the object boundary for it to converge successfully to the true boundary. More importantly, active contour methods have difficulty handling deeply convoluted boundary such as CSF, GM and WM boundaries due to their contour smoothness requirement. Hence, they are often not appropriate for the segmentation of brain tissues. Nevertheless, it has been applied successfully to the segmentation of intracranial boundary , brain outer surface , and neuro-anatomic structures in MR brain images

14

.

Description of input dataMR scans of the head is given as input to the algorithm. Currently working with gradient echo images acquired using a General Electric Sigma 1.5 Tesla clinical MR imager. The voxel size is approximately 1 1 1.5 mm and there are 25625660 voxels per data set Tissue classes visible in such MRI scans include white and grey matter, cerebrospinal fluid (csf), meninges (the protective membranes surrounding the brain), skull, muscle, fat, skin or air . Pathology introduces the additional classes of edema, tumor, hemorrhage or other abnormality.

Model for the brainOur first task was to construct a model for the brain that would guide our segmentation process. This model is implicit in our algorithms. We represent the brain as the largest region consisting of white and grey matter, located approximately in the center of the head, and surrounded by csf and meninges. If our segmenter could clearly identify white and grey matter, without falsely including other tissue, and if it could do so while clearly isolating this material for surrounding tissue, that would be sufficient. Unfortunately, several other tissue types can cause the white and grey matter to be connected to other structures. For example, the meninges are surrounded by the cranium. Blood vessels and nerves connect the cranium to the brain tissue. In particular, the connectors are, in order of increasing thickness: bridging veins from the cerebral cortex to dura, and from dura to the skull, the second cranial nerve, or optic nerve, the vertebral arteries around foramun magnum, and the external carotid artery in the region of the temporalis muscle. Thus, we need some way of removing these connecting structures so that we can isolate the white and grey matter. This is compounded by the fact that there is some natural overlap in the intensity distributions of brain versus non-brain structures. Additional overlap in the intensity distributions is typically introduced

15 due to limitations of the imaging process, and noise may be introduced due to movement of the patient during the acquisition of the scan. This model of the brain strongly suggests the use of intensity distributions as well as absolute and relative spatial arrangement of the various structures in the head to aid the segmentation process.

Biomedical-Imaging ApplicationsThe growing size and number of these medical images have necessitated the use of computers to facilitate processing and analysis. In particular, computer algorithms for the delineation of anatomical structures and other regions of interest are becoming increasingly important in assisting and automating specific radiological tasks. These algorithms, called image segmentation algorithms, play a vital role in numerous biomedical-imaging applications, such as 1. 2. 3. 4. 5. 6. The quantification of tissue volumes Diagnosis localization of pathology Study of anatomical structure Treatment planning and Computer-integrated surgery

Practical Applacations of Image segmentationMedical Applications 1. Locate tumors and other pathologies Measure tissue volumes Computer guided surgery Diagnosis Treatment planning study of anotomical structure 2. Locate objects in satellite images (roads, forests, etc) 3. Face Recognition

16 4. Finger print Recognition , etc Segmentation methods can be classified in the following way: 1. Pixel intensity based methods. The intensity values of the pixel are used to segment the image. The space continuity is not frequently considered in this type of methods. Within this group, they stand out the method of classification of pixels, which uses a sort of statistical algorithms to assign a label pixel of the image. 2. Region based methods. The image segmentation of is based on the similarity of the adjacent intensities of pixels at image pixels. Region growth methods, where the regions begin being small and soon after, by an iterative process of growth, regions that have similar characteristics are merged . 3. Model based methods. It begins with a model that grows, updated accordingly to the image characteristics of the image. Within this group, they stand out: - Mesh based methods. The model is represented using a mesh, and the update produces changes to it. A typical example of this type of segmentation methods is the algorithms based on snakes. T-Snakes that evolves the desired surface based on mesh approximation concept.

Segmentation Methods:Several common approaches have appeared in the recent literature on medicalimage segmentation. We define each method, provide an overview of its implementation, and discuss its advantages and disadvantages. Although each technique is described separately, multiple techniques are often used in conjunction for solving different segmentation problems. We divide segmentation methods into eight categories: Thresholding approaches, 1) 2) Region growing approaches, Clustering approaches,

17

ThresholdingThresholding approaches segment scalar images by creating a binary partitioning of the image intensities. The histogram of a scalar image that possesses different apparent classes, corresponding to the different modes. A thresholding procedure attempts to determine an intensity value, called the threshold, which separates the desired classes. The segmentation is then achieved by grouping all pixels with intensities greater than the threshold into one class and all other pixels into another class. Determination of more than one threshold value is a process called multithresholding. Thresholding is a simple yet often effective means for obtaining a segmentation of images in which different structures have contrasting intensities or other quantifiable features. The partition is usually generated interactively, although automated methods do exist . Thresholding is often performed interactively, based on the operators visual assessment of the resulting segmentation. Thresholding is often used as an initial step in a sequence of image-processing operations. It has been applied in digital mammography, in which two classes of tissue are typically presenthealthy and tumorous . Its main limitations are that, in its simplest form, only two classes are generated, and it cannot be applied to multichannel images. In addition, thresholding typically does not take into account the spatial characteristics of an image. This causes it to be sensitive to noise and intensity inhomogeneities, which can occur in MR images. Both of these artifacts essentially corrupt the histogram of the image, making separation more difficult. For these reasons, variations on classical thresholding have been proposed for medical-image segmentation that incorporate information based on local intensities and connectivity .

18

Region Growing:Region growing is a technique for extracting an image region that is connected based on some predefined criteria. These criteria can be based on intensity information and/or edges in the image . In its simplest form, region growing requires a seed point that is manually selected by an operator and extracts all pixels connected to the initial seed based on some predefined criteria. For example, one possible criterion might be to grow the region until an edge in the image is met. Like thresholding, region growing is seldom used alone but usually within a set of image-processing operations, particularly for the delineation of small, simple structures such as tumors and lesions .

Region based method:Growth of regions The first region growing method was the seeded region growing method. This method takes a set of seeds as input along with the image. The seeds mark each of the objects to be segmented. The regions are iteratively grown by comparing all unallocated neighboring pixels to the regions. The difference between a pixel's intensity value and the region's mean, , is used as a measure of similarity. The pixel with the smallest difference measured this way is allocated to the respective region. This process continues until all pixels are allocated to a region. The growth of the regions is carried out from the seeds that were determined as input, where each one of them contains the following information: Position. These are x, y and z coordinates within the image. It is known that this point belongs to the region of interest. Intensity. The voxel intensity is important to determine the rank of intensities that will be included in the region (if the inclusion criterion makes use of this value). Another input data of the algorithm is the three-dimensional image with a cubical matrix shape. The algorithm output will be a matrix with the same dimensions as the input image. This output matrix is initially filled out with zeroes in all the positions, and the seeds will be marked to let the region grow.

19

Fig2.1 6-connected region growing Growth Algorithm An auxiliary FIFO (First In First Out) structure is used where the seeds are initially located, and where the Neighbors that belong to the region to be visited are queued up. In algorithm 1 it is possible to see the pseudocode of Voxel Grow algorithm in detail. The algorithm successively takes elements from the queue. Each one of these elements is one of the volumes voxel that have already been accepted. For each one of them we must visit its neighbors, and decide if that neighbor belongs or not to the region according to the selection criterion . In order to compare neighbors, 6-connectedness is used.

One of the most remarkable aspects of this technique is that it always grows by neighbors, so it maintains connectivity between the elements that are included within the segmented region. Growth Types Three growth variations are provided to consider if a voxel belongs or not to the region of interest. The first one considers the variation of voxel intensity in relation to the seed intensity. The second one considers the local intensity variation in relation to the neighbor being visited. The last one considers the three-dimensional gradient of the image. Seed Growth In this case the seed intensity is taken always as reference. Each new voxel that is added to the region is included if the intensity difference that exists between it and the intensity of the seed maintains within a threshold determined previously. This

20 threshold is compared directly with the intensity difference. This technique gives as result regions that contain voxels whose intensities are within a certain rank. Neighbor Growth Unlike the previous case, this variation considers that the voxel belongs to the region if the intensity difference with its neighbor remains underneath the threshold. In this technique, voxels that have great variations of intensity with their neighbors are excluded Disadvantages of Region growing: The primary disadvantage of region growing is that it requires manual interaction to obtain the seed point. Thus, for each region that needs to be extracted, a seed must be planted. Splitand-merge is an algorithm related to region growing, but it does not require a seed point . Region growing can also be sensitive to noise, causing extracted regions to have holes or even become disconnected. Conversely, partial-volume effects can cause separate regions to become connected. To help alleviate these problems, a homotopic region-growing algorithm has been proposed that preserves the topology between an initial region and an extracted region . Fuzzy analogies to region growing have also been developed .

ClusteringClustering algorithms essentially perform the same function as classifier methods without the use of training data. Thus, they are termed unsupervised methods. To compensate for the lack of training data, clustering methods iteratatively alternate between segmenting the image and characterizing the properties of each class. In a sense, clustering methods train themselves, using the available data. Three commonly used clustering algorithms are the K-means or ISODATA algorithm , the fuzzy c-means algorithm , and the expectation-maximization (EM) algorithm . The K-means clustering algorithm clusters data by iteratively computing a mean intensity for each class and segmenting the image by classifying each pixel in the class with the closest mean . Figure 4b shows the result of applying the K-means algorithm to a slice of an MR brain image in Figure 4a. The number of classes was

21 assumed to be three, representing (from dark gray to white in Figure 4) cerebrospinal fluid, gray matter, and white matter. The fuzzy c-means algorithm generalizes the K-means algorithm, allowing for soft segmentations based on fuzzy set theory . The EM algorithm applies the same clustering principles with the underlying assumption that the data follow a Gaussian mixture model

22 .

23

the posterior probabilities and computing maximum likelihood estimates of the means, covariances, and mixing coefficients of the mixture model. Although clustering algorithms do not require training data, they do require an initial segmentation (or, equivalently, initial parameters). The EM algorithm has demonstrated greater sensitivity to initialization than the K-means or fuzzy c-means algorithm . Like classifier methods, clustering algorithms do not directly incorporate spatial modeling and can therefore be sensitive to noise and intensity inhomogeneities. This lack of spatial modeling, however, can provide significant

24 advantages for fast computation . Work on improving the robustness of clustering algorithms to intensity inhomogeneities in MR images has demonstrated excellent success . Robustness to noise can be incorporated byMRF modeling as described in the next section. Region split and merge: 1)Region Splitting Region growing starts from a set of seed points. An alternative is to start with the whole image as a single region and subdivide the regions that do not satisfy a condition of homogeneity. 2)Region Merging Region merging is the opposite of region splitting. Start with small regions (e.g. 2x2 or 4x4 regions) and merge the regions that have similar characteristics (such as gray level, variance). Typically, splitting and merging approaches are used iteratively.

K-Means AlgorithmThe K-means algorithm is an iterative technique that is used to partition an image into K clusters. The basic algorithm is: 1. Pick K cluster centers, either randomly or based on some heuristic 2. Assign each pixel in the image to the cluster that minimizes the variance between the pixel and the cluster center 3. Re-compute the cluster centers by averaging all of the pixels in the cluster 4. Repeat steps 2 and 3 until convergence is attained (e.g. no pixels change clusters) In this case, variance is the squared or absolute difference between a pixel and a cluster center. The difference is typically based on pixel color, intensity, texture, and location, or a weighted combination of these factors. K can be selected manually, randomly, or by a heuristic. This algorithm is guaranteed to converge, but it may not return the optimal solution. The quality of the solution depends on the initial set of clusters and the value of K. The detailed description of clustering methods for images is given in a source.

25 The other approach to partition an image into K clusters is the statistical hierarchical aglomerative clusterization technique for identification of images regions by the color similarity. This method uses a binary mask and ranks the color components of the clusters central components. The basic algorithm is: 1. Each pixel is the separate cluster 2. The clusters with the same masks joins into new clusters 3. New clusters are set up by the cluster integration with minimum distance. The stage may occur until the condition for clusters comparability is being obeyed. This is condition based on the binary mask of correlation and ranks. Histogram-Based Methods Histogram-based methods are very efficient when compared to other image segmentation methods because they typically require only one pass through the pixels. In this technique, a histogram is computed from all of the pixels in the image, and the peaks and valleys in the histogram are used to locate the clusters in the image. Color or intensity can be used as the measure. A refinement of this technique is to recursively apply the histogram-seeking method to clusters in the image in order to divide them into smaller clusters. This is repeated with smaller and smaller clusters until no more clusters are formed.[1][5] One disadvantage of the histogram-seeking method is that it may be difficult to identify significant peaks and valleys in the image. In this technique of image classification distance metric and integrated region matching are familiar.

Edge-Based Segmentation Contour and shape models approach the problem from the point of view of edges rather than regions. Edges are usually modeled (either piecewise or in totality) as splines, and a search or relaxation technique is used to push the splines towards the edges. This type of segmentation method tries to find any places where a rapid transition from one brightness or colour value to another occurs. The fundamental principle involves convolving gradient operators with the image. High values of the gradient magnitude are possible places of rapid transition between two different regions; these are what we see as edges. After the step of finding edges on the image, they have to be linked to form closed boundaries of the regions. Edge detection is a well-developed field on its own within image processing. Region boundaries and edges are closely related, since there is often a sharp adjustment in

26 intensity at the region boundaries. Edge detection techniques have therefore been used as the base of another segmentation technique. The edges identified by edge detection are often disconnected. To segment an object from an image however, one needs closed region boundaries. Discontinuities are bridged if the distance between the two edges is within some predetermined threshold.

Image Segmentation By Thresholding Defining a region of interest before image segmentation will limit the processing the defined region so no computing resource is wasted for other irrelevant areas. This also reduces the amount of editing needed after image segmentation because object boundaries are generated within the defined regions. Image segmentation by thresholding is a simple but powerful approach for images containing solid objects which are distinguishable from the background or other objects in terms of pixel intensity values. The pixel thresholds are normally adjusted interactively and displayed in real-time on screen. When the values are defined properly, the boundaries are traced for all pixels within the range in the image. Greyscale thresholding works well when an image that has uniform regions and contrasting background. Following section discusses some of the image segmentation methods implemented in the software.

Region Growing SegmentationRegion GrowingIntroduction Region growing has shown to be a very useful and efficient segmentation technique in image processing. Region growing in its simplest sense is the process

27 of joining neighboring points into larger regions based on some condition or selection of a threshold value. Seeded region growing starts with one or more seed points and then grows the region to form a larger region satisfying some homogeneity constraint. The homogeneity of a region can be dependent upon any characteristic of the region in the image: texture, color or average intensity. Seeded Region growing Region growing approach is the opposite of the split and merge approach: An initial set of small areas are iteratively merged according to similarity constraints.

Start by choosing an arbitrary seed pixel and compare it with neighbouring pixels Region is grown from the seed pixel by adding in neighbouring pixels that are similar, increasing the size of the region. When the growth of one region stops we simply choose another seed pixel which does not yet belong to any region and start again. This whole process is continued until all pixels belong to some region. A bottom up method.

Region growing methods often give very good segmentations that correspond well to the observed edges.

28 Fig.3.3 Example of region growing However starting with a particular seed pixel and letting this region grow completely before trying other seeds biases the segmentation in favour of the regions which are segmented first.

This can have several undesirable effects:

Current region dominates the growth process -- ambiguities around edges of adjacent regions may not be resolved correctly. Different choices of seeds may give different segmentation results. Problems can occur if the (arbitrarily chosen) seed point lies on an edge.

To counter the above problems, simultaneous region growing techniques have been developed.

Similarities of neighbouring regions are taken into account in the growing process. No single region is allowed to completely dominate the proceedings. A number of regions are allowed to grow at the same time. o similar regions will gradually coalesce into expanding regions. Control of these methods may be quite complicated but efficient methods have been developed. Easy and efficient to implement on parallel computers.

An extensive and comparative study Problems and overcoming method Seeded region growing (SRG) algorithm is very attractive for semantic image segmentation by involving high-level knowledge of image components in the seed selection procedure. However, the SRG algorithm also suffers from the problems of pixel sorting orders for labeling and automatic seed selection. An obvious way to improve the SRG algorithm is to provide more effective pixel labeling technique and automate the process of seed selection. To provide such a framework. we design an automatic SRG algorithm, along with a boundary-oriented parallel pixel

29 labeling technique and an automatic seed selection method. Moreover, a seed tracking algorithm is proposed for automatic moving object extraction. The region seeds, which are located inside the temporal change mask, are selected for generating the regions of moving objects. Experimental evaluation shows good performances of our technique on a relatively large variety of images without the need of adjusting parameters.

Algorithm Steps: Region growing segmentation Edge-based segmentation: borders between regions Region-based segmentation: direct construction of regions It is easy to construct regions from their borders and it is easy to detect borders of existing regions. Segmentations resulting from edgebased methods and region growing methods are not usually exactly the same. Region growing techniques are generally better in noisy images where edges are extremely difficult to detect. The criteria for homogeneity: Gray level Color, texture Shape Model etc. Regions have already been defined Homogeneity of regions is used as the main segmentation criterion in region growing.

Further assumptions:

30

Resulting regions of the segmented image must be both homogeneous and maximal.

Region-Oriented Segmentation Region Growing Region growing is a procedure that groups pixels or subregions into larger regions. The simplest of these approaches is pixel aggregation, which starts with a set of seed points and from these grows regions by appending to each seed points those neighboring pixels that have similar properties (such as gray level, texture, color, shape). Region growing based techniques are better than the edge-based techniques in noisy images where edges are difficult to detect.

Region growing: a recursive approach This is the counterpart of the edge linking mechanism which is based on local comparison of pixel properties without reference to a more global viewpoint. Regions (or pixels) should be merged if they are homogeneous, i.e. have similar grey level intensity, colour, texture, depth etc. In a segmented image,

31

where S is the number of regions in the image, and

is a Boolean

homogeneity evaluation of region i, based normally on a statistical measure such as the standard deviation of the grey levels about the mean pixel intensity. In the segmented image, regions must be be both homogeneous and maximal, by which we mean that the homogeneity criteria would cease to be true if adjacent regions were merged. First we consider a recursive algorithm (iterative equivalents scan the image top to bottom, left to right) based on a 4-connected model of image connectivity.

fig 3.5 4-connected where pixel, and , , and denotes the current

denote the upper, left, lower (down) and right pixels

respectively in a 4-connected image matrix. (In an 8-connected matrix the central pixel would also be connected to the diagonal pixels.) The object is to compare the current pixel to each of the adjacent pixels to see if it can be added to an existing region. The algorithm is expressed with reference to a grey scale image. An initial pixel must be found. This may satisfy some predetermined criteria, e.g. start with the most red or brightest pixel, or may start from some predetermined location, e.g. the centre of the image. When the recursive function terminates, there will, in general, be a group of pixels conjoined to form a labelled region with property I. The process must be repeated for another start pixel with similar or different property value. For example, if the goal was colour segmentation it might be appropriate to form the red regions, then when no more red pixels can be found to form the green regions and so on. Pixel-Based Segmentation using Region-Growing

32 Region-based methods are complementary to the edge-based methods. In this method the region-growing is performed as a preprocessing stage. Unsupervised clustering is performed on the image, resulting in isolated regions of similarity, which are then used in the subsequent segmentation. The presence of anomalous pixels in a region can then be used as evidence for the region belonging to the foreground, and region models can be developed as before. A possible advantage to this technique is that similar pixels are spatially linked prior to any processing being done, which should encourage connectivity of segmented regions. This would require high sensitivity on the parameters of the initial clustering. Region growing is an approach to image segmentation in which neighboring pixels are examined and added to a region class if no edges are detected. This process is iterated for each boundary pixel in the region. If adjacent regions are found, a region-merging algorithm is used in which weak edges are dissolved and strong edges are left in tact. An example of how a region is grown a The seeds are found using specific criteria b The seeds are selected as the starting point of a region. c All neighbouring pixels of the seeds with similar characteristics are included in the region. d All other pixels surrounding the region which also have similar characteristics to the region are included into the region. e & f Repeat section (d) until all pixels have been grown. 3.3 Color Image Segmentation Using a Region Growing Method Common approaches for color image segmentation are clustering algorithms such as k-means or Mixture of Principal Components , however these algorithms do not take spatial information into account. Furthermore, clustering algorithms require prior information regarding number of clusters, which is a difficult or ambiguous task, requiring the assertion of some criterion on the very nature of the

33 clusters being formed. Some progress has been made on this issue, however much experimentation still needs to be done An alternative set of algorithms exists which uses color similarity and a regiongrowing approach to spatial information . Region growing is based on the following principles. The algorithm starts with a seed pixel, examines local pixels around it, determines the most similar one, which is then included in the region if it meets certain criteria. This process is followed until no more pixels can be added. The definition of similarity may be set in any number of different ways. Region growing algorithms have been used mostly in the analysis of grayscale images; however, some significant work has been completed in the color realm by Tremeau et al. They discuss the segmentation of color regions which are homogeneous in color (i.e., no illumination effects are considered) thus restricting the application domain. They use a set of thresholds when calculating whether a color pixel is part of a region or not, and the Euclidean distance is used a as the measure of similarity between two color vectors. Region Growing Algorithm

A region growing algorithm is proposed in this paper based on the vector angle color similarity measure and the use of the principal component of the covariance matrix as the "characteristic" color of the region, with the goal of a region-based segmentation which is perceptually-based. The algorithm is presented as follows: 1. Select seed pixels within the image. 2. From each seed pixel grow a region: 2.1. Set the region prototype to be the seed pixel; 2.2.Calculate the similarity between the region prototype and the candidate pixel; 2.3. Calculate the similarity between the candidate and its nearest neighbor in the region; 2.4. Include the candidate pixel if both similarity measures are higher than experimentally-set thresholds; 2.5. Update the region prototype by calculating the new principal component; 2.6. Adantages: Go to the next pixel to be examined.

34 This algorithm presents several advantages over other color image segmentation algorithms. First, it is based on the concept of color vector angle. The vector angle is a shading-invariant color similarity measure, implying that intensity variations will be discounted in the region growing process, which is clearly not the case when using the Euclidean distance. Secondly, since spatial information is taken into account, regions having a slightly different color, but still spatially distinct, should appear as separate regions due to the region growing process. Disadvantages: Clearly a significant disadvantage of this approach to color image segmentation algorithm is need for seed pixels, and careful consideration needs to be given to the selection of those pixels. Alternative approaches include finding those pixels in the color image with the greatest intensity, or to use the MPC algorithm to select the seeds based on the clustering result.

Fig 3.12 Sagittal orientation of Brain 3.4 Splitting and Merging Region Splitting Region growing starts from a set of seed points. An alternative is to start with the whole image as a single region and subdivide the regions that do not satisfy a condition of homogeneity. Region Merging Region merging is the opposite of region splitting. Start with small regions (e.g. 2x2 or 4x4 regions) and merge the regions that have similar characteristics (such as gray level, variance).

35 Typically, splitting and merging approaches are used iteratively.

Splitting and merging attempts to divide an image into uniform regions. The basic representational structure is pyramidal, i.e. a square region of size m by m at one level of a pyramid has 4 sub-regions of size by below it in the pyramid. Usually

the algorithm starts from the initial assumption that the entire image is a single region, then computes the homogeneity criterion to see if it is TRUE. If FALSE, then the square region is split into the four smaller regions. This process is then repeated on each of the sub-regions until no further splitting is necessary. These small square regions are then merged if they are similar to give larger irregular regions. The problem (at least from a programming point of view) is that any two regions may be merged if adjacent and if the larger region satisfies the homogeneity criteria, but regions which are adjacent in image space may have different parents or be at different levels (i.e. different in size) in the pyramidal structure. The process terminates when no further merges are possible.

Fig 3.13 Quad splitting of an image Although it is common to start with the single region assumption, it is possible to start at an intermediate level, e.g. 16 regions or whatever. In the latter case, it is possible that 4 regions may be merged to form a parent region. For simplicity, assume we start with a single region, i.e. the whole image. Then, the process of

36 splitting is simple. A list of current regions to be processed, i.e. regions defined as not homogeneous is maintained. When a region is found to be homogeneous it is removed from the ProcessList and placed on a RegionList. Uniformity is determined on the basis of homogeneity of property as in the previous examples. For a grey level image, say, a region is said to be statistically homogeneous if the standard deviation of the intensity less than some threshold value, where the standard deviation is given by,

and is the mean intensity of the N pixels in the region. Whereas splitting is quite simple, merging is more complex. Different algorithms are possible, some use the same test for homogeneity but others use the difference in average values. Generally, pairs of regions are compared, allowing more complex shapes to emerge. A program in use at Heriot-Watt is spam ( split and merge) which takes regions a pair at a time and uses the difference of averages to judge similarity, i.e. merge region A with neighbouring region B if the difference in average intensities of A and B is below a threshold. Thresholding Gray level thresholding is the simplest segmentation process. Many objects or image regions are characterized by constant reflectivity or light absorption of their surface. Thresholding is computationally inexpensive and fast and can easily be done in real time using specialized hardware.

37 A complete segmentation of an image R is a finite set of regions R1, . . .RS,

For

binary

images,

there

is

a

single

threshold:

Search all the pixels f(i,j) of the image f. An image element g(i,j) of the segmented image is an object pixel if f(i,j) >=T, and is a background pixel otherwise. In many vision applications, it is useful to be able to separate out the regions of the image corresponding to objects in which we are interested, from the regions of the image that correspond to background. Thresholding often provides an easy and convenient way to perform this segmentation on the basis of the different intensities or colors in the foreground and background regions of an image. In addition, it is often useful to be able to see what areas of an image consist of pixels whose values lie within a specified range, or band of intensities (or colors). Thresholding can be used for this as well. Working: The input to a thresholding operation is typically a grayscale or color image. In the simplest implementation, the output is a binary image representing the segmentation. Black pixels correspond to background and white pixels correspond to foreground (or vice versa). In simple implementations, the segmentation is determined by a single parameter known as the intensity threshold. In a single pass, each pixel in the image is compared with this threshold. If the pixel's intensity is higher than the threshold, the pixel is set to, say, white in the output. If it is less than the threshold, it is set to black.

38 In more sophisticated implementations, multiple thresholds can be specified, so that a band of intensity values can be set to white while everything else is set to black. For color or multi-spectral images, it may be possible to set different thresholds for each color channel, and so select just those pixels within a specified cuboid in RGB space. Another common variant is to set to black all those pixels corresponding to background, but leave foreground pixels at their original color/intensity (as opposed to forcing them to white), so that that information is not lost. Guidelines for Use Not all images can be neatly segmented into foreground and background using simple thresholding. Whether or not an image can be correctly segmented this way can be determined by looking at an intensity histogram of the image. We will consider just a grayscale histogram here, but the extension to color is trivial. If it is possible to separate out the foreground of an image on the basis of pixel intensity, then the intensity of pixels within foreground objects must be distinctly different from the intensity of pixels within the background. In this case, we expect to see a distinct peak in the histogram corresponding to foreground objects such that thresholds can be chosen to isolate this peak accordingly. If such a peak does not exist, then it is unlikely that simple thresholding will produce a good segmentation. In this case, adaptive thresholding may be a better answer.

39 Multithresholding resulting image is no longer binary

Semithresholding aims to mask out the image background leaving gray level information present in the objects

Thresholding This technique is based upon a simple concept. A parameter called the brightness threshold is chosen and applied to the image a[m,n] as follows:

This version of the algorithm assumes that we are interested in light objects on a dark background. For dark objects on a light background we would use:

The output is the label "object" or "background" which, due to its dichotomous nature, can be represented as a Boolean variable "1" or "0". In principle, the test

40 condition could be based upon some other property than simple brightness (for example, If (Redness{a[m,n]} >=red

), but the concept is clear.

Threshold techniques are based on the thresholds which are normally selected from the image histogram. It is said that all pixels whose values (this value can be either gray intensity, color, or any number of other features) are between two values of thresholds belong to one region. The fact that the thresholds are derived from the histogram says that these techniques dont take into account spatial information of the image and therefore, incur problems to do with noise as well as with blurred edges in the image. To go from image edges to the image boundaries is an extremely difficult task.

The central question in thresholding then becomes: ow do we choose the threshold ? While there is no universal procedure for threshold selection that is guaranteed to work on all images, there are a variety of alternatives. * Fixed threshold - One alternative is to use a threshold that is chosen independently of the image data. If it is known that one is dealing with very highcontrast images where the objects are very dark and the background is homogeneous and very light, then a constant threshold of 128 on a scale of 0 to 255 might be sufficiently accurate. By accuracy we mean that the number of falsely-classified pixels should be kept to a minimum. * Histogram-derived thresholds - In most cases the threshold is chosen from the brightness histogram of the region or image that we wish to segment. Two pixels based segmentation methods are applied in our proposed method. One is histogram statistics and the other is K-, means clustering Histogram Based segmentation:

41 In an image processing context, the histogram of an image normally refers to a histogram of the pixel intensity values. This histogram is a graph showing the number of pixels in an image at each different intensity value found in that image. For an 8-bit grayscale image there are 256 different possible intensities, and so the histogram will graphically display 256 numbers showing the distribution of pixels amongst those grayscale values. Histograms can also be taken of color images --either individual histograms of red, green and blue channels can be taken, or a 3-D histogram can be produced, with the three axes representing the red, blue and green channels, and brightness at each point representing the pixel count. The exact output from the operation depends upon the implementation --- it may simply be a picture of the required histogram in a suitable image format, or it may be a data file of some sort representing the histogram statistics.

How It Works The operation is very simple. The image is scanned in a single pass and a running count of the number of pixels found at each intensity value is kept. This is then used to construct a suitable histogram. Histograms have many uses. One of the more common is to decide what value of threshold to use when converting a grayscale image to a binary one by thresholding. If the image is suitable for thresholding then the histogram will be bimodal --- i.e. the pixel intensities will be clustered around two well-separated values. A suitable threshold for separating these two groups will be found somewhere in between the two peaks in the histogram. If the distribution is not like this then it is unlikely that a good segmentation can be produced by thresholding. Thresholding is used to segment an image by setting all pixels whose intensity values are above a threshold to a foreground value and all the remaining pixels to a background value.

42 Whereas the conventional thresholding operator uses a global threshold for all pixels, adaptive thresholding changes the threshold dynamically over the image. This more sophisticated version of thresholding can accommodate changing lighting conditions in the image, e.g. those occurring as a result of a strong illumination gradient or shadows. We usually try to segment regions by identifying common properties.

The simplest property that pixels in a region can share is intensity. So, a natural way to segment such regions is through thresholding, the separation of light and dark regions. Thresholding creates binary images from grey-level ones by turning all pixels below some threshold to zero and all pixels about that threshold to one. (What you want to do with pixels at the threshold doesn't matter, as long as you're consistent.) If is a thresholded version of g(x,y)= 1 =0 if f(x,y)>t at some global threshold t,

otherwise

Problems with Thresholding The major problem with thresholding is that we consider only the intensity, not any relationships between the pixels. There is no guarantee that the pixels identified by the thresholding process are contiguous. We can easily include extraneous pixels that aren't part of the desired region, and we can just as easily miss isolated pixels within the region (especially near the boundaries of the region). These effects get worse as the noise gets worse, simply because it's more likely that a pixels intensity doesn't represent the normal intensity in the region.

43 When we use thresholding, we typically have to play with it, sometimes losing too much of the region and sometimes getting too many extraneous background pixels. (Shadows of objects in the image are also a real pain--not just where they fall across another object but where they mistakenly get included as part of a dark object on a light background.)

K-means Clustering Algorithm Simply speaking k-means clustering is an algorithm to classify or to group your objects based on attributes/features into K number of group. K is positive integer number. The grouping is done by minimizing the sum of squares of distances between data and the corresponding cluster centroid. Thus the purpose of K-mean clustering is to classify the data. The basic step of k-means clustering is simple. In the beginning we determine number of cluster K and we assume the centroid or center of these clusters. We can take any random objects as the initial centroids or the first K objects in sequence can also serve as the initial centroids.

The K means algorithm will do the four steps below until convergence Iterate until stable (= no object move group): 1. 2. 3. Determine the centroid coordinate Determine the distance of each object to the centroids Group the object based on minimum distance

44 Step 1. Begin with a decision on the value of k = number of clusters Step 2. Put any initial partition that classifies the data into k clusters. You may assign the training samples randomly, or systematically as the following: a. b. cluster. Step 3 . Take each sample in sequence and compute its distance from the centroid of each of the clusters. If a sample is not currently in the cluster with the closest centroid, switch this sample to that cluster and update the centroid of the cluster gaining the new sample and the cluster losing the sample. Step 4 . Repeat step 3 until convergence is achieved, that is until a pass through the training sample causes no new assignments. Since we are not sure about the location of the centroid, we need to adjust the centroid location based on the current updated data. Then we assign all the data to this new centroid. This process is repeated until no data is moving to another cluster anymore. Mathematically this loop can be proved to be convergent. The convergence will always occur if the following condition satisfied: 1. Each switch in step 2 the sum of distances from each training sample to that training sample's group centroid is decreased. 2. There are only finitely many partitions of the training examples into k clusters. Various metrics to the centroids that can be minimized include

Take the first k training sample as single-element clusters Assign each of the remaining (N-k) training sample to the cluster with the

nearest centroid. After each assignment, recomputed the centroid of the gaining

maximum distance to its centroid for any object. sum of the average distance to the centroids over all clusters.

45

sum of the variance over all clusters. total distance between all objects and their centroids.

The metric to minimize and the choice of a distance measure will determine the shape of the optimium clusters. Two procedures are available to search for the optimum set of clusters. The first assigns each object to a cluster and the second sets initial positions for the cluster centroids. In the first procedure, the objects are randomly assigned to one of the K clusters. Once this is done, the position of the K centroids are determined, as is the value of the metric to minimize. A global optimization method is then used to reassign some of the objects to different clusters. New centroids are determined, as is the metric to minimize. This procedure is continued until (hopefully) the optimum assignment of objects to clusters is found. In the second procedure for K-means clustering, placement of the K centroids can be done by the following procedure. 1. Place K points into the space represented by the objects that are being clustered. These points represent initial group centroids. 2. 3. centroids 4. repeat step 2 and 3 until the centroids no longer move This produces a separation of the objects into groups from which the metric to be minimized can be calculated. Assign each object to the group that has the closest centroid. When all objects have been assigned, recalculate the positions of k-

46 A global optimization method is then used to move the position of one or more of the centroids. The above procedure is repeated and new metric is determined. The object is to move the centroids into a position such that an optimum separation of objects into groups occurrs. There are several variants of the k-means clustering algorithm, but most variants involve an iterative scheme that operates over a fixed number of clusters, while attempting to satisfy the following properties: 1. Each class has a center which is the mean position of all the samples in that class. Each sample is in the class whose center it is closest to.

Algorithm steps K-means Clustering Algorithm: K-Means algorithm is an unsupervised clustering algorithm that classifies the input data points into multiple classes based on their inherent distance from each other. The algorithm assumes that the data features form a vector space and tries to find natural clustering in them. The points are clustered around centroids which are obtained by minimizing the objective

As a part of this project, an iterative version of the algorithm was implemented. The algorithm takes a 2 dimensional image as input. Various steps in the algorithm are as follows: 1. Compute the intensity distribution(also called the histogram) of the intensities. 2. Initialize the centroids with k random intensities.

47 3. Repeat the following steps until the cluster labels of the image does not change anymore. 4. Cluster the points based on distance of their intensities from the centroid intensities.

5. Compute the new centroid for each of the clusters.

where k is a parameter of the algorithm (the number of clusters to be found), i iterates over the all the intensities, j iterates over all the centroids and centroid intensities. The basic k-means algorithm consists of the following steps: K-Means Algorithm Pick k centers randomly K-Means Iterations Assign every point to the closest center Compute the center of every cluster to replace the old one Stop the algorithm if the centers are stable are the

Initialize Loop until termination condition is met: 1. For each pixel in the image, assign that pixel to a class such that the distance from this pixel to the center of that class is minimized. 2. For each class, recalculate the means of the class based on the pixels that belong to that class.

48

end loop; Demonstration of the algorithm The following images demonstrate the k-means clustering algorithm in action, for the two-dimensional case. The initial centres are generated randomly to demonstrate the stages in more detail. The background space partitions are only for illustration and are not generated by the k-means algorithm.

Now the intialSteps 2 & 3 are Shows the initialPoints are associatedrandomized points arerepeated until a randomized pointwith the nearestmoved to the center ofsuitable level of randomized and a number ofinitial their respectiveconvergence has been point. points. clusters(the centroids). reached.

Initialization of K-means K-means results are highly dependent on the initialization procedure used. There are a number of different ways to initialize the algorithm: 1. Arbitrarily assign classes to pixels The straightforward way to do this is to assign the ith pixel to the i modulo kth class. This is a good approach when the number of channels is greater than the number of classes. You may need a large number of bits of precision just for the first few iterations -- to ensure that there is some distance between the different means. For this reason, it works better in software than hardware. 2. Distribute the mean table around the color space

49 This is a good approach if the number of channels is less than the number of classes. Otherwise it is difficult to distribute the means. 3. Initialize mean values with random pixels from the image.

To initialize k classes, choose k pixels at random from the image. (Note -- they don't need to be that random.) Make sure that the pairwise distance between the k distance is large enough. How to ensure that 2 pixels are sufficiently far away from each other ? One (compute intensive) way to do this is to choose p pixels at random from the image ( where p >> k but smaller than all the pixels in the image) and then do k means clustering on those p pixels. Distance Measure The meat of the k-means algorithm is calculating the distance between each pixel and each class center. There are different distance measures that can be used. The most common are:

L1 distance (Manhattan distance): The absolute value of the componentwise

difference between the pixel and the class. This is the simplest distance to calculate and may be more robust to outliers.

L2 distance (Euclidean distance): The square root of the componentwise

square of the difference between the pixel and the class. Since we are only comparing the results, you can omit the square root. Computing the L2 distance requires squaring the data, which introduces extra bits of precision into the data. The squaring operation is expensive in hardware. One advantage of this metric is that the distance is a sphere around the centroid. How to measure quality of a classification One issue is how to measure the quality of the results provided by k-means classification. We use some internal measures:

50 A good classification has: 1. Low within class variance -- compactness 2. High distance between class centers -- isolation Simple pixel based classifiers Simple pixel based classifiers originated in the 1970's, and were designed for multispectral data. They can be divided into two different types, supervised and unsupervised. Supervised classifiers require the user to decide which classes exist in the image, and then to delineate samples of these classes. These samples (known as training areas) are then input into a classification program, which produces a classified image. Unsupervised classification does not require training areas, just the number of classes you would like to end up with. You should be aware, though, that the classes an unsupervised classifier creates may be quite different from the classes a human would identify. Types of Unsupervised Classifiers 1. K-Means This method works by choosing random seeds, which can be though of as points with random DN values. After the seeds have been chosen lines are formed to separate the classes. Next, the points lying within the delineated areas are analysed, and their means are noted. The means then form the new seeds, and a new series of lines are formed to separate the classes. This process is then repeated several times. 2. Fuzzy C Means Very similar to K-Means, but fuzzy logic is incorporated.

3. Isodata A more sophisticated version of the K-Means classifier which allows classes to be created and destroyed.

51

4 . Global k-means clustering: The simplest form of clustering is partitional clustering which aims at partitioning a given data set into disjoint subsets (clusters) so that specifc clustering criteria are optimized. The most widely used criterion is the clustering error criterion which for each point computes its squared distance from the corresponding cluster center and then takes the sum of these distances for all points in the data set. A popular clustering method that minimizes the clustering error is the k-means algorithm. However, the k-means algorithm is a local search procedure and it is well known that it suffers from the serious drawback that its performance heavily depends on the initial starting conditions . To treat this problem several other techniques have been developed that are based on stochastic global optimization methods (e.g. simulated annealing, genetic algorithms). However, it must be noted that these techniques have not gained wide acceptance and in many practical applications the clustering method that is used is the k-means algorithm with multiple restarts .The global k-means clustering algorithm, which constitutes a deterministic effective global clustering algorithm for the minimization of the clustering error that employs the k-means algorithm as a local search procedure. The algorithm proceeds in an incremental way: to solve a clustering problem with M clusters, all intermediate problems with 1; 2; : : : ; M 1 clusters are sequentially solved. The basic idea underlying the proposed method is that an optimal solution for a clustering problem with M clusters can be obtained using a series of local searches (using the k-means algorithm). At each local search the M 1 cluster centers are always initially placed at their optimal positions corresponding to the clustering problem with M 1 clusters. The remaining Mth cluster center is initially placed at several positions within the data space. Since for M =1 the optimal solution is known, we can iteratively apply the above procedure to 2nd optimal solutions for all k-clustering problems k =1; : : : ; M. In addition to effectiveness, the method is

52 deterministic and does not depend on any initial conditions or empirically adjustable parameters.These are signi2cant advantages over all clustering approaches mentioned above. In the following section we start with a formal defnition of the clustering error and a brief description of the k-means algorithm and then we describe the proposed global k-means algorithm. Section 3 describes modifcations of the basic method that require less computation at the expense of being slightly less effective. Color Image Segmentation Using a Spatial K-Means Clustering Algorithm Image segmentation is one of the most important precursors for image processingbased applications and has a crucial impact on the overall performance of the developed systems. Robust segmentation has been the subject of research for many years, but the published work indicates that most of the developed image segmentation algorithms have been designed in conjunction with particular applications. The aim of the segmentation process consists of dividing the input image into several disjoint regions with similar characteristics such as color and texture. Robust image segmentation is a difficult task since often the scene objects are defined by image regions with non-homogenous texture and color characteristics and in order to divide the input image into semantically meaningful regions many developed algorithms either use a priori knowledge in regard to the scene objects or employ the parameter estimation for local texture. The development of texture alone approaches proved to be limited and the use of color information in the development of joint color-texture models has led to the development of more robust and generic segmentation algorithms . The area of color image analysis is one of the most active topics of research and a large number of color-driven segmentation techniques have been proposed. Most representative color segmentation techniques include histogram-based segmentation, probabilistic space partitioning and clustering , region growing, Markov random field and simulated annealing. All these techniques have the aim to reduce the number of color components from the input image into a reduced number of components in the color segmented image that are strongly related to the image objects.

53 In this paper we have developed a new technique that is a generalization of the standard K-Means clustering technique. The K-Means clustering technique is a well-known approach that has been applied to solve low-level image segmentation tasks. This clustering algorithm is convergent and its aim is to optimize the partitioning decisions based on a user-defined initial set of clusters Image segmentation is one of the most important precursors for image processingbased applications and has a crucial impact on the overall performance of the developed systems. Robust segmentation has been the subject of research for many years, but the published work indicates that most of the developed image segmentation algorithms have been designed in conjunction with particular applications. The aim of the segmentation process consists of dividing the input image into several disjoint regions with similar characteristics such as color and texture. Robust image segmentation is a difficult task since often the scene objects are defined by image regions with non-homogenous texture and color characteristics and in order to divide the input image into semantically meaningful regions many developed algorithms either use a priori knowledge in regard to the scene objects or employ the parameter estimation for local texture. The development of texture alone approaches proved to be limited and the use of color information in the development of joint color-texture models has led to the development of more robust and generic segmentation algorithms . The area of color image analysis is one of the most active topics of research and a large number of color-driven segmentation techniques have been proposed. Most representative color segmentation techniques include histogram-based segmentation, probabilistic space partitioning and clustering , region growing, Markov random field and simulated annealing. All these techniques have the aim to reduce the number of color components from the input image into a reduced number of components in the color segmented image that are strongly related to the image objects. In this project we have developed a new technique that is a generalization of the standard K-Means clustering technique. The K-Means clustering technique is a well-known approach that has been applied to solve low-level image segmentation

54 tasks. This clustering algorithm is convergent and its aim is to optimize the partitioning decisions based on a user-defined initial set of clusters As mentioned before, the aim of the K-Means is the minimization of an objective function that samples the closeness between the data points and the cluster centers, and is calculated as follows:

2 x j i ic e ls u s t e r jeo i lt' e m n s f ts h c l u t e r Clustering and Thresholding A pixel based clustering is a generalization of thresholding that can be used for both gray level and multi-band images (for instance, color images). k-means Clustering k-means Clustering performs pixel-based segmentation of multi-band images. An image stack is interpreted as a set of bands corresponding to the same image. For instance, an RGB color images has three bands: red, green, and blue. Each pixels is represented by an n-valued vector , where n is a number of bands, for instance, a 3-value vector [r,g,b] in case of a color image. Each cluster is defined by its centroid in n-dimensional space. Pixels are grouped by their proximity to cluster's centroids. Cluster centroids are determined using a heuristics: initially centroids are randomly initialized and then their location is interactively optimized. EXAMPLE of K-means K-Means Clustering 1. Partition the data points into K clusters randomly. Find the centroids of each cluster. 2. For each data point: Calculate the distance from the data point to each cluster. Assign the data point to the closest cluster. 3. Recompute the centroid of each cluster. 4. Repeat steps 2 and 3 until there is no further change in the assignment of data points (or in the centroids).

55

Image Segmentation Group similar components (such as, pixels in an image, image frames in a video) to obtain a compact representation. Applications: Finding tumors, veins, etc. in medical images, finding targets in satellite/aerial images, finding people in surveillance images, summarizing video, etc. Methods: Thresholding, K-means clustering, etc. Segmentation algorithms for monochrome images generally are based on one of two basic properties of gray-scale values: Discontinuity The approach is to partition an image based on abrupt changes in gray-scale levels. The principal areas of interest within this category are detection of isolated points, lines, and edges in an image. Similarity The principal approaches in this category are based on thresholding, region growing, and region splitting/merging.

Thresholding Suppose that an image, f(x,y), is composed of light objects on a dark backround, and the following figure is the histogram of the image.

Fig 5.1 Thresholding

56

Then, the objects can be extracted by comparing pixel values with a threshold T. Then, the objects can be extracted by comparing pixel values with a threshold T. Non-uniform illumination may change the histogram in a way that it becomes impossible to segment the image using a single global threshold. Choosing local threshold values may help. Region-Oriented Segmentation Region Growing Region growing is a procedure that groups pixels or subregions into larger regions. The simplest of these approaches is pixel aggregation, which starts with a set of seed points and from these grows regions by appending to each seed points those neighboring pixels that have similar properties (such as gray level, texture, color, shape). Region growing based techniques are better than the edge-based techniques in noisy images where edges are difficult to detect.

57

Fig5.2 classification

58

Fig5.3 Clustering Clustering methods K-Means Clustering One of the most popular and widely studied clustering algorithms to separate the input data in the Euclidian space is the K-Means clustering. It is a nonhierarchical technique that follows a simple and easy way to classify a given dataset through a certain number of clusters (we need to make an assumption for parameter k) that are known a priori. The K-Means algorithm is built using an iterative framework where the elements of the data are exchanged between clusters in order to satisfy the criteria of minimizing the variation within each cluster and maximizing the variation between clusters. When no elements are exchanged between clusters, the process is halted. The four steps of this algorithm are briefly described below:

59

Steps of the K-Means clustering algorithm: 1. Initialization define the number of clusters and randomly select the position of the centers for each cluster or directly generate k seed points as cluster centers. 2. Assign each data point to the nearest cluster center. 3. Calculate the new cluster centers for clusters receiving new data points and for clusters losing data points. 4. Repeat the steps 2 and 3 until a convergence criterion is met (when there is no exchange of data points between the k clusters). The aim of the K-Means is the minimization of an objective Function:

is the distance measure (usually Euclidian metric) between a data point and the cluster center c j (this is an indicator of the distance of the n data

points from the cluster centers). There are situations when the K-Means algorithm doesnt find the optimal solution corresponding to the global objective function J and in addition is sensitive to the initialisation process that selects the initial cluster centers that are usually randomly picked from input data. The main advantages of this algorithm are its simplicity and low computational cost, which allows it to run efficiently on large datasets. The main drawback is the fact that it does not systematically yield the same re