I want to measure the time that KMColourSegmenter, in OpenIMAJ library, takes to perform the clustering.
If I didn't make the initial centroids fixed, rather than random, I can't make the measure the performance; because it will change every time, give different number of iterations , and vary in time to execute the clustering.
So how to make the initial centroids fixed i.e. setting them manually?
Update:
@Jon Thanks for the answer, I am trying to implement what you said. Could you check it, especially the "clusters" array I think this array doesn't make sense to initialize. Please, correct me if I am wrong.
public class MyFloatKMeansInit extends FloatKMeansInit{
@Override
public void initKMeans(DataSource<float[]> bds, float[][] clusters) throws IOException {
// TODO Auto-generated method stub
for (int i = 0; i < bds.size(); i++) {
for (int j = 0; j < bds.getData(i).length; j++) {
clusters[i][j]=bds.getData(i)[j];
}
}
}
}
public class MyKMColourSegmenter extends KMColourSegmenter{
public MyKMColourSegmenter(FloatArrayBackedDataSource bds, ColourSpace colourSpace, int K) throws IOException {
super(colourSpace, K);
MyFloatKMeansInit myFloatKMeansInit = new MyFloatKMeansInit();
float[][] clusters = new float[K][];//#######I think there is something wrong here
myFloatKMeansInit.initKMeans(bds, clusters);
this.kmeans.setInit(myFloatKMeansInit);
// TODO Auto-generated constructor stub
}
}