Top Banner
BRAIN TUMOR DETECTION USING COLOR SPACED K MEANS CLUSTERING SEGMENTATION 1
96

Brain Tumor Detection

May 29, 2017

Download

Documents

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Brain Tumor Detection

BRAIN TUMOR DETECTION USING

COLOR SPACED K MEANS CLUSTERING SEGMENTATION

1

Page 2: Brain Tumor Detection

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.

2

Page 3: Brain Tumor Detection

INTRODUCTION

An Introduction to Image Segmentation

Image 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

3

Page 4: Brain Tumor Detection

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 (ROI’s) are

often examined in detail, for example in multiple sclerosis (MS) studies. In order to

perform good quantitative studies, ROI’s within the brain must be well defined. In

traditional methods, a skilled operator manually outlines the ROI’s 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

4

Page 5: Brain Tumor Detection

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

it’s 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. gray scale single image segmentation

2. multispectral segmentation

Gray scale single image segmentation

The 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

5

Page 6: Brain Tumor Detection

threshold selection . In addition, the edges found are usually not closed such that

edge linking techniques are further required.

Multispectral segmentation

Segmentation 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 user-

interaction 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

6

Page 7: Brain Tumor Detection

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

complexity of the images

• Accurate and robust tissue classification is the basis for many applications such

as the quantitative analysis of tissue volume in healthy and diseased populations

Echo MR slice

7

Page 8: Brain Tumor Detection

Categories of image segmentation

Accurate 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. Classification based

2. Region based

3. 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

8

Page 9: Brain Tumor Detection

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 Segmentation

In 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

9

Page 10: Brain Tumor Detection

one to model the spatial interactions between neighboring voxels. The bias field

estimation problem is cast in a Bayesian framework and the expectation-

maximization (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.

10

Page 11: Brain Tumor Detection

Region-Based Segmentation

The 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

11

Page 12: Brain Tumor Detection

2. Watershed based segmentation

have also been proposed for MRI segmentation.

1. Split-and-merge based segmentation

In 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 Segmentation

Contour-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.

12

Page 13: Brain Tumor Detection

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 under-

segmentation, 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 object’s

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 object’s 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

13

Page 14: Brain Tumor Detection

.

Description of input data

MR 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

256×256×60 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 brain

Our 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

14

Page 15: Brain Tumor Detection

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 Applications

The 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. The quantification of tissue volumes

2. Diagnosis

3. localization of pathology

4. Study of anatomical structure

5. Treatment planning and

6. Computer-integrated surgery

Practical Applacations of Image segmentation

Medical 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

15

Page 16: Brain Tumor Detection

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) Region growing approaches,

2) Clustering approaches,

16

Page 17: Brain Tumor Detection

Thresholding

Thresholding 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 operator’s 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 present—healthy 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 .

17

Page 18: Brain Tumor Detection

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.

18

Page 19: Brain Tumor Detection

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 volume’s 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

19

Page 20: Brain Tumor Detection

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 .

Clustering

Clustering 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

20

Page 21: Brain Tumor Detection

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

21

Page 22: Brain Tumor Detection

.

22

Page 23: Brain Tumor Detection

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

23

Page 24: Brain Tumor Detection

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 Algorithm

The 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.

24

Page 25: Brain Tumor Detection

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

25

Page 26: Brain Tumor Detection

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 Segmentation

Region Growing

Introduction

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

26

Page 27: Brain Tumor Detection

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.

27

Page 28: Brain Tumor Detection

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

28

Page 29: Brain Tumor Detection

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 edge-

based 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. Homogeneity of regions is used as the main

segmentation criterion in region growing.

The criteria for homogeneity:

Gray level

Color, texture

Shape

Model

etc.

Regions have already been defined

Further assumptions:

29

Page 30: Brain Tumor Detection

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,

30

Page 31: Brain Tumor Detection

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 denotes the current

pixel, and , , and 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

31

Page 32: Brain Tumor Detection

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

32

Page 33: Brain Tumor Detection

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 region-

growing 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. Go to the next pixel to be examined.

Adantages:

33

Page 34: Brain Tumor Detection

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).

34

Page 35: Brain Tumor Detection

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

35

Page 36: Brain Tumor Detection

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.

36

Page 37: Brain Tumor Detection

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.

37

Page 38: Brain Tumor Detection

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.

38

Page 39: Brain Tumor Detection

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

39

Page 40: Brain Tumor Detection

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 don’t 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 high-

contrast 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:

40

Page 41: Brain Tumor Detection

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 bi-

modal --- 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.

41

Page 42: Brain Tumor Detection

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 at some global threshold t,

g(x,y)= 1 if f(x,y)>t

= 0 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.

42

Page 43: Brain Tumor Detection

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. Determine the centroid coordinate

2. Determine the distance of each object to the centroids

3. Group the object based on minimum distance

43

Page 44: Brain Tumor Detection

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. Take the first k training sample as single-element clusters

b. 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

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

• maximum distance to its centroid for any object.

• sum of the average distance to the centroids over all clusters.

44

Page 45: Brain Tumor Detection

• 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. Assign each object to the group that has the closest centroid.

3. When all objects have been assigned, recalculate the positions of k-

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.

45

Page 46: Brain Tumor Detection

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.

46

Page 47: Brain Tumor Detection

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 are the

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

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.

47

Page 48: Brain Tumor Detection

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.

Shows the initial randomized point and a number of points.

Points are associated with the nearest initial randomized point.

Now the intial randomized points are moved to the center of their respective clusters(the centroids).

Steps 2 & 3 are repeated until a suitable level of convergence has been 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

48

Page 49: Brain Tumor Detection

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:

49

Page 50: Brain Tumor Detection

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.

50

Page 51: Brain Tumor Detection

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

51

Page 52: Brain Tumor Detection

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

processing–based 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.

52

Page 53: Brain Tumor Detection

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

processing–based 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

53

Page 54: Brain Tumor Detection

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:

xj−µi2

j∈elements of i' th cluster∑

i∈clusters

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 Clustering1. 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).

54

Page 55: Brain Tumor Detection

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

55

Page 56: Brain Tumor Detection

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.

56

Page 57: Brain Tumor Detection

Fig5.2 classification

57

Page 58: Brain Tumor Detection

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:

58

Page 59: Brain Tumor Detection

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

doesn’t 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 result each time the algorithm is executed and the

resulting clusters depend on the initial assignments. The K-Means algorithm

maximizes inter-cluster (or minimizes intra-cluster) variance, but does not ensure

that the algorithm will not converge to local minima due to an improper starting

condition (initialization of the cluster centers).

K- means is a widely used clustering algorithm to partition data into k clusters.Clusteing this the process for grouping data points with similar feature vectors into a single cluster and for grouping data points with dissimilar feature vectors into different clusters. Let the feature vectors derived from l clustered data be X-{Xi/i=1,2---------l} .The generalized algorithem initiates k cluster centroids C={Cj/j=1,2,--------k} by randomly

59

Page 60: Brain Tumor Detection

selecting k feature vectors from X. Later the feature vectors are grouped are grouped into k clusters using a selected distance measure such Euclidean distance so that

d=mod(Xi-Cj).

Pseudo-color transformation :

Basically, feature space selection is a key issued in K-means clustering segmentation .the original MR brain image is rendered as a gray-level image that is insufficient to support fine features .to obtain more useful feature and enhance the visual density, the pro posed method applies pseudo-color transformation a mapping function that maps a gray-level pixel to a color-level pixel by a lookup table in a predefined color map. An RGB color map contains R, G, and B values for each item. The proposed method has adopted the standard RGB color map, which gradually maps gray-level values 0 to 255 into blue-to-green-to-red color.To retrieve important features to benefit the clustering process, the RGB color space is further converted to a CIELab color model(L*a*b*).the L*a*b* space consists of a luminosity layer L* ,a chromaticity-layer a*,which indicates where color falls along the red-green axis, and a chromaticity-layer b* ,which indicates where the color falls along the blue-yellow axis. The translating formula calculates the tri-stimulus coefficients first as

W=0.4303R+0.341G+0.1784B, Y=0.2219R+0.7068G+0.0713B, Z=0.0202R+0.1296G+0.9393B.

The CIELab color model is calculated as

L*=116(h(Y/Ys))-16,a*=500(h(W/Ws))-h(Y/Ys),b*=200(h(Y/Ys)-h(Z/Zs)),h (q)=3sqrt(q) q>0.008856 7.787q+16/116 q<=0.008856,

where Ys Ws and Zs are the standard stimulus coefficients .Both the a* and b* layers contain all required color information .there fore the proposed method then classifies the colors in the a*b* space using k means clustering .after the clustering process, the cluster containing an area of interest is selected as the primary segment .to eliminate the pixels which are not related to the interest in the selected

60

Page 61: Brain Tumor Detection

cluster, histogram clustering is applied by luminosity feature l* to derive the final segment result.

In the proposed method we convert a gray level MR brain image into an RGB color image first and then convert the RGB color image into a CIELab color model. Therefore, colors in both the* and b* spaces are feature vectors for K-means clustering .to demonstrate the detection performance of the proposed method, an MR brain image containing the pathological change area in the image served as a test image. The RGB color image converted from the gray-level image is shown in fig----. To prove that the feature vectors proposed by our method really can provide better segmentation performance, two different data sets were prepared; the gray feature vectors if the original MR brain image and the RGB features derived from the converted RGB color image .generally, an MR brain image consists of regions that represent the bone ,soft tissue, fat and background. In the gray and color test images suggest three primary clusters in the test image shown . When k=3 the image labeled by cluster index from the K-means process for different kinds of feature vectors. Using index labels, we can separate objects in the brain image by three colors: white, gray and black. The final segmentation results generated by histogram clustering are shown in k mean cluster image by combining the histogram cluster image we can see that not only a tumor is identified but also the white matter, cerebrospinal fluid, and the ventricles are. In other words, the segmentation result cannot exactly identify the position of the tumor shown in compared image.However, the segmentation result generated by the proposed method can ignore most of the white matter locating the position of the tumor. Therefore the segmentation performance of the proposed features derived from the CIELab color model and the propped method is confirmed.

Project Implementation

Image segmentation:

• Image Segmentation is the process of identifying features in images and

marking them as distinct from one another.

• Segmentation is separation of structures of interest from the Background and

each other

Another way of extracting and representing information from an image is to group pixels together into regions of similarity. This process is commonly called segmentation. In

2D -- we would group pixels together according to the rate of change of their intensity over a region.

61

Page 62: Brain Tumor Detection

3D -- we group together pixels according to the rate of change of depth in the image, corresponding to pixels lying on the same surface such as a plane, cylinder, sphere etc.

Implementation of K-means clustering

• The K-means clustering is a popular approach to partition d-dimensional data

into k-clusters

• The k-means clustering is quite sensitive to the initial cluster assignment and

the choice of distance measure

• Clustering is the process of of grouping data points with similar feature vectors

together in a single cluster

• Images can be segmented by pixel classification through clustering of features

of interest

• A feature vector may consists of gray value, contrast and local texture

measures for each pixel in the image

• Clustering may produce disjoint regions with holes or regions with a single

pixel

K-means is one of the simplest unsupervised learning algorithms that solve the

well known clustering problem. The procedure follows a simple and easy way to

classify a given data set through a certain number of clusters (assume k clusters)

fixed a priori. The main idea is to define k centroids, one for each cluster. These

centroids shoud be placed in a cunning way because of different location causes

different result. So, the better choice is to place them as much as possible far away

from each other. The next step is to take each point belonging to a given data set

and associate it to the nearest centroid. When no point is pending, the first step is

completed and an early groupage is done. At this point we need to re-calculate k

new centroids as barycenters of the clusters resulting from the previous step. After

we have these k new centroids, a new binding has to be done between the same

data set points and the nearest new centroid. A loop has been generated. As a result

of this loop we may notice that the k centroids change their location step by step

62

Page 63: Brain Tumor Detection

until no more changes are done. In other words centroids do not move any more.

Finally, this algorithm aims at minimizing an objective function, in this case a

squared error function. The objective function

,

where is a chosen distance measure between a data point and the

cluster centre , is an indicator of the distance of the n data points from their

respective cluster centres.

K- means is a widely used clustering algorithm to partition data into k clusters.Clusteing this the process for grouping data points with similar feature vectors into a single cluster and for grouping data points with dissimilar feature vectors into different clusters. Let the feature vectors derived from l clustered data be X-{Xi/i=1,2---------l} .The generalized algorithem initiates k cluster centroids C={Cj/j=1,2,--------k} by randomly selecting k feature vectors from X. Later the feature vectors are grouped are grouped into k clusters using a selected distance measure such Euclidean distance so thatd=mod(Xi-Cj).

The algorithm is composed of the following steps:

1. Place K points into the space represented by the objects that are being clustered. These points represent initial group centroids.

2. Assign each object to the group that has the closest centroid.3. When all objects have been assigned, recalculate the

positions of the K centroids.

63

Page 64: Brain Tumor Detection

4. Repeat Steps 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.

Although it can be proved that the procedure will always terminate, the k-means

algorithm does not necessarily find the most optimal configuration, corresponding

to the global objective function minimum. The algorithm is also significantly

sensitive to the initial randomly selected cluster centres. The k-means algorithm can

be run multiple times to reduce this effect.

Implementation of Region Growing

• 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.

64

Page 65: Brain Tumor Detection

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

observed edges.

Fig. 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.

65

Page 66: Brain Tumor Detection

• Control of these methods may be quite complicated but efficient methods have been developed.

• Easy and efficient to implement on parallel computers. •

DIGITAL IMAGE PROCESSING

BACKGROUND :

Digital image processing is an area characterized by the need for extensive

experimental work to establish the viability of proposed solutions to a given problem. An

important characteristic underlying the design of image processing systems is the

significant level of testing & experimentation that normally is required before arriving at

an acceptable solution. This characteristic implies that the ability to formulate approaches

&quickly prototype candidate solutions generally plays a major role in reducing the cost

& time required to arrive at a viable system implementation.

What is DIP?

An image may be defined as a two-dimensional function f(x, y), where x &

y are spatial coordinates, & the amplitude of f at any pair of coordinates (x, y) is called

the intensity or gray level of the image at that point. When x, y & the amplitude values

of f are all finite discrete quantities, we call the image a digital image. The field of DIP

refers to processing digital image by means of digital computer. Digital image is

composed of a finite number of elements, each of which has a particular location &

value. The elements are called pixels.

Vision is the most advanced of our sensor, so it is not surprising that image play

the single most important role in human perception. However, unlike humans, who are

limited to the visual band of the EM spectrum imaging machines cover almost the entire

66

Page 67: Brain Tumor Detection

EM spectrum, ranging from gamma to radio waves. They can operate also on images

generated by sources that humans are not accustomed to associating with image.

There is no general agreement among authors regarding where image processing

stops & other related areas such as image analysis& computer vision start. Sometimes a

distinction is made by defining image processing as a discipline in which both the input

& output at a process are images. This is limiting & somewhat artificial boundary. The

area of image analysis (image understanding) is in between image processing & computer

vision.

There are no clear-cut boundaries in the continuum from image processing at one

end to complete vision at the other. However, one useful paradigm is to consider three

types of computerized processes in this continuum: low-, mid-, & high-level processes.

Low-level process involves primitive operations such as image processing to reduce

noise, contrast enhancement & image sharpening. A low- level process is characterized

by the fact that both its inputs & outputs are images. Mid-level process on images

involves tasks such as segmentation, description of that object to reduce them to a form

suitable for computer processing & classification of individual objects. A mid-level

process is characterized by the fact that its inputs generally are images but its outputs are

attributes extracted from those images. Finally higher- level processing involves

“Making sense” of an ensemble of recognized objects, as in image analysis & at the far

end of the continuum performing the cognitive functions normally associated with human

vision.

Digital image processing, as already defined is used successfully in a broad range of

areas of exceptional social & economic value.

What is an image?

An image is represented as a two dimensional function f(x, y) where x and y are

spatial co-ordinates and the amplitude of ‘f’ at any pair of coordinates (x, y) is called the

intensity of the image at that point.

Gray scale image:

A grayscale image is a function I (xylem) of the two spatial coordinates of the

image plane.I(x, y) is the intensity of the image at the point (x, y) on the image plane.

67

Page 68: Brain Tumor Detection

I (xylem) takes non-negative values assume the image is bounded by a rectangle [0, a]

× [0, b]I: [0, a] × [0, b] → [0, info)

Color image:

It can be represented by three functions, R (xylem) for red, G (xylem) for

green and B (xylem) for blue.

An image may be continuous with respect to the x and y coordinates and

also in amplitude. Converting such an image to digital form requires that the coordinates

as well as the amplitude to be digitized. Digitizing the coordinate’s values is called

sampling. Digitizing the amplitude values is called quantization.

Coordinate convention:

The result of sampling and quantization is a matrix of real numbers. We use two

principal ways to represent digital images. Assume that an image f(x, y) is sampled so

that the resulting image has M rows and N columns. We say that the image is of size M X

N. The values of the coordinates (xylem) are discrete quantities. For notational clarity

and convenience, we use integer values for these discrete coordinates.

In many image processing books, the image origin is defined to be at

(xylem)=(0,0).The next coordinate values along the first row of the image are

(xylem)=(0,1).It is important to keep in mind that the notation (0,1) is used to signify the

second sample along the first row. It does not mean that these are the actual values of

physical coordinates when the image was sampled. Following figure shows the

coordinate convention. Note that x ranges from 0 to M-1 and y from 0 to N-1 in integer

increments.

The coordinate convention used in the toolbox to denote arrays is different from the

preceding paragraph in two minor ways. First, instead of using (xylem) the toolbox uses

the notation (race) to indicate rows and columns. Note, however, that the order of

coordinates is the same as the order discussed in the previous paragraph, in the sense that

the first element of a coordinate topples, (alb), refers to a row and the second to a column.

68

Page 69: Brain Tumor Detection

The other difference is that the origin of the coordinate system is at (r, c) = (1, 1); thus, r

ranges from 1 to M and c from 1 to N in integer increments. IPT documentation refers to

the coordinates. Less frequently the toolbox also employs another coordinate convention

called spatial coordinates which uses x to refer to columns and y to refers to rows. This is

the opposite of our use of variables x and y.

Image as Matrices:

The preceding discussion leads to the following representation for a digitized image

function:

f (0,0) f(0,1) ……….. f(0,N-1)

f(1,0) f(1,1) ………… f(1,N-1)

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

. ................... .................. .....

f(M-1,0) f(M-1,1) ………… f(M-1,N-1)

The right side of this equation is a digital image by definition. Each element

of this array is called an image element, picture element, pixel or pel. The terms image

and pixel are used throughout the rest of our discussions to denote a digital image and its

elements.

A digital image can be represented naturally as a MATLAB matrix:

f(1,1) f(1,2) ……. f(1,N)

f(2,1) f(2,2) …….. f(2,N)

. . .

f = . . .

69

Page 70: Brain Tumor Detection

f(M,1) f(M,2) …….f(M,N)

Where f(1,1) = f(0,0) (note the use of a moonscape font to denote MATLAB

quantities). Clearly the two representations are identical, except for the shift in origin.

The notation f (p ,q) denotes the element located in row p and the column q. For example

f (6, 2) is the element in the sixth row and second column of the matrix f. Typically we

use the letters M and N respectively to denote the number of rows and columns in a

matrix. A 1xN matrix is called a row vector whereas an Mx1 matrix is called a column

vector. A 1x1 matrix is a scalar.

Matrices in MATLAB are stored in variables with names such as A, a, RGB, real

array and so on. Variables must begin with a letter and contain only letters, numerals and

underscores. As noted in the previous paragraph, all MATLAB quantities are written

using mono-scope characters. We use conventional Roman, italic notation such as f(x ,y),

for mathematical expressions

Reading Images:

Images are read into the MATLAB environment using function imread whose

syntax is

imread(‘filename’)

Format name Description recognized extension

TIFF Tagged Image File Format .tif, .tiff

JPEG Joint Photograph Experts Group .jpg, .jpeg

GIF Graphics Interchange Format .gif

BMP Windows Bitmap .bmp

70

Page 71: Brain Tumor Detection

PNG Portable Network Graphics .png

XWD X Window Dump .xwd

Here filename is a spring containing the complete of the image file(including any

applicable extension).For example the command line

>> f = imread (‘8. jpg’);

reads the JPEG (above table) image chestxray into image array f. Note the use of single

quotes (‘) to delimit the string filename. The semicolon at the end of a command line is

used by MATLAB for suppressing output. If a semicolon is not included. MATLAB

displays the results of the operation(s) specified in that line. The prompt symbol (>>)

designates the beginning of a command line, as it appears in the MATLAB command

window.

When as in the preceding command line no path is included in filename, imread

reads the file from the current directory and if that fails it tries to find the file in the

MATLAB search path. The simplest way to read an image from a specified directory is to

include a full or relative path to that directory in filename.

For example,

>> f = imread ( ‘D:\myimages\chestxray.jpg’);

reads the image from a folder called my images on the D: drive, whereas

>> f = imread(‘ . \ myimages\chestxray .jpg’);

reads the image from the my images subdirectory of the current of the current

working directory. The current directory window on the MATLAB desktop toolbar

displays MATLAB’s current working directory and provides a simple, manual way to

change it. Above table lists some of the most of the popular image/graphics formats

supported by imread and imwrite.

71

Page 72: Brain Tumor Detection

Function size gives the row and column dimensions of an image:

>> size (f)

ans = 1024 * 1024

This function is particularly useful in programming when used in the following

form to determine automatically the size of an image:

>>[M,N]=size(f);

This syntax returns the number of rows(M) and columns(N) in the image.

The whole function displays additional information about an array. For instance ,the

statement

>> whos f

gives

Name size Bytes Class

F 1024*1024 1048576 unit8 array

Grand total is 1048576 elements using 1048576 bytes

The unit8 entry shown refers to one of several MATLAB data classes. A semicolon

at the end of a whose line has no effect ,so normally one is not used.

Displaying Images:

Images are displayed on the MATLAB desktop using function imshow, which has

the basic syntax:

72

Page 73: Brain Tumor Detection

imshow(f,g)

Where f is an image array, and g is the number of intensity levels used to

display it. If g is omitted ,it defaults to 256 levels .using the syntax

imshow(f,{low high})

Displays as black all values less than or equal to low and as white all values

greater than or equal to high. The values in between are displayed as intermediate

intensity values using the default number of levels .Finally the syntax

Imshow(f,[ ])

Sets variable low to the minimum value of array f and high to its maximum

value. This form of imshow is useful for displaying images that have a low dynamic

range or that have positive and negative values.

Function pixval is used frequently to display the intensity values of individual

pixels interactively. This function displays a cursor overlaid on an image. As the cursor is

moved over the image with the mouse the coordinates of the cursor position and the

corresponding intensity values are shown on a display that appears below the figure

window .When working with color images, the coordinates as well as the red, green and

blue components are displayed. If the left button on the mouse is clicked and then held

pressed, pixval displays the Euclidean distance between the initial and current cursor

locations.

The syntax form of interest here is Pixval which shows the cursor on the last image

displayed. Clicking the X button on the cursor window turns it off.

The following statements read from disk an image called rose_512.tif extract basic

information about the image and display it using imshow:

>>f=imread(‘rose_512.tif’);

73

Page 74: Brain Tumor Detection

>>whos f

Name Size Bytes Class

F 512*512 262144 unit8 array

Grand total is 262144 elements using 262144 bytes

>>imshow(f)

A semicolon at the end of an imshow line has no effect, so normally one is not used.

If another image,g, is displayed using imshow, MATLAB replaces the image in the

screen with the new image. To keep the first image and output a second image, we use

function figure as follows:

>>figure ,imshow(g)

Using the statement

>>imshow(f),figure ,imshow(g) displays both images.

Note that more than one command can be written on a line ,as long as different

commands are properly delimited by commas or semicolons. As mentioned earlier, a

semicolon is used whenever it is desired to suppress screen outputs from a command line.

Suppose that we have just read an image h and find that using imshow produces the

image. It is clear that this image has a low dynamic range, which can be remedied for

display purposes by using the statement.

>>imshow(h,[ ])

WRITING IMAGES:

Images are written to disk using function imwrite, which has the following basic syntax:

74

Page 75: Brain Tumor Detection

imwrite (f,’filename’)

With this syntax, the string contained in filename must include a recognized file format

extension .Alternatively, the desired format can be specified explicitly with a third input

argument. >>imwrite(f,’patient10_run1’,’tif’)

Or alternatively

For example the following command writes f to a TIFF file named patient10_run1:

>>imwrite(f,’patient10_run1.tif’)

If filename contains no path information, then imwrite saves the file in the current

working directory.

The imwrite function can have other parameters depending on e file format selected.

Most of the work in the following deals either with JPEG or TIFF images ,so we focus

attention here on these two formats.

More general imwrite syntax applicable only to JPEG images is

imwrite(f,’filename.jpg,,’quality’,q)

where q is an integer between 0 and 100(the lower number the higher the degradation due

to JPEG compression).

For example, for q=25 the applicable syntax is

>> imwrite(f,’bubbles25.jpg’,’quality’,25)

The image for q=15 has false contouring that is barely visible, but this effect becomes

quite pronounced for q=5 and q=0.Thus, an expectable solution with some margin for

75

Page 76: Brain Tumor Detection

error is to compress the images with q=25.In order to get an idea of the compression

achieved and to obtain other image file details, we can use function imfinfo which has

syntax.

Imfinfo filename

Here filename is the complete file name of the image stored in disk.

For example,

>> imfinfo bubbles25.jpg

outputs the following information(note that some fields contain no information in this

case):

Filename: ‘bubbles25.jpg’

FileModDate: ’04-jan-2003 12:31:26’

FileSize: 13849

Format: ‘jpg’

Format Version: ‘ ‘

Width: 714

Height: 682

Bit Depth: 8

Color Depth: ‘grayscale’

Format Signature: ‘ ‘

Comment: { }

76

Page 77: Brain Tumor Detection

Where file size is in bytes. The number of bytes in the original image is corrupted simply

by multiplying width by height by bit depth and dividing the result by 8. The result is

486948.Dividing this file size gives the compression ratio:(486948/13849)=35.16.This

compression ratio was achieved. While maintaining image quality consistent with the

requirements of the appearance. In addition to the obvious advantages in storage space,

this reduction allows the transmission of approximately 35 times the amount of un

compressed data per unit time.

The information fields displayed by imfinfo can be captured in to a so called structure

variable that can be for subsequent computations. Using the receding an example and

assigning the name K to the structure variable.

We use the syntax >>K=imfinfo(‘bubbles25.jpg’);

To store in to variable K all the information generated by command imfinfo, the

information generated by imfinfo is appended to the structure variable by means of

fields, separated from K by a dot. For example, the image height and width are now

stored in structure fields K. Height and K. width.

As an illustration, consider the following use of structure variable K to commute the

compression ratio for bubbles25.jpg:

>> K=imfinfo(‘bubbles25.jpg’);

>> image_ bytes =K.Width* K.Height* K.Bit Depth /8;

>> Compressed_ bytes = K.FilesSize;

>> Compression_ ratio=35.162

Note that iminfo was used in two different ways. The first was t type imfinfo

bubbles25.jpg at the prompt, which resulted in the information being displayed on the

screen. The second was to type K=imfinfo (‘bubbles25.jpg’),which resulted in the

information generated by imfinfo being stored in K. These two different ways of calling

77

Page 78: Brain Tumor Detection

imfinfo are an example of command_ function duality, an important concept that is

explained in more detail in the MATLAB online documentation.

More general imwrite syntax applicable only to tif images has the form

Imwrite(g,’filename.tif’,’compression’,’parameter’,….’resloution’,[colres rowers] )

Where ‘parameter’ can have one of the following principal values: ‘none’ indicates no

compression, ‘pack bits’ indicates pack bits compression (the default for non ‘binary

images’) and ‘ccitt’ indicates ccitt compression. (the default for binary images).The 1*2

array [colres rowers]

Contains two integers that give the column resolution and row resolution in dot per_ unit

(the default values). For example, if the image dimensions are in inches, colres is in the

number of dots(pixels)per inch (dpi) in the vertical direction and similarly for rowers in

the horizontal direction. Specifying the resolution by single scalar, res is equivalent to

writing [res res].

>>imwrite(f,’sf.tif’,’compression’,’none’,’resolution’,……………..[300 300])

the values of the vector[colures rows] were determined by multiplying 200 dpi by the

ratio 2.25/1.5, which gives 30 dpi. Rather than do the computation manually, we could

write

>> res=round(200*2.25/1.5);

>>imwrite(f,’sf.tif’,’compression’,’none’,’resolution’,res)

where its argument to the nearest integer.It function round rounds is important to note

that the number of pixels was not changed by these commands. Only the scale of the

image changed. The original 450*450 image at 200 dpi is of size 2.25*2.25 inches. The

new 300_dpi image is identical, except that is 450*450 pixels are distributed over a

1.5*1.5_inch area. Processes such as this are useful for controlling the size of an image in

a printed document with out sacrificing resolution.

78

Page 79: Brain Tumor Detection

Often it is necessary to export images to disk the way they appear on the MATLAB

desktop. This is especially true with plots .The contents of a figure window can be

exported to disk in two ways. The first is to use the file pull-down menu is in the figure

window and then choose export. With this option the user can select a location, filename,

and format. More control over export parameters is obtained by using print command:

Print-fno-dfileformat-rresno filename

Where no refers to the figure number in the figure window interest, file format refers

one of the file formats in table above. ‘resno’ is the resolution in dpi, and filename is the

name we wish to assign the file.

If we simply type print at the prompt, MATLAB prints (to the default printer) the

contents of the last figure window displayed. It is possible also to specify other options

with print, such as specific printing device.

Data Classes:

Although we work with integers coordinates the values of pixels themselves are not

restricted to be integers in MATLAB. Table above list various data classes supported by

MATLAB and IPT are representing pixels values. The first eight entries in the table are

refers to as numeric data classes. The ninth entry is the char class and, as shown, the last

entry is referred to as logical data class.

All numeric computations in MATLAB are done in double quantities, so this is also

a frequent data class encounter in image processing applications. Class unit 8 also is

encountered frequently, especially when reading data from storages devices, as 8 bit

images are most common representations found in practice. These two data classes,

classes logical, and, to a lesser degree, class unit 16 constitute the primary data classes on

which we focus. Many ipt functions however support all the data classes listed in table.

Data class double requires 8 bytes to represent a number uint8 and int 8 require one byte

each, uint16 and int16 requires 2bytes and unit 32.

79

Page 80: Brain Tumor Detection

Name Description

Double Double _ precision, floating_ point numbers the Approximate.

Uinit8 unsigned 8_bit integers in the range [0,255] (1byte per

Element). Element).

Uinit16 unsigned 16_bit integers in the range [0,65535] (2byte

Per element).

Uinit 32 unsigned 32_bit integers in the range [0,4294967295]

(4 bytes per element).

Int8 signed 8_bit integers in the range[-128,127]

1 byte per element)

Int 16 signed 16_byte integers in the range

[32768, 32767] (2 bytes per element).

Int 32 Signed 32_byte integers in the range

[-2147483648, 21474833647]

(4 byte per element).

Single single _precision floating _point numbers with values

In the approximate range (4 bytes per elements).

Char characters (2 bytes per elements).

80

Page 81: Brain Tumor Detection

Logical values are 0 to 1 (1byte per element).

int 32 and single, required 4 bytes each. The char data class holds characters in

Unicode representation. A character string is merely a 1*n array of characters logical

array contains only the values 0 to 1,with each element being stored in memory using

function logical or by using relational operators.

Image Types:

The toolbox supports four types of images:

1 .Intensity images

2. Binary images

3. Indexed images

4. R G B images

Most monochrome image processing operations are carried out using binary or

intensity images, so our initial focus is on these two image types. Indexed and RGB

colour images.

Intensity Images:

An intensity image is a data matrix whose values have been scaled to represent

intentions. When the elements of an intensity image are of class unit8, or class unit 16,

they have integer values in the range [0,255] and [0, 65535], respectively. If the image is

of class double, the values are floating _point numbers. Values of scaled, double intensity

images are in the range [0, 1] by convention.

Binary Images:

81

Page 82: Brain Tumor Detection

Binary images have a very specific meaning in MATLAB.A binary image is a

logical array 0s and1s.Thus, an array of 0s and 1s whose values are of data class, say

unit8, is not considered as a binary image in MATLAB .A numeric array is converted to

binary using function logical. Thus, if A is a numeric array consisting of 0s and 1s, we

create an array B using the statement.

B=logical (A)

If A contains elements other than 0s and 1s.Use of the logical function converts all

nonzero quantities to logical 1s and all entries with value 0 to logical 0s.

Using relational and logical operators also creates logical arrays.

To test if an array is logical we use the I logical function:

islogical(c)

If c is a logical array, this function returns a 1.Otherwise returns a 0. Logical array

can be converted to numeric arrays using the data class conversion functions.

Indexed Images:

An indexed image has two components:

A data matrix integer, x.

A color map matrix, map.

Matrix map is an m*3 arrays of class double containing floating_ point values in the

range [0, 1].The length m of the map are equal to the number of colors it defines. Each

row of map specifies the red, green and blue components of a single color. An indexed

images uses “direct mapping” of pixel intensity values color map values. The color of

each pixel is determined by using the corresponding value the integer matrix x as a

pointer in to map. If x is of class double ,then all of its components with values less than

82

Page 83: Brain Tumor Detection

or equal to 1 point to the first row in map, all components with value 2 point to the

second row and so on. If x is of class units or unit 16, then all components value 0 point

to the first row in map, all components with value 1 point to the second and so on.

RGB Image:

An RGB color image is an M*N*3 array of color pixels where each color pixel is

triplet corresponding to the red, green and blue components of an RGB image, at a

specific spatial location. An RGB image may be viewed as “stack” of three gray scale

images that when fed in to the red, green and blue inputs of a color monitor

Produce a color image on the screen. Convention the three images forming an RGB

color image are referred to as the red, green and blue components images. The data class

of the components images determines their range of values. If an RGB image is of class

double the range of values is [0, 1].

Similarly the range of values is [0,255] or [0, 65535].For RGB images of class units

or unit 16 respectively. The number of bits use to represents the pixel values of the

component images determines the bit depth of an RGB image. For example, if each

component image is an 8bit image, the corresponding RGB image is said to be 24 bits

deep.

Generally, the number of bits in all component images is the same. In this case the

number of possible color in an RGB image is (2^b) ^3, where b is a number of bits in

each component image. For the 8bit case the number is 16,777,216 colors

INTRODUCTION TO MATLAB

What Is MATLAB?

83

Page 84: Brain Tumor Detection

MATLAB® is a high-performance language for technical computing. It integrates

computation, visualization, and programming in an easy-to-use environment where

problems and solutions are expressed in familiar mathematical notation. Typical uses

include

Math and computation

Algorithm development

Data acquisition

Modeling, simulation, and prototyping

Data analysis, exploration, and visualization

Scientific and engineering graphics

Application development, including graphical user interface building.

MATLAB is an interactive system whose basic data element is an array that does

not require dimensioning. This allows you to solve many technical computing problems,

especially those with matrix and vector formulations, in a fraction of the time it would

take to write a program in a scalar non interactive language such as C or FORTRAN.

The name MATLAB stands for matrix laboratory. MATLAB was originally

written to provide easy access to matrix software developed by the LINPACK and

EISPACK projects. Today, MATLAB engines incorporate the LAPACK and BLAS

libraries, embedding the state of the art in software for matrix computation.

MATLAB has evolved over a period of years with input from many users. In

university environments, it is the standard instructional tool for introductory and

advanced courses in mathematics, engineering, and science. In industry, MATLAB is the

tool of choice for high-productivity research, development, and analysis.

84

Page 85: Brain Tumor Detection

MATLAB features a family of add-on application-specific solutions called

toolboxes. Very important to most users of MATLAB, toolboxes allow you to learn and

apply specialized technology. Toolboxes are comprehensive collections of MATLAB

functions (M-files) that extend the MATLAB environment to solve particular classes of

problems. Areas in which toolboxes are available include signal processing, control

systems, neural networks, fuzzy logic, wavelets, simulation, and many others.

The MATLAB System:

The MATLAB system consists of five main parts:

Development Environment:

This is the set of tools and facilities that help you use MATLAB functions and

files. Many of these tools are graphical user interfaces. It includes the MATLAB desktop

and Command Window, a command history, an editor and debugger, and browsers for

viewing help, the workspace, files, and the search path.

The MATLAB Mathematical Function:

This is a vast collection of computational algorithms ranging from elementary

functions like sum, sine, cosine, and complex arithmetic, to more sophisticated functions

like matrix inverse, matrix eigen values, Bessel functions, and fast Fourier transforms.

The MATLAB Language:

This is a high-level matrix/array language with control flow statements, functions,

data structures, input/output, and object-oriented programming features. It allows both

85

Page 86: Brain Tumor Detection

"programming in the small" to rapidly create quick and dirty throw-away programs, and

"programming in the large" to create complete large and complex application programs.

Graphics:

MATLAB has extensive facilities for displaying vectors and matrices as graphs, as

well as annotating and printing these graphs. It includes high-level functions for two-

dimensional and three-dimensional data visualization, image processing, animation, and

presentation graphics. It also includes low-level functions that allow you to fully

customize the appearance of graphics as well as to build complete graphical user

interfaces on your MATLAB applications.

The MATLAB Application Program Interface (API):

This is a library that allows you to write C and Fortran programs that interact with

MATLAB. It includes facilities for calling routines from MATLAB (dynamic linking),

calling MATLAB as a computational engine, and for reading and writing MAT-files.

MATLAB WORKING ENVIRONMENT:

MATLAB DESKTOP:-

Matlab Desktop is the main Matlab application window. The desktop contains five

sub windows, the command window, the workspace browser, the current directory

window, the command history window, and one or more figure windows, which are

shown only when the user displays a graphic.

The command window is where the user types MATLAB commands and

expressions at the prompt (>>) and where the output of those commands is displayed.

86

Page 87: Brain Tumor Detection

MATLAB defines the workspace as the set of variables that the user creates in a work

session. The workspace browser shows these variables and some information about them.

Double clicking on a variable in the workspace browser launches the Array Editor, which

can be used to obtain information and income instances edit certain properties of the

variable.

The current Directory tab above the workspace tab shows the contents of the current

directory, whose path is shown in the current directory window. For example, in the

windows operating system the path might be as follows: C:\MATLAB\Work, indicating

that directory “work” is a subdirectory of the main directory “MATLAB”; WHICH IS

INSTALLED IN DRIVE C. clicking on the arrow in the current directory window shows

a list of recently used paths. Clicking on the button to the right of the window allows the

user to change the current directory.

MATLAB uses a search path to find M-files and other MATLAB related files,

which are organize in directories in the computer file system. Any file run in MATLAB

must reside in the current directory or in a directory that is on search path. By default, the

files supplied with MATLAB and math works toolboxes are included in the search path.

The easiest way to see which directories are on the search path. The easiest way to see

which directories are soon the search path, or to add or modify a search path, is to select

set path from the File menu the desktop, and then use the set path dialog box. It is good

practice to add any commonly used directories to the search path to avoid repeatedly

having the change the current directory.

The Command History Window contains a record of the commands a user has

entered in the command window, including both current and previous MATLAB

sessions. Previously entered MATLAB commands can be selected and re-executed from

the command history window by right clicking on a command or sequence of

commands. This action launches a menu from which to select various options in addition

to executing the commands. This is useful to select various options in addition to

executing the commands. This is a useful feature when experimenting with various

commands in a work session.

87

Page 88: Brain Tumor Detection

Using the MATLAB Editor to create M-Files:

The MATLAB editor is both a text editor specialized for creating M-files and a

graphical MATLAB debugger. The editor can appear in a window by itself, or it can be a

sub window in the desktop. M-files are denoted by the extension .m, as in pixelup.m. The

MATLAB editor window has numerous pull-down menus for tasks such as saving,

viewing, and debugging files. Because it performs some simple checks and also uses

color to differentiate between various elements of code, this text editor is recommended

as the tool of choice for writing and editing M-functions. To open the editor , type edit at

the prompt opens the M-file filename.m in an editor window, ready for editing. As noted

earlier, the file must be in the current directory, or in a directory in the search path.

Getting Help:

The principal way to get help online is to use the MATLAB help browser, opened

as a separate window either by clicking on the question mark symbol (?) on the desktop

toolbar, or by typing help browser at the prompt in the command window. The help

Browser is a web browser integrated into the MATLAB desktop that displays a Hypertext

Markup Language(HTML) documents. The Help Browser consists of two panes, the help

navigator pane, used to find information, and the display pane, used to view the

information. Self-explanatory tabs other than navigator pane are used to perform a search.

Summary, conclusion and Future scope

In this project a color based segmentation method based on K-means clustering for

tracking tumor in the MRI brain image is proposed . A preliminary experiment conducted

on the MRI brain image demonstrates encouraging results. by using the features derived

from CIELab color model can provide good segmentation performance with the proposed

method and the location of a tumor or lesion can be the proposed method simply

88

Page 89: Brain Tumor Detection

combines color translation K-means clustering and histogram clustering thus making it

efficient and very easy to implement.

The segmentation of MR brain images is an important problem in medical

imaging. Although much effort has been spent on finding a good solution to the

MRI segmentation problem. This project given an implementation of various

computational techniques for solving the problem. This project described and

validated a completely automatic procedure for brain tissue classiffcation from MR

anatomical images. Segmentation algorithms that can be broadly categorized into

classification-based, region-based, or contour-based approaches have been

reviewed, and discussed the advantages and disadvantages of each category

In this project three approaches for segmentation of brain tissue in MR images

is presented. The results show that this method can successively segment a tumor

provided the parameters are choosen properly. The visualization and detective

valuations of the results of the segmentation show the success of the approaches. In

this study, the tumor identification and the investigation are carried out for the

potential use of MRI data for improving the tumor shape and 2D visualization of

the surgical planning.

In this project, the problem of the region segmentation in MR images due to the

brain image complexity has been addressed using seed point and region growing

algorithm. Conventionally, for brain MR image segmentation, there are various

structural and statistical approaches. Structural methods are based on the spatial

properties of the image, such as edges and regions. Region growing is a structural

approach that is used for accurate segmentation of tumor.

Future Scope:

Future research in MRI segmentation should strive toward improving the

accuracy, precision, and computation speed of the segmentation algorithms, while

89

Page 90: Brain Tumor Detection

reducing the amount of manual interactions needed. This is particularly important

as MR imaging is becoming a routine diagnostic procedure in clinical practice. It is

also important that any practical segmentation algorithm should deal with 3D

volume segmentation instead of 2D slice by slice segmentation, since MRI data is

3D in nature. Volume segmentation ensures continuity of the 3D boundaries of the

segmented images whereas slice by slice segmentation does not guarantee

continuation of the boundaries of the tissue regions between slices.

Future work will focus on the construction of more accurate brain atlas using a

non rigid registration technique and on the investigation of the partial volume effect

Results:

original gray level image

90

Page 91: Brain Tumor Detection

original colormap image

color space translated image

image labeled by cluster index

91

Page 92: Brain Tumor Detection

objects in cluster 1

objects in cluster 3

Truly segmented image using K-means

9. References

1. Xia, Y., Bettinger, K., Shen, L., Reiss, A.: Automatic segmentation of the

caudate nucleus from human brain MR images. IEEE Transactions on Medical

Imaging 26(4) (2007) 509–517

92

Page 93: Brain Tumor Detection

2. C. Chu and K. Takaya, “3-Dimensional rendering of MR images,”

WESCANEX

93. Communications, Computers and Power in the Modern Environment

Conference Proceedings, IEEE , pp. 165–170, 2003

3. Clarke, L., Velthuizen, R., Camacho, M., Heine, J., Vaydianathan, M., Hall, L.,

Thatcher, R., Silbiger, M.: MRI segmentation: Methods and applications.

Magnetic Resonance Imaging 13 (2002)

4. Cline, H., Lorensen, W., Kikinis, R. and Jolesz, F. (2001) Three- Dimensional

Segmentation of MR Images of the Head Using Probability and Connectivity. J.

Comp. Assis. Tomogr., 14, 1037–1045

5. J. Liang, . McInerney, D. Terzopolos Interactive Medical Image Segmentation

with United Snakes Medical Image Computing and Computer-Assisted

Intervention - MICCAI’99, 116, 1999.

6. Pham, D.L., Xu, C., Prince, J.L.: Current methods in medical image

segmentation. Annual Review of Biomedical Engineering 2 (2000) 315{337

7.. Dugas-Phocion, G., Ballester, M.A.G., Malandain, G., Lebrun, C., Ayache, N.:

Improved em-based tissue segmentation and partial volume e®ect quantifcation

In multi-sequence brain mri. In: MICCAI. (2004)

8. Kapur, T., Grimson, W.E., Wells, W.M., Kikinis, R.: Segmentation of brain

tissue from magnetic resonance images. Med Image Anal. 1 (1996)

9. Prastawa, M., Gilmore, J., Lin, W., Gerig, G.: Automatic segmentation of

Neonatal brain mri. In: MICCAI. (2004)

10. Leemput, K.V., Maes, F., Vandermeulen, D., Suetens, P.: Automated model-

Based tissue classi¯cation of MR images of the brain. IEEE trans. on medical

imaging 18 (1999) 897

11. Zhang, Y., Brady, M., Smith, S.: Segmentation of brain MR images through a

hidden markov random field model and the expectation-maximization

algorithm.IEEE trans. on medical imaging 20 (2001) 45

12. Digital Image Processing, by Rafael C. Gonzalez, Richard Eugene

Woods

13. Digital Image Processing, by Kenneth R. Castleman

93

Page 94: Brain Tumor Detection

14. Digital Image Processing Using Matlab, by Rafael C. Gonzalez, Richard

E.

Woods, Steven L. Eddins

15 Fundamentals of Digital Image Processing , by Anil K. Jain

16 Digital Image Processing , by Bernd Jähne

17 Digital Image Processing Algorithms and Applications , by Ioannis Pitas

94

Page 95: Brain Tumor Detection

95

Page 96: Brain Tumor Detection

96