Introduction

Image segmentation, the partitioning of an image into homogeneous regions based on a set of characteristics, is a key element in image analysis and computer vision. Clustering is one of the methods available for this purpose. Clustering is a process which can be used for classifying pixels based on similarity according to the pixel's color or gray-level intensity.

The K-means algorithm has been used for a fast and crisp "hard" segmentation. The Fuzzy Set theory has improved this process by allowing the concept of partial membership, in which an image pixel can belong to multiple clusters. This "soft" clustering allows for a more precise computation of the cluster membership, and has been used successfully for image clustering and for the unsupervised segmentation of medical, geological, and satellite images.

Algorithm

The fuzzy C-means (FCM) algorithm follows the same principles as the K-means algorithm in that it compares the RGB value of every pixel with the value of the cluster center. The main difference is that instead of making a hard decision about which cluster the pixel should belong to, it assigns a value between 0 and 1 describing "how much this pixel belongs to that cluster" for each cluster. Fuzzy rule states that the sum of the membership value of a pixel to all clusters must be 1. The higher the membership value, the more likely that pixel is to belong to that cluster. The FCM clustering is obtained by minimizing an objective function shown in equation (1):

(1)

Where:

J is the objective function

n is the number of pixels in the image E

c is the number of clusters

µ is the fuzzy membership value from table

m is a fuzziness factor (a value > 1)

pi is the ith pixel in E

vk is the centroid of the kth cluster

|pi – vk| is the Euclidean distance between pi and vk defined by equation (2):

(2)

The calculation of the centroid of the kth cluster is achieved using equation (3):

(3)

The fuzzy membership table is calculated using the original equation (4):

(4)

This algorithm has been extended for clustering of color images in the RGB color space. Hence, the computation given in equation (2) to compute the Euclidean distance between the values pi and vk is modified to incorporate RGB colors, and is shown in equation (5):

(5)

Pseudo-Code

As mentioned earlier, this is an iterative process. The pseudo-code is as follows:

Step 1: Set the number of clusters, the fuzzy parameter (a constant > 1), and the stopping condition

Step 5: For each pixel, for each cluster, compute the membership values in the matrix

Step 6: If the value of J between consecutive iterations is less than the stopping condition, then stop; otherwise, set k=k+1 and go to step 4

Step 7: Defuzzification and segmentation

Using the Code

The GUI is pretty straightforward, but the calculations can be very intensive. For that reason, the processing is done in a worker thread, which complicates the interaction with the GUI.

First, use the "File" menu to load an image. Beware, large images will tale a long time!

The options available to be changed from the GUI are the number of clusters, the maximum number of iterations (so that the program doesn't just keep running forever), and the precision. The algorithm will stop before the maximum number of iterations if the precision is achieved.

Clicking the "Fuzzy C-means Clustering" button will start the computation. The program will start by creating a ClusterPoint object for every pixel in the image:

Once the iterations are done, the algorithm will perform a defuzzification process to assign the pixel to the cluster for which it has the highest membership value. For each cluster, the program will then save a segmented image containing the pixels from the original image that are contained in that cluster.

As an example, the clustering of the following test image with 2 clusters:

will result in the following clustered image:

By using the cluster information and the pixels from the original image, the following regions can be extracted:

Because this algorithm is very computationally intensive, it has a tendency to "lock" the GUI and not refresh the status and the working image. For that reason, I had to use a worker thread.

Points of Interest

This is my first post, and my first C# program, so I am sure that it leaves a lot of room for improvement. But overall, I hope that you will find this project fun and interesting!

I think your algorithm can be improved a lot if you use a faster way to get pixels color values.
I had written two articles about ManagedBitmaps and, if you want, I can send you the last version of my work.

Are you saying you don't know what to do?! Then do nothing rather than voting a 1! Two things you could follow: improve your English or anything else you could be possibly capable of doing! In case your poor English: "好好学英语，不要在这里...(我就不说了)"

(1) What is the main objective of your article?
(2) How you can achieve this?
(3) Sample code example with detail .
(4) How your code works?
(5) Code and Article formation.
(6) Add screen shots at the top of your article, if you have.
Etc..

You should consider the above…
It will be very nice if you include some more detail on your idea, how your code works, the crucial parts as well.
However keep it up

Thanks
Md. Marufuzzaman
I will not say I have failed 1000 times; I will say that I have discovered 1000 ways that can cause failure – Thomas Edison.

Hay..that's Gr8. Yes the article editor has the option to set your article as work in Progress - do not make public.
To do that you just need to checked the "Work in Progress - do not make public" checkbox. Keep it up

Thanks
Md. Marufuzzaman
I will not say I have failed 1000 times; I will say that I have discovered 1000 ways that can cause failure – Thomas Edison.

1. Remove all the text and other parts that are not your articles part and were present by default from beginning.
2. Please add more details on fuzzy C-means clustering, segmentation of color images, when do we use it and what advantage we have on using the above metioned algo of yours. This would help a noive to understand about it from beginning.