An image segmentation by K-means cluster algorithm with c++. K-means cluster centers update according to three elements: 1.color, 2.coordinate, 3.texture. You can adjust the weight of them in the code.
VS2015 OpenCV3.1.0 Debug:x64
Test image:
Labeled image:
Segmentation result image:
Running result: