KM and FCM algorithm

1.Select k vectors randomly from the dataset as initial cluster centers μ<sup>j</sup> (j = 1, …, k). Set the current iteration t = 0.

2.KM-Step: assign each vector Xi to its closest cluster center using Eq. (1).

3.FCM-Step: set t = t + 1.

4.For each cluster Cj, compute the center μ<sup>j</sup> using Eq. (3)

5.Compute the new membership matrix Uð Þ<sup>t</sup> <sup>k</sup> <sup>X</sup> <sup>N</sup> using Eq. (4)

6.Assign data objects to clusters using the membership matrix.

7.Compute Percentage change using Eq. (2).

8.Stop the process if Percentage change < α. Otherwise, set t = t + 1.

9.KM-Step: For each cluster Cj, compute new center μ<sup>j</sup> using Eq. (3).

10.Assign each vector Xi to its closest cluster center using Eq. (1).

11.Compute Percentage change using Eq. (2).

12.Stop the process if Percentage change < α. Otherwise, go to step 3.

For all the algorithms, i.e., KM, FCM, KMFCM, KMandFCM, the same termination condition, Eq. (2), is used.

## 5. Performance evaluation measures

For performance evaluation of algorithms, CPU time in seconds, sum of squared error [12] and clustering fitness [43] are taken into consideration and are calculated for all the algorithms.

#### 5.1 Sum of squared errors

The objective of clustering is to minimize the within-cluster sum of squared error (SSE). The lesser the SSE, the better the goodness of fit is. The sum of squared error [12] for the results of each clustering algorithm is computed using the Eq. (5)

Segmenting Images Using Hybridization of K-Means and Fuzzy C-Means Algorithms DOI: http://dx.doi.org/10.5772/intechopen.86374

$$\text{SSE} = \sum\_{j=1}^{k} \sum\_{X\_i \in C\_j} \left( X\_i - \mu\_j \right)^2 \tag{5}$$

Here, Xi is the ith data object in the dataset, μ<sup>j</sup> (j = 1, …, k) is the center of the cluster Cj, and k is the number of clusters.

#### 5.2 Clustering fitness

The main objective of any clustering algorithm is to generate clusters with higher intra-cluster similarity and lower inter-cluster similarity. So, it is also important to consider inter-cluster similarity while evaluating the clustering performance. In the present work, clustering fitness is also considered as a performance criterion, which requires the calculation of both intra-cluster similarity and inter-cluster similarity. The computation of clustering fitness also requires the experiential knowledge, λ. The computation of clustering fitness results in higher value when the inter-cluster similarity is low and results in lower value for when the inter-cluster similarity is high. Also that to make the computation of clustering fitness unbiased, the value of λ is taken as 0.5 [43].

(a) Intra-cluster similarity for the cluster Cj: it can be quantified via a function of the reciprocals of intra-cluster radii within each of the resulting clusters. The intra-cluster similarity [43] of a cluster Cj (1 = j = k), denoted as Stra(Cj ), is defined in Eq. (6)

$$S\_{\rm tra}(\mathbf{C}\_{j}) = \frac{\mathbf{1} + n}{\mathbf{1} + \sum\_{1}^{n} dist(I\_{l}, Centroid)} \tag{6}$$

Here, n is the number of items in cluster Cj, Ij (1 = j = n) is the jth item in cluster Cj, and dist(Ij, Centroid) calculates the distance between Ij and the centroid of Cj, which is the intra-cluster radius of Cj. To smooth the value of Stra(Cj) and allow for possible singleton clusters, 1 is added to the denominator and numerator.

(b) Intra-cluster similarity for one clustering result C: it is denoted as Stra(C). It is defined in Eq. (7), [43]

$$\mathbf{S}\_{\text{tra}}(\mathbf{C}) = \frac{\sum\_{1}^{k} \mathbf{S}\_{\text{tra}}(\mathbf{C}\_{j})}{k} \tag{7}$$

Here, k is the number of resulting clusters in C and Stra(Cj) is the intra-cluster similarity for the cluster Cj.

(c) Inter-cluster similarity: it can be quantified via a function of the reciprocals of inter-cluster radii of the clustering centroids. The inter-cluster similarity [43] for one of the possible clustering results C, denoted as Ster(Cj ), is defined as Eq. (8)

$$\mathcal{S}\_{ter}(\mathcal{C}) = \frac{1+k}{1 + \sum\_{1}^{k} \text{dist}\left(\text{Centroid}\_{j}, \text{Centroid}^{2}\right)} \tag{8}$$

Here, k is the number of resulting clusters in C,1= j = k, Centroidj is the centroid of the jth cluster in C, Centroid<sup>2</sup> is the centroid of all centroids of clusters in C. We compute inter-cluster radius of Centroidj by calculating dist(Centroidj, Centroid<sup>2</sup> ), which is distance between Centroidj, and Centroid<sup>2</sup> . To smooth the value of Ster(C)

and allow for possible all-inclusive clustering result, 1 is added to the denominator and the numerator.

(d) Clustering fitness: the clustering fitness [43] for one of the possible clustering results C, denoted as CF, is defined as Eq. (9)

$$\text{CF} = \lambda \times \text{S}\_{\text{tru}}(\text{C}) + \frac{1 - \lambda}{\text{S}\_{\text{tr}}(\text{C})} \tag{9}$$

Here, λ (0 < λ < 1) is an experiential weight, Stra(C) is the intra-cluster similarity for the clustering result C and Ster(C) is the inter-cluster similarity for the clustering result C. To avoid biasedness in our experiments, λ is assumed to be 0.5.
