I want to count how many peanuts there are in this picture using image segmentation K-MEANS , does anyone know how to go about this?

I want to count how many peanuts there are in this picture using image segmentation K-MEANS , does anyone know how to go about this?

Late answer, but still. I would use the clustering in order to separate the peanuts from the background. But a color thresholding or a dominant color analysis should be enough and give comparable results. Except that I would consider each dark area (shadows) as the background in order to separate the peanuts.
Then you get a binary mask, and you can apply an ultimate eroded in order to estimate the number of peanuts.