Upload
avdhesh-gupta
View
230
Download
0
Embed Size (px)
Citation preview
8/12/2019 Color Image Segmentation by Clustering
1/17
Image segmentation byClustering
(using Mahalanobis distance)
- Manjit Chintalapalli
8/12/2019 Color Image Segmentation by Clustering
2/17
ABSTRACT:
In this work the way is described an algorithm, which are used tosegmentation of images with clustering methods. This algorithm is tested onten color images, which are firstly transformed to R*B*G* color space.Conditions, results and conclusions are described lower. The results arecompared using both ahalanobis and !uclidean distances in the clusteringalgorithm.
INTRODUCTION:Image segmentation was, is and will be a ma"or research topic for many
image processing researchers. The reasons are ob#ious and applicationsendless$ most computer #ision and image analysis problems re%uire asegmentation stage in order to detect ob"ects or di#ide the image into regionswhich can be considered homogeneous according to a gi#en criterion, suchas color, motion, te&ture, etc.
Clustering is the search for distinct groups in the feature space. It is e&pectedthat these groups ha#e different structures and that can be clearlydifferentiated. The clustering task separates the data into number of
partitions, which are #olumes in the n'dimensional feature space. Thesepartitions define a hard limit between the different groups and depend on thefunctions used to model the data distribution.
Image segmentation:
To humans, an image is not "ust a random collection of pi&els( it is ameaningful arrangement of regions and ob"ects. There also e&its a #ariety of
images$ natural scenes, paintings, etc. )espite the large #ariations of theseimages, humans ha#e no problem to interpret them. Considering the largedatabases on the , in our personal photograph folders, a strong andautomatic image analysis would be welcome.
8/12/2019 Color Image Segmentation by Clustering
3/17
Image segmentation is the first step in image analysis and patternrecognition. It is a critical and essential component of image analysissystem, is one of the most difficult tasks in image processing, anddetermines the %uality of the final result of analysis. Image segmentation isthe process of di#iding an image into different regions such that each regionis homogeneous.
Image segmentation methods can be categori+ed as follows this is not ane&hausti#e list-$
Histogram thresholding:assumes that images are composed ofregions with different gray or color- ranges, and separates it into anumber of peaks, each corresponding to one region.
Edge-based approaches:use edge detection operators such as obel,/aplacian for e&le. Resulting regions may not be connected,hence edges need to be "oined.
Region-based approaches:based on similarity of regional imagedata. 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 onColor image segmentation using ahalanobis distance. !uclidean distanceis also used for comparing between the %uality of segmentation between theahalanobis and !uclidean distance.
Image Segmentation by Clustering
Clustering is a classification techni%ue. Gi#en a #ector of 0 measurementsdescribing each pi&el or group of pi&els i.e., region- in an image, asimilarity 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 bean indicator of similarity of image regions, and may be used forsegmentation purposes.
8/12/2019 Color Image Segmentation by Clustering
4/17
The #ector of measurements describes some useful image feature and thus isalso known as a feature #ector. imilarity between image regions or pi&elsimplies clustering small separation distances- in the feature space.Clustering methods were some of the earliest data segmentation techni%uesto 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 theminade%uate for batch processing of huge image databases
Secondly, the clusters are represented by their centroid and built usingan !uclidean distance therefore inducing generally an hypersphericcluster 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 arearbitrarily shaped
8/12/2019 Color Image Segmentation by Clustering
5/17
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 werecalculated 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.
http://www.predictivepatterns.com/docs/WebSiteDocs/Glossary/Glossary_of_Terms_Acronym_List.htm#G_Indexhttp://www.predictivepatterns.com/docs/WebSiteDocs/Glossary/Glossary_of_Terms_Acronym_List.htm#G_Index8/12/2019 Color Image Segmentation by Clustering
6/17
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.
8/12/2019 Color Image Segmentation by Clustering
7/17
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&elsand is transformed into a feature space RBG-.
Step 2:0e&t similar data points, i.e. the points which ha#e similar color, are groupedtogether using any clustering method. 3 clustering method such as k'meansclustering is used to form clusters as shown in the flow chart. The distancesare calculated using ahalanobis and !uclidean distant.
8/12/2019 Color Image Segmentation by Clustering
8/17
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 acluster.
The data points with minimum ahalanobis distance or !uclidean distanceare grouped together to form the clusters. ahalanobis and !uclidean aredescribed 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
8/12/2019 Color Image Segmentation by Clustering
9/17
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 calculatedconsidering the #ariances of the data points in the 4') RGB space.
a%alanobisDistan(e
8/12/2019 Color Image Segmentation by Clustering
10/17
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 twopi&els
!uclidean distance 9 :&; ' &8-< = y; ' y8- &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 thatahalanobis 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.
8/12/2019 Color Image Segmentation by Clustering
11/17
Results
Original Images:
eture Rose
(ainting 3andscape
8/12/2019 Color Image Segmentation by Clustering
12/17
4ea/er China camp
Car Canoe
he ree
8/12/2019 Color Image Segmentation by Clustering
13/17
Segmente) Color Images
5riginal ,mage ,mage segmented !ith 6 clusters
,mage segmented !ith 7 clusters
8/12/2019 Color Image Segmentation by Clustering
14/17
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 seenwith four clusters
7-Clusters
i& colors can beafter segmentation
8/12/2019 Color Image Segmentation by Clustering
15/17
Rose +original-
Image Segmente) $it%2 (lusters usinga%alanobis Distan(e
Image Segmente) $it%2 (lusters usingEu(li)ean Distan(e
8/12/2019 Color Image Segmentation by Clustering
16/17
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 usinga%alanobis Distan(e
Image segmente) $it%2 (lusters usingEu(li)ean Distan(e
8/12/2019 Color Image Segmentation by Clustering
17/17
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 clusters.
That has to be true because the ahalanobis distance considers the
#ariances also.
RE4ERENCES:
;D chmid, ?.$ Colorimetry and color spaces, http$EEwww.schmid'saugeon.chEpublications.html, 8FF;
8D chmid, ?.$ Image segmentation by color clustering, http$EEwww.schmid'saugeon.chEpublications.html, 8FF;
4D )igital Image ?rocessing , R.C. Gon+ale+, R.!. oods, ./. !ddins.