Select any pixel as ‘seed’ which will be a non-background pixel .Check its gray level and assign it a label 1.
Evaluate each unlabelled non-background pixel in the neighborhood of the seed pixel. Assign same label to all the neighboring pixels having same gray level.
Select one of the neighboring pixels with the same label and call it the seed, go to step 2.if none of the neighbors of all the pixels in the region has same gray level go to step4. If no unlabelled pixel is found, go to step 6.
Select any unlabelled non-background pixel with a gray-level as seed and assign it the next label. If no such pixel is found then go to step 6.
go to step 2
The image scan is over and the image is segmented into regions identified by the pixels of the same label.