KmeansTrainer never stops if it reaches 0 on the first iteration
Created by: anjos
The following code sample (color image segmentation) shows the problem:
import bob
import logging
image = bob.io.load('/idiap/resource/database/banca/english/images/en_video_sc1_1/1001_f_g1_s01_1001_en_1.ppm')
image_flat = image.reshape(3, -1).transpose().copy()
logging.getLogger().setLevel(logging.INFO)
kmeans = bob.machine.KMeansMachine(3, 3)
ktrainer = bob.trainer.KMeansTrainer()
ktrainer.max_iterations = 1000
ktrainer.convergence_threshold = 1e-5
ktrainer.train(kmeans, image_flat)
This code will iterate 1000 times instead of stopping on the very first iteration as expected.