Commit 96f706a8 authored by lafabregue's avatar lafabregue

Update arff import to data to integrate as ImageData

parent 33a3a54f
......@@ -100,7 +100,7 @@ public class SimpleCluster extends Cluster {
this.data.setAttributesNames(data.getAttributesNames());
c = 0;
Iterator<DataObject> iter = data.iterator(0, clusterMap.length);
Iterator<DataObject> iter = data.iterator();
int i = 0;
while(iter.hasNext()) {
DataObject current = iter.next();
......
package jcl.clustering;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Vector;
import jcl.data.Data;
import jcl.data.DataObject;
import jcl.data.SimpleData;
import jcl.learning.LearningResult;
import jcl.learning.methods.monostrategy.kmeans.LearningResultKmeans;
import jcl.utils.exceptions.MethodNotImplementedException;
......@@ -100,6 +105,7 @@ public class SimpleClusteringResult extends ClusteringResult {
* Les critere d'evaluation de la classification
*
*/
@SuppressWarnings("unchecked")
public SimpleClusteringResult(final LearningResult learning,
final int clusterMap[], final double membershipDegree[][],
ClassificationWeights weights, final int nbClusters,
......@@ -152,6 +158,15 @@ public class SimpleClusteringResult extends ClusteringResult {
.getSeed(i).getCenter(), clusterSize[i]));
}
} else {
// in this case we need to compute cluster's centres
Iterator<DataObject> iter = data.getWholeSourceDataObjects();
Object[] clustersData = new Object[nbClusters];
for(int k = 0 ; k < nbClusters ; k++) {
clustersData[k] = new ArrayList<DataObject>();
}
for(int j = 0 ; j < clusterMap.length ; j++) {
((List<DataObject>) clustersData[clusterMap[j]]).add(iter.next());
}
for (int i = 0; i < nbClusters; i++) {
// if (membershipDegree == null) {
// clusters.add(new SimpleCluster(data, this.clusterMap, i, weights
......@@ -160,7 +175,8 @@ public class SimpleClusteringResult extends ClusteringResult {
// clusters.add(new SimpleCluster(data, this.clusterMap, i, weights
// .getWeights(i), membershipDegree[i], proba[i]));
// }
clusters.addElement(new LightCluster(this, i));
//clusters.addElement(new LightCluster(this, i));
clusters.add(new LightCluster(this, i, new SimpleData((List<DataObject>) clustersData[i]).mean(), clusterSize[i]));
}
}
this.clusters = new Cluster[clusters.size()];
......
......@@ -21,7 +21,7 @@ import loci.formats.FormatException;
* The image is read using the bioformats library
* This implementation is streamed but not parallelized yet.
*
* @author Baptiste Lafabregue
* @author Baptiste LAFABREGUE
*
*/
public class ImageSampler extends Sampler {
......@@ -40,7 +40,7 @@ public class ImageSampler extends Sampler {
private double offset = 1;
/** The list of indexes used to build the sample */
private List<Integer> selectedIndexes = null;
protected List<Integer> selectedIndexes = null;
/** Object to read the image */
private Vector<StreamedImageReaderWrapper> readers = null;
......@@ -179,6 +179,7 @@ public class ImageSampler extends Sampler {
this.geoTranslateVectors = sampler.geoTranslateVectors;
this.startX = sampler.startX;
this.startY = sampler.startY;
this.selectedIndexes = sampler.selectedIndexes;
}
@Override
......
......@@ -1187,7 +1187,7 @@ public class HybridClassification extends Classification implements Runnable {
final int nbre_agents = this.agents.size();
// nombre d'objets classifies : on prend le plus gros
final int nb_obj = (this.agents.get(0)).getData().getNbObjects();
final int nb_obj = (this.agents.get(0)).getData().getWholeDataNbObjects();
// Initialisation des parametres et de la matrice
stat = new int[nb_obj];
......
......@@ -444,6 +444,7 @@ public class StreamedImageReaderWrapper implements Iterable<double[]>, MemoryFlu
if (maxRAM == -1) {
tileHeight = optimaleTileHeight;
tileWidth = optimaleTileWidth;
return;
}
// there is an internal limit in bio-format to read 2GB of data at a time
if (maxRAM > 1900000000) {
......
......@@ -11,6 +11,14 @@ package jcl.utils.exceptions;
*/
public class MethodNotImplementedException extends Exception {
public MethodNotImplementedException() {
super();
}
public MethodNotImplementedException(String s) {
super(s);
}
/** */
private static final long serialVersionUID = 6965245284498658739L;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment