Thank you all.I know about multithresh n im2bw n all.I need the steps after thresholding n segmentation inorder to label segments in them. bwlabel() is used in matlab only for black n white not for anything else.I have to do it in grayscale not in binary.
K-mean clustering divides the image into related segments or clusters , then every region is labelled. the number of clusters equals the number of region. you can implement the code in matlab because it is simple method.
Is this "then every region is labeled " is part of this K-mean clustering? Secondly I would use classification further not clustering what would be suitable in that case?
As the people earlier have correctly pointed out, using K-means you can "segment" the image into K regions. However, you need to manually decide on K so that you have K distinct labelsl.
If you want to label the regions of a gray-image similar to bwlabel, you need to have a criteria of similarity between adjacent pixel values to have a region-level criteria. Please go through the function "imregionalmax" which finds a region level maxima from a gray-scale image, and works by the neighborhood relationship exactly similar to bwlabel.
You can also achieve the same through any region-growing segmentation algorithm, or even watershed segmentation algorithm.