|
Algorithm 1: Online K-Means clustering algorithm for color-based image segmentation |
| 1: |
Initialize the ‘k’ number of centroids, , , with random values. |
| 2: |
Initialize the counts n1, n2, n3 .... nk to zero. |
| 3: |
while ‘pixel stream continues’ do
|
| 4: |
p ← RGB2YCbCr(p) |
| 5: |
Match the input pixel, ‘p’, to a single centroid by minimizing the distance
|
| 6: |
Increment ni
|
| 7: |
Update the matching centroid, , using moving average |
| 8: |
← + (1/ ni)(p − ) |
| 9: |
Classify the input pixel, ‘p’, as ‘i’. |
| 10: |
end
|