Sie sind auf Seite 1von 17

Image segmentation by

Clustering
(using Mahalanobis distance)
- Manjit Chintalapalli
ABSTRACT:
In this work the way is described an algorithm, which are used to
segmentation of images with clustering methods. This algorithm is tested on
ten color images, which are firstly transformed to R*B*G* color space.
Conditions, results and conclusions are described lower. The results are
compared using both ahalanobis and !uclidean distances in the clustering
algorithm.
INTRODUCTION:

Image segmentation was, is and will be a ma"or research topic for many
image processing researchers. The reasons are ob#ious and applications
endless$ most computer #ision and image analysis problems re%uire a
segmentation stage in order to detect ob"ects or di#ide the image into regions
which can be considered homogeneous according to a gi#en criterion, such
as color, motion, te&ture, etc.
Clustering is the search for distinct groups in the feature space. It is e&pected
that these groups ha#e different structures and that can be clearly
differentiated. The clustering task separates the data into number of
partitions, which are #olumes in the n'dimensional feature space. These
partitions define a hard limit between the different groups and depend on the
functions used to model the data distribution.
Image segmentation:
To humans, an image is not "ust a random collection of pi&els( it is a
meaningful arrangement of regions and ob"ects. There also e&its a #ariety of
images$ natural scenes, paintings, etc. )espite the large #ariations of these
images, humans ha#e no problem to interpret them. Considering the large
databases on the ***, in our personal photograph folders, a strong and
automatic image analysis would be welcome.
Image segmentation is the first step in image analysis and pattern
recognition. It is a critical and essential component of image analysis
system, is one of the most difficult tasks in image processing, and
determines the %uality of the final result of analysis. Image segmentation is
the process of di#iding an image into different regions such that each region
is homogeneous.
Image segmentation methods can be categori+ed as follows ,this is not an
e&hausti#e list-$
Histogram thresholding: assumes that images are composed of
regions with different gray ,or color- ranges, and separates it into a
number of peaks, each corresponding to one region.
Edge-based approaches: use edge detection operators such as .obel,
/aplacian for e&ample. Resulting regions may not be connected,
hence edges need to be "oined.
Region-based approaches: based on similarity of regional image
data. .ome of the more widely used approaches in this category are$
Thresholding, Clustering, Region growing, .plitting and merging.
Hybrid: consider both edges and regions.
The pro"ect is done using Image .egmentation by Clustering. It is based on
Color image segmentation using ahalanobis distance. !uclidean distance
is also used for comparing between the %uality of segmentation between the
ahalanobis and !uclidean distance.
Image Segmentation by Clustering
Clustering is a classification techni%ue. Gi#en a #ector of 0 measurements
describing each pi&el or group of pi&els ,i.e., region- in an image, a
similarity of the measurement #ectors and therefore their clustering in the 0'
dimensional measurement space implies similarity of the corresponding
pi&els or pi&el groups. Therefore, clustering in measurement space may be
an indicator of similarity of image regions, and may be used for
segmentation purposes.
The #ector of measurements describes some useful image feature and thus is
also known as a feature #ector. .imilarity between image regions or pi&els
implies clustering ,small separation distances- in the feature space.
Clustering methods were some of the earliest data segmentation techni%ues
to be de#eloped.

Similar data points grouped together into clusters.
ost popular clustering algorithms suffer from two ma"or drawbacks
First, the number of clusters is predefined, which makes them
inade%uate for batch processing of huge image databases
Secondly, the clusters are represented by their centroid and built using
an !uclidean distance therefore inducing generally an hyperspheric
cluster shape, which makes them unable to capture the real structure
of the data.
This is especially true in the case of color clustering where clusters are
arbitrarily shaped
CLUSTERING ALGORITHS:
K-means
K-medoids
Hierarchical Clustering
There are many other algorithms used for clustering.
K-means algorithm was used in the project and the distances were
calculated using Mahalanobis and Euclidean distances
!"eans Clustering O#er#ie$
1'eans clustering generates a specific number of dis"oint, flat ,non'
hierarchical- clusters. It is well suited to generating globular clusters. The 1'
eans method is numerical, unsuper#ised, non'deterministic and iterati#e.
!"eans Algorit%m &ro'erties
There are always 1 clusters.
There is always at least one item in each cluster.
The clusters are non'hierarchical and they do not o#erlap.
!#ery member of a cluster is closer to its cluster than any other cluster
because closeness does not always in#ol#e the center of clusters.
T%e !"eans Algorit%m &ro(ess
The dataset is partitioned into 1 clusters and the data points are
randomly assigned to the clusters resulting in clusters that ha#e
roughly the same number of data points.
2or each data point$
Calculate the distance ,ahalanobis or !uclidean- from the data point
to each cluster.
If the data point is closest to its own cluster, lea#e it where it is. If the
data point is not closest to its own cluster, mo#e it into the closest
cluster.
Repeat the abo#e step until a complete pass through all the data points
results in no data point mo#ing from one cluster to another. 3t this
point the clusters are stable and the clustering process ends.
The choice of initial partition can greatly affect the final clusters that
result, in terms of inter'cluster and intra'cluster distances and
cohesion.
Ho$ t%e 'roblem $as a''roa(%e)*
Flow-chart of an image segmentation method
Step 1:
2irst, an image is taken as an input. The input image is in the form of pi&els
and is transformed into a feature space ,RBG-.
Step 2:
0e&t similar data points, i.e. the points which ha#e similar color, are grouped
together using any clustering method. 3 clustering method such as k'means
clustering is used to form clusters as shown in the flow chart. The distances
are calculated using ahalanobis and !uclidean distant.
The abo#e figure shows how the data points are clustered in the 4'd RGB
space. 3s one can see all similar colors are grouped together to form a
cluster.
The data points with minimum ahalanobis distance or !uclidean distance
are grouped together to form the clusters. ahalanobis and !uclidean are
described later below.
Step :
3fter clustering is done, the mean of the clusters is taken. Then the mean
color in each cluster is calculated to be remapped onto the image.
Ho$ a%alanobis an) Eu(li)ean )istan(e is (al(ulate)*
Both ahalanobis and !uclidean distances are described below clearly.
a%alanobis Distan(e:
ahalanobis )istance is a #ery useful way of determining the
5similarity5 of a set of #alues from an 5unknown5$ sample to a set of
#alues measured from a collection of 5known5 samples
.uperior to !uclidean distance because it takes distribution of the
points ,correlations- into account
Traditionally to classify obser#ations into different groups
It takes into account not only the a#erage #alue but also its #ariance
and the co#ariance of the #ariables measured
It compensates for interactions ,co#ariance- between #ariables
It is dimensionless
The formula used to calculate ahalanobis distance is gi#en below.
Dt+,- . +, / Ci- 0 In#erse+S- 0 +, / Ci-1
6ere 7 is a data point in the 4') RGB space,
Ci is the center of a cluster
. is the co#ariance matri& of the data points in the 4') RGB space
In#erse,.- is the in#erse of co#ariance matri& ..
The abo#e figure shows how the mahalanobis distance is calculated
considering the #ariances of the data points in the 4') RGB space.
a%alanobis
Distan(e
The function used for ahalanobis distance is user defined in the program.
ahalano8, -(
Eu(li)ean Distan(e:
The !uclidean distance is the straight'line distance between two
pi&els
!uclidean distance 9 :,,&; ' &8-< = ,y; ' y8-<- ,
where ,&;,y;- > ,&8,y8- are two pi&el points or two data points.
Ho! the "unction #ahalano2$ % !as used "or both #ahalanobis and
Euclidean distances &
The only difference between ahalanobis and !uclidean distance is that
ahalanobis considers the In#erse of the co#ariance matri& of the set of data
points in the 4'd space.
.o,
#ahalanobis distance ' $( ) *% + ,-.$Co/$S%% + $( ) *%0
Euclidean distance ' $( ) *% + $( ) *%0
6ere ? is a data point and @ is the center of a cluster.
. is a #ector containing all the data points the 4'd color space.
Results
Original Images:


1e2ture Rose
(ainting 3andscape


4ea/er
China camp
Car Canoe
1he 1ree
Segmente) Color Images

5riginal ,mage ,mage segmented !ith 6 clusters
,mage segmented !ith 7 clusters
Bea#er:

Comparison bet!een
#ahalanobis and Euclidean
Bea#er
+original-
2-Clusters
Anly two colors can be
seen after segmentation
6-Clusters
2our colors can be seen
with four clusters
7-Clusters
.i& colors can be seen
after segmentation

Rose +original-
Image Segmente) $it%
2 (lusters using
a%alanobis Distan(e
Image Segmente) $it%
2 (lusters using
Eu(li)ean Distan(e



Car +Original-
Image segmente) $it%
3 (lusters using
a%alanobis Distan(e
Image segmente) $it%
3 (lusters using
Eu(li)ean Distan(e
Image segmente) $it%
2 (lusters using
a%alanobis Distan(e
Image segmente) $it%
2 (lusters using
Eu(li)ean Distan(e
CONCLUSION
The image segmentation is done using k'means clustering in 4')
RGB space, so it works perfectly fine with all images.
The clarity in the segmented image is #ery good compared to other
segmentation techni%ues.
The clarity of the image also depends on the number of clusters used.
Ane disad#antage of the procedure used is that the number of clusters
is to be defined in each iteration.
The results are compared using both ahalanobis and !uclidean
distance.
3s one can see from the abo#e image in the pre#ious page that the
image segmented with ahalanobis distance did come better than
!uclidean )istance when the image is segmented with B clusters.
That has to be true because the ahalanobis distance considers the
#ariances also.
RE4ERENCES:
C;D .chmid, ?.$ Colorimetry and color spaces, http$EEwww.schmid'
saugeon.chEpublications.html, 8FF;
C8D .chmid, ?.$ Image segmentation by color clustering, http$EEwww.schmid'
saugeon.chEpublications.html, 8FF;
C4D )igital Image ?rocessing , R.C. Gon+ale+, R.!. *oods, ../. !ddins.

Das könnte Ihnen auch gefallen