How to cluster the intensities in a gray scale image?

1 view (last 30 days)
Dear all,
I have the following 8 bit gray image that contains 5 intensity levels .
Level-1 (black) = 159567 pixels
Level-2 = 68245 pixels
Level-3 = 33807 pixels
Level-4 = 10736 pixels
Level-5 (white) = 5736 pixels
However, the image I get is not always perfect and it looks something like what I show below.
Now, I want to know the number of pixels in each gray level in the noisy image (5 levels). Any idea how to find that?
I think I need a method that at first cluster the noisy image into 5 gray levels, and then find the number of pixels in each level (cluster).
K-means could be a good way to do that, but it always gives different result, so is there a better method than k-means? or is there a way to make k-means provide a correct and fixed answer?
Any idea will be appreciated.
Meshoo

Answers (1)

Sukuchha
Sukuchha on 14 May 2014
you can use, median filtering first and provide the resultant image to K-means. You would have use k-means X-times for reducing the effect of random generation of cluster centres.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!