...
 
Commits (7)
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -23,6 +23,9 @@ import jcl.data.Data;
import jcl.data.DataObject;
import jcl.data.SimpleData;
import jcl.data.attribute.AttributeMultiDimSequence;
import jcl.data.distance.DistanceModel;
import jcl.data.distance.DistanceParameter;
import jcl.weights.GlobalWeights;
import mustic.gui.MainFrame;
import mustic.gui.dialog.Messages;
import mustic.gui.dialog.SequenceDialog;
......@@ -138,7 +141,7 @@ public class ArffToDataDialog extends JInternalFrame implements ToUpdateObject {
}
}
@SuppressWarnings({ "unchecked", "deprecation" })
@SuppressWarnings({ "unchecked" })
protected void buttonOk_actionPerformed() {
try {
Object[] result = DataArffExchange.arffToData(this.textFile.getText());
......@@ -212,16 +215,23 @@ public class ArffToDataDialog extends JInternalFrame implements ToUpdateObject {
// test if we have one or multiples images
if (sequenceFiles.size() > 1) {
data = new ImageData(new ImportedImageSampler(sequenceFilesPath,
(List<DataObject>) result[1], (List<Integer>) result[0]), sequenceFiles);
(List<DataObject>) result[1], (List<Integer>) result[0]), sequenceFiles, null, null);
} else {
data = new ImageData(new ImportedImageSampler(sequenceFilesPath.get(0),
(List<DataObject>) result[1], (List<Integer>) result[0]), sequenceFiles.get(0));
(List<DataObject>) result[1], (List<Integer>) result[0]), sequenceFiles.get(0),
null, null);
}
} else {
// if no images is associated we create a SimpleData
data = new SimpleData((List<DataObject>) result[1]);
data = new SimpleData((List<DataObject>) result[1], null, null);
}
DistanceModel distanceModel = DistanceModel.generateDefaultModel(
data.getOneDataObject(), new GlobalWeights(data.getOneDataObject()));
DistanceParameter[][] distanceParameters = DistanceModel
.generateDefaultDistanceParameters(1, distanceModel, data);
data.setDistanceModel(distanceModel, distanceParameters);
if (this.textData.getText().length() == 0) {
this.textData.setText(DataArffExchange.getRelationName(this.textFile.getText()));
......
......@@ -56,6 +56,9 @@ import jcl.clustering.constraints.LabelConstraint;
import jcl.clustering.constraints.MustLinkConstraint;
import jcl.clustering.constraints.NbClusterConstraint;
import jcl.data.Data;
import jcl.data.distance.DistanceModel;
import jcl.data.distance.DistanceParameter;
import jcl.weights.GlobalWeights;
import mustic.utils.image.ImageAddOn;
import mustic.utils.image.ImageDisplayer;
import mustic.utils.tools.ProgressPropertyChangeListener;
......@@ -161,11 +164,15 @@ public class ConstraintsSelectionFrame extends JFrame implements ImageAddOn {
this.imageDisplayer = imgDisplayer;
this.constraintsContainer = constraintsContainer;
if (data != null) {
// case of Data provided
minDistance = data.getEstimatedMinDistance();
maxDistance = data.getEstimatedMaxDistance();
DistanceModel model = DistanceModel.generateDefaultModel(data.getOneDataObject(),
new GlobalWeights(data.getOneDataObject()));
DistanceParameter[][] parameters = DistanceModel.generateDefaultDistanceParameters(1,model, data);
minDistance = data.getEstimatedMinDistance(model, parameters[0]);
maxDistance = data.getEstimatedMaxDistance(model, parameters[0]);
this.data = data;
} else {
// otherwise we base our estimation on the image
......
......@@ -24,6 +24,9 @@ import jcl.data.Data;
import jcl.data.DataObject;
import jcl.data.SimpleData;
import jcl.data.attribute.AttributeMultiDimSequence;
import jcl.data.distance.DistanceModel;
import jcl.data.distance.DistanceParameter;
import jcl.weights.GlobalWeights;
import multiCube.tools.image.ImageHelper;
import mustic.gui.MainFrame;
import mustic.gui.dialog.Messages;
......@@ -140,7 +143,6 @@ public class CSVToDataDialog extends JInternalFrame implements ToUpdateObject {
}
}
@SuppressWarnings({"deprecation"})
protected void buttonOk_actionPerformed() {
try {
List<DataObject> result = new ArrayList<DataObject>();
......@@ -160,7 +162,11 @@ public class CSVToDataDialog extends JInternalFrame implements ToUpdateObject {
}
if(result != null) {
data = new SimpleData(result);
data = new SimpleData(result, null, null);
DistanceModel model = DistanceModel.generateDefaultModel(data.getOneDataObject(),
new GlobalWeights(data.getOneDataObject()));
DistanceParameter[][] parameters = DistanceModel.generateDefaultDistanceParameters(1,model, data);
data.setDistanceModel(model, parameters);
if (this.textData.getText().length() == 0) {
this.textData.setText(ImageHelper.extractFileName(
......
package mustic.gui.dialog.csv;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.List;
import javax.swing.JButton;
import javax.swing.JFileChooser;
import javax.swing.JInternalFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;
import jcl.data.Data;
import jcl.data.DataObject;
import jcl.data.DistanceModel;
import jcl.data.SimpleData;
import jcl.data.attribute.AttributeMultiDimSequence;
<<<<<<< HEAD
import jcl.data.distance.DistanceParameter;
import jcl.weights.GlobalWeights;
=======
import multiCube.tools.image.ImageHelper;
>>>>>>> master
import mustic.gui.MainFrame;
import mustic.gui.dialog.Messages;
import mustic.utils.documentFilter.ToUpdateObject;
import mustic.utils.io.CSVUtils;
/**
* Dialog that allow the user to generate a Data from an arff file
*
* @author Baptiste LAFABREGUE
*
*/
public class CSVToDataDialog extends JInternalFrame implements ToUpdateObject {
private static final long serialVersionUID = 1L;
private JTextField textFile = new JTextField();
private JTextField textData = new JTextField();
private JTextField textSeparator = new JTextField();
public CSVToDataDialog() {
super();
JPanel mainPanel = new JPanel(new BorderLayout());
JPanel panel = new JPanel(new GridLayout(3, 2));
JPanel pInpout = new JPanel(new BorderLayout());
panel.add(new JLabel(Messages.getString("CSVToDataDialog.0")), BorderLayout.WEST); //$NON-NLS-1$
pInpout.add(this.textFile, BorderLayout.CENTER);
this.textFile.addFocusListener(new FocusListener() {
@Override
public void focusLost(FocusEvent e) {
updateOutputName();
}
@Override
public void focusGained(FocusEvent e) {
}
});
JButton buttonBrowse = new JButton("..."); //$NON-NLS-1$
buttonBrowse.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
JFileChooser fileChooser = new JFileChooser();
int returnVal = fileChooser
.showOpenDialog(CSVToDataDialog.this);
if (returnVal == JFileChooser.APPROVE_OPTION) {
CSVToDataDialog.this.textFile.setText(fileChooser
.getSelectedFile().getPath());
updateOutputName();
if (!fileChooser.getSelectedFile().getPath()
.endsWith(".csv")) { //$NON-NLS-1$
JOptionPane.showMessageDialog(CSVToDataDialog.this,
Messages.getString("CSVToDataDialog.3"), //$NON-NLS-1$
Messages.getString("CSVToDataDialog.4"), //$NON-NLS-1$
JOptionPane.WARNING_MESSAGE);
}
}
}
});
pInpout.add(buttonBrowse, BorderLayout.EAST);
panel.add(pInpout);
JPanel pSeparator = new JPanel(new BorderLayout());
panel.add(new JLabel(Messages.getString("CSVToDataDialog.2")), BorderLayout.WEST); //$NON-NLS-1$
pSeparator.add(this.textSeparator, BorderLayout.CENTER);
panel.add(pSeparator);
this.textSeparator.setText(";");
JPanel pOutpout = new JPanel(new BorderLayout());
panel.add(new JLabel(Messages.getString("CSVToDataDialog.5")), BorderLayout.WEST); //$NON-NLS-1$
pOutpout.add(this.textData, BorderLayout.CENTER);
panel.add(pOutpout);
this.textFile.setPreferredSize(new Dimension(200, 30));
JPanel panelButton = new JPanel();
JButton buttonOk = new JButton(Messages.getString("CSVToDataDialog.7")); //$NON-NLS-1$
panelButton.add(buttonOk);
buttonOk.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
buttonOk_actionPerformed();
}
});
mainPanel.add(panel, BorderLayout.NORTH);
mainPanel.add(panelButton, BorderLayout.SOUTH);
this.setContentPane(mainPanel);
this.setTitle(Messages.getString("CSVToDataDialog.8")); //$NON-NLS-1$
this.setSize(300, 180);
this.setResizable(true);
this.setMaximizable(true);
this.setIconifiable(true);
this.setClosable(true);
this.setVisible(true);
this.requestFocus();
}
private void updateOutputName() {
if (this.textData.getText() != null && this.textData.getText() != "") { //$NON-NLS-1$
// we don't update if there is already a value
return;
}
if (this.textFile.getText() != null && this.textFile.getText() != "") { //$NON-NLS-1$
this.textData.setText(ImageHelper.extractFileName(
ImageHelper.stripExtension(this.textData.getText())));
}
}
protected void buttonOk_actionPerformed() {
try {
List<DataObject> result = new ArrayList<DataObject>();
Data data = null;
CSVUtils reader = null;
try {
File file = new File(this.textFile.getText());
reader = new CSVUtils(file, this.textSeparator.getText().charAt(0));
List<String> line;
while((line = reader.readNext()) != null) {
extractObjectFromLine(result, line);
}
} catch (FileNotFoundException e) {
e.printStackTrace();
result = null;
}
if(result != null) {
data = new SimpleData(result, null, null);
DistanceModel model = DistanceModel.generateDefaultModel(data.getOneDataObject(),
new GlobalWeights(data.getOneDataObject()));
DistanceParameter[][] parameters = DistanceModel.generateDefaultDistanceParameters(1,model, data);
data.setDistanceModel(model, parameters);
if (this.textData.getText().length() == 0) {
this.textData.setText(ImageHelper.extractFileName(
ImageHelper.stripExtension(this.textData.getText())));
}
data.setDataName(this.textData.getText());
MainFrame.getInstance().createDataSession(data);
JOptionPane.showMessageDialog(this,
Messages.getString("CSVToDataDialog.151") + this.textData.getText() //$NON-NLS-1$
+ " " + Messages.getString("CSVToDataDialog.152"), //$NON-NLS-1$
Messages.getString("CSVToDataDialog.16"), //$NON-NLS-1$
JOptionPane.INFORMATION_MESSAGE);
} else {
JOptionPane.showMessageDialog(this,
Messages.getString("CSVToDataDialog.41"), //$NON-NLS-1$
Messages.getString("CSVToDataDialog.4"), //$NON-NLS-1$
JOptionPane.WARNING_MESSAGE);
}
this.dispose();
} catch (Exception e) {
JOptionPane.showMessageDialog(this,
Messages.getString("CSVToDataDialog.41"), //$NON-NLS-1$
Messages.getString("CSVToDataDialog.4"), //$NON-NLS-1$
JOptionPane.WARNING_MESSAGE);
e.printStackTrace();
}
}
/**
* Construct a DataObject from a set of Strings and add it to a List
* @param list
* the list to add the DataObject to
* @param line
* the line to interpret
*/
private void extractObjectFromLine(List<DataObject> list, List<String> line) {
DataObject obj = new DataObject(1);
double[][] seq = new double[line.size()][];
for (int i = 0 ; i < line.size() ; i++) {
seq[i] = new double[1];
seq[i][0] = Double.parseDouble(line.get(i));
}
obj.setAttribute(0, new AttributeMultiDimSequence(seq));
list.add(obj);
}
@Override
public void update(String s) {
}
}
......@@ -21,6 +21,9 @@ import javax.swing.text.PlainDocument;
import jcl.data.Data;
import jcl.data.DataObject;
import jcl.data.SimpleData;
import jcl.data.distance.DistanceModel;
import jcl.data.distance.DistanceParameter;
import jcl.weights.GlobalWeights;
import mustic.gui.MainFrame;
import mustic.gui.dialog.Messages;
import mustic.utils.documentFilter.BasicIntDocumentFilter;
......@@ -158,7 +161,13 @@ public class OGRToDataDialog extends JInternalFrame implements ToUpdateObject {
if(result != null) {
data = new SimpleData(result);
data = new SimpleData(result, null, null);
DistanceModel distanceModel = DistanceModel.generateDefaultModel(
data.getOneDataObject(), new GlobalWeights(data.getOneDataObject()));
DistanceParameter[][] distanceParameters = DistanceModel
.generateDefaultDistanceParameters(1, distanceModel, data);
data.setDistanceModel(distanceModel, distanceParameters);
data.setDataName(this.textData.getText());
MainFrame.getInstance().createDataSession(data);
......
This diff is collapsed.
......@@ -4,8 +4,6 @@ import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
import java.io.*;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Observable;
import java.util.Observer;
import java.util.Vector;
......@@ -949,10 +947,11 @@ public class ImageResultPanel extends ResultPanel implements TreeSelectionListen
*/
public void hClustering_actionPerformed(boolean newResult) {
try {
LearningParameters learningParameters = new ParametersAHC(null);
LearningParameters learningParameters = new ParametersAHC(imgData.getDistanceModel(),
imgData.getDistanceParameters());
LearningMethod learningMethod = learningParameters.getLearningMethodInstance();
@SuppressWarnings("deprecation")
Data classificationData = new SimpleData(this.result.getClusterCenters());
Data classificationData = new SimpleData(this.result.getClusterCenters(),
imgData.getDistanceModel(), imgData.getDistanceParameters());
LearningResult learningResult = learningMethod.learn(classificationData);
this.result.hierarchy = ((LearningResultAHC) learningResult).getHierarchy();
Classification classif = new SingleClassification("", classificationData, learningMethod, this.result);
......@@ -1199,12 +1198,6 @@ public class ImageResultPanel extends ResultPanel implements TreeSelectionListen
out.closeEntry();
}
out.putNextEntry(new ZipEntry(name + '/' + "ParameterMode.ser"));
oos = new ObjectOutputStream(out);
oos.writeObject(AttributeMultiDimSequence.getMode());
oos.flush();
out.closeEntry();
out.putNextEntry(new ZipEntry(name + '/' + "ParameterSimplify.ser"));
oos = new ObjectOutputStream(out);
oos.writeObject(AttributeMultiDimSequence.getSimplifyFrom());
......@@ -1311,12 +1304,6 @@ public class ImageResultPanel extends ResultPanel implements TreeSelectionListen
out.closeEntry();
}
out.putNextEntry(new ZipEntry(name + '/' + "ParameterMode.ser"));
oos = new ObjectOutputStream(out);
oos.writeObject(AttributeMultiDimSequence.getMode());
oos.flush();
out.closeEntry();
out.putNextEntry(new ZipEntry(name + '/' + "ParameterSimplify.ser"));
oos = new ObjectOutputStream(out);
oos.writeObject(AttributeMultiDimSequence.getSimplifyFrom());
......
......@@ -5,7 +5,10 @@ import java.awt.event.ActionEvent;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import jcl.data.distance.DistanceModel;
import jcl.data.distance.DistanceParameter;
import jcl.learning.LearningParameters;
import jcl.weights.GlobalWeights;
import mustic.gui.ImageDesktopFrame;
import mustic.gui.MainFrame;
import mustic.io.ImageData;
......@@ -79,7 +82,13 @@ class RemoteSensingClassifierDialog extends ClassifierDialog {
if (this.bidouille == null) {
img = MainFrame.getInstance().getDesktop().getAllImageDesktopFrames()[this.dataBox
.getSelectedIndex()].getImageSession().getRawImage();
this.bidouille = new ImageData(img);
this.bidouille = new ImageData(img, null, null);
DistanceModel distanceModel = DistanceModel.generateDefaultModel(
this.bidouille.getOneDataObject(), new GlobalWeights(this.bidouille.getOneDataObject()));
DistanceParameter[][] distanceParameters = DistanceModel
.generateDefaultDistanceParameters(1, distanceModel, this.bidouille);
this.bidouille.setDistanceModel(distanceModel, distanceParameters);
}
LearningParameters params = this.classifiersPanel
......
......@@ -20,6 +20,7 @@ import jcl.learning.methods.monostrategy.som.ParametersSOM;
import jcl.weights.ClassificationWeights;
import jcl.weights.GlobalWeights;
import jcl.weights.Weights;
import mustic.gui.DataDesktopFrame;
import mustic.gui.DesktopFrame;
import mustic.gui.ImageDesktopFrame;
import mustic.gui.MainFrame;
......@@ -861,52 +862,52 @@ public class ClassifierHandler extends DefaultHandler {
} else if (qName.equals("InitMethod")) { //$NON-NLS-1$
Data data = null;
DesktopFrame[] desktopFrames = MainFrame.getInstance().getDesktop()
.getAllDesktopFrames();
DataDesktopFrame[] desktopFrames = MainFrame.getInstance().getDesktop()
.getAllDataDesktopFrames();
int nbSessions = desktopFrames.length;
for (int i = 0; i < nbSessions; i++) {
if (this.listData.get(0).equals(
desktopFrames[i].getImageSession().getRawImage()
.getPath())) {
data = desktopFrames[i].getImageSession().getImageData();
desktopFrames[i].getDataSession().getAssociatedImageSessions().get(0)
.getRawImage().getPath())) {
data = desktopFrames[i].getDataSession().getData();
break;
}
}
if (data == null) {
File f = new File(this.listData.get(0));
try {
MainFrame.getInstance().createSession(
MainFrame.getInstance().createImageSession(
MainFrame.getInstance().open(f), null);
if (MainFrame.getInstance().getCurrentSession()
if (MainFrame.getInstance().getCurrentImageSession()
.getRawImage().getNbBands() > 1) {
MainFrame.getInstance().getCurrentSession()
MainFrame.getInstance().getCurrentImageSession()
.getBirdViewPanel().setR(0);
MainFrame.getInstance().getCurrentSession()
MainFrame.getInstance().getCurrentImageSession()
.getBirdViewPanel().setG(1);
MainFrame.getInstance().getCurrentSession()
MainFrame.getInstance().getCurrentImageSession()
.getBirdViewPanel().setB(2);
MainFrame
.getInstance()
.getCurrentSession()
.getCurrentImageSession()
.getBirdViewPanel()
.syncImage(
MainFrame.getInstance()
.getCurrentSession());
.getCurrentImageSession());
PictureTool.setR(MainFrame.getInstance()
.getCurrentSession().getRawImage()
.getCurrentImageSession().getRawImage()
.getBirdview(), 0);
PictureTool.setG(MainFrame.getInstance()
.getCurrentSession().getRawImage()
.getCurrentImageSession().getRawImage()
.getBirdview(), 1);
PictureTool.setB(MainFrame.getInstance()
.getCurrentSession().getRawImage()
.getCurrentImageSession().getRawImage()
.getBirdview(), 2);
MainFrame.getInstance().getCurrentSession()
MainFrame.getInstance().getCurrentImageSession()
.getBirdViewPanel().refresh();
MainFrame.getInstance().getCurrentSession().associatedFrame
MainFrame.getInstance().getCurrentImageSession().associatedFrame
.toBack();
data = MainFrame.getInstance().getCurrentSession()
data = MainFrame.getInstance().getCurrentImageSession()
.getData();
}
} catch (Exception e) {
......
......@@ -10,9 +10,15 @@ import javax.swing.*;
import javax.swing.border.TitledBorder;
import jcl.data.Data;
import jcl.data.attribute.Attribute;
import jcl.data.attribute.AttributeMultiDimSequence;
import jcl.data.distance.Distance;
import jcl.data.distance.DistanceModel;
import jcl.data.distance.DistanceParameter;
import jcl.data.distance.sequential.DistanceEuclidean;
import jcl.learning.LearningParameters;
import jcl.learning.methods.multistrategy.samarah.*;
import jcl.weights.GlobalWeights;
import mustic.gui.MainFrame;
import mustic.gui.dialog.classifier.AgentDialog;
import mustic.gui.panels.classifier.*;
......@@ -74,7 +80,7 @@ public class HybridClassificationPanel extends JPanel implements AgentListManage
this.title = this.title + "." + HybridClassificationPanel.nbSamarah;
HybridClassificationPanel.nbSamarah++;
// this.samarah = new HybridClassification("TEST", data, null);
this.samarah = new HybridClassification();
this.samarah = new HybridClassification(null, null);
if (MainFrame.DEBUG_MODE)
System.out.println(" in HybridClassificationParametersPanel() ");
this.samarah.config.printInfo();
......@@ -98,7 +104,11 @@ public class HybridClassificationPanel extends JPanel implements AgentListManage
jbInit();
HybridClassificationPanel.nbSamarah++;
// this.samarah = new HybridClassification("TEST", data, null);
this.samarah = new HybridClassification();
DistanceModel model = DistanceModel.generateDefaultModel(data.getOneDataObject(),
new GlobalWeights(data.getOneDataObject()));
DistanceParameter[][] parameters = DistanceModel.generateDefaultDistanceParameters(1,model, data);
this.samarah = new HybridClassification(model, parameters);
}
@Override
......@@ -151,12 +161,17 @@ public class HybridClassificationPanel extends JPanel implements AgentListManage
else {
file += "\t\t<isSimplifySequence>true</isSimplifySequence>\n";
}
if (AttributeMultiDimSequence.getMode() == AttributeMultiDimSequence.EUCLIDIEN) {
file += "\t\t<isUseNaiveDist>true</isUseNaiveDist>\n";
}
else {
file += "\t\t<isUseNaiveDist>false</isUseNaiveDist>\n";
}
//TODO try to match with the new distanceModel
// for (Distance<Attribute, DistanceParameter> d : agent.getParams().getModel().getDistances()) {
// if(!(d instanceof DistanceEuclidean))
//
// }
// if (AttributeMultiDimSequence.getMode() == AttributeMultiDimSequence.EUCLIDIEN && agent.getParams().getModel()) {
// file += "\t\t<isUseNaiveDist>true</isUseNaiveDist>\n";
// }
// else {
// file += "\t\t<isUseNaiveDist>false</isUseNaiveDist>\n";
// }
if (agent.getParams().weights != null) {
file += "\t\t<weight>";
double weights[] = agent.getParams().weights.getGlobalWeights().getWeights();
......
......@@ -15,8 +15,11 @@ import javax.swing.JScrollPane;
import com.l2fprod.common.swing.JTaskPane;
import com.l2fprod.common.swing.JTaskPaneGroup;
import jcl.data.distance.DistanceModel;
import jcl.data.distance.DistanceParameter;
import jcl.data.mask.Mask;
import jcl.data.sampling.Sampler;
import jcl.weights.GlobalWeights;
import mustic.gui.ImageDesktopFrame;
import mustic.gui.ImageSession;
import mustic.gui.MainFrame;
......@@ -143,12 +146,19 @@ public class DataConstructPanel extends JPanel implements ToUpdateObject {
if (containsAtLeastOne) {
((ImageSampler) sample).setMaskSequence(maskSequence);
}
}
}
if (filesPaths.size() > 1) {
data = new ImageData(sample, filesPaths);
data = new ImageData(sample, filesPaths, null, null, null);
} else {
data = new ImageData(sample, filesPaths.get(0));
data = new ImageData(sample, filesPaths.get(0), null, null);
}
DistanceModel distModel = DistanceModel.generateDefaultModel(data.getOneDataObject(),
new GlobalWeights(data.getOneDataObject()));
DistanceParameter[][] distParameters = DistanceModel
.generateDefaultDistanceParameters(1, distModel, data);
data.setDistanceModel(distModel, distParameters);
MainFrame.getInstance().createDataSession(data);
DataConstructFrame.getInstance().updateDataConstructPanel();
......
......@@ -6,8 +6,9 @@ import java.util.Vector;
import jcl.data.DataObject;
import jcl.data.SimpleData;
import jcl.data.attribute.AttributeMultiDimSequence;
import jcl.data.attribute.AttributeNumerical;
import jcl.data.distance.DistanceModel;
import jcl.data.distance.DistanceParameter;
import jcl.data.mask.Mask;
import jcl.data.sampling.Sampler;
import multiCube.tools.util.exceptions.MethodNotImplementedException;
......@@ -58,7 +59,8 @@ public class ImageData extends SimpleData implements Serializable {
* @param image the image to convert
*/
@Deprecated
public ImageData(RawImage image) {
public ImageData(RawImage image, DistanceModel model, DistanceParameter[][] parameters) {
super(model, parameters);
if (MainFrame.DEBUG_MODE) {
System.out.println(">> ImageData(RawImage) <<");
}
......@@ -167,7 +169,8 @@ public class ImageData extends SimpleData implements Serializable {
* @param percent le pourcentage de pixels a choisir parmi l'image
*/
@Deprecated
public ImageData(RawImage image, double percent) {
public ImageData(RawImage image, double percent, DistanceModel model, DistanceParameter[][] parameters) {
super(model, parameters);
if (MainFrame.DEBUG_MODE)
System.out.println(">> ImageData(RawImage, double) <<");
......@@ -236,8 +239,12 @@ public class ImageData extends SimpleData implements Serializable {
* the path of the image
* @param mask
* a mask to apply to the sampler
* @param model
* the model to use with the data
*/
public ImageData(Sampler sampler, RawImage path, Mask mask) {
public ImageData(Sampler sampler, RawImage path, Mask mask,
DistanceModel model, DistanceParameter[][] parameters) {
super(model, parameters);
if (MainFrame.DEBUG_MODE) {
System.out.println(">> ImageData(Sampler,String) <<");
}
......@@ -289,7 +296,6 @@ public class ImageData extends SimpleData implements Serializable {
long endTime = System.currentTimeMillis();
System.out.println("___________________Total elapsed time in execution of loading image is :" + ((endTime - startTime)));
}
}
/**
......@@ -302,15 +308,16 @@ public class ImageData extends SimpleData implements Serializable {
* The sample to extract data from
* @param path
* the path of the image
* @param model
* the model to use with the data
*/
public ImageData(Sampler sampler, RawImage path) {
this(sampler, path, null);
public ImageData(Sampler sampler, RawImage path, DistanceModel model, DistanceParameter[][] parameters) {
this(sampler, path, null, model, parameters);
}
/**
* <p>
* Construcor from an already built set of DataObject of a sampler,
* Constructor from an already built set of DataObject of a sampler,
* paths are only used to gather the image informations
* </p>
*
......@@ -320,9 +327,12 @@ public class ImageData extends SimpleData implements Serializable {
* paths of the images
* @param mask
* a mask to apply to the sampler
* @param model
* the model to use with the data
*/
public ImageData(Sampler sampler, Vector<RawImage> images, Mask mask) {
public ImageData(Sampler sampler, Vector<RawImage> images, Mask mask,
DistanceModel model, DistanceParameter[][] parameters) {
super(model, parameters);
for(RawImage s : images) {
this.rawImages.add(s);
}
......@@ -381,12 +391,11 @@ public class ImageData extends SimpleData implements Serializable {
System.out.println("___________________Total elapsed time in execution of loading image is :"
+ ((endTime - startTime)));
}
}
/**
* <p>
* Construcor from an already built set of DataObject of a sampler,
* Constructor from an already built set of DataObject of a sampler,
* paths are only used to gather the image informations
* </p>
*
......@@ -394,11 +403,12 @@ public class ImageData extends SimpleData implements Serializable {
* the sample to extract data from
* @param path
* paths of the images
* @param mask
* a mask to apply to the sampler
* @param model
* the model to use with the data
*/
public ImageData(Sampler sampler, Vector<RawImage> images) {
this(sampler, images, null);
public ImageData(Sampler sampler, Vector<RawImage> images,
DistanceModel model, DistanceParameter[][] parameters) {
this(sampler, images, null, model, parameters);
}
......@@ -523,12 +533,6 @@ public class ImageData extends SimpleData implements Serializable {
public void setResolution(double resolution) {
this.resolution = resolution;
}
private void setProperties(int mode, int simplifyFrom) {
AttributeMultiDimSequence.setMode(mode);
AttributeMultiDimSequence.setSimplifyFrom(simplifyFrom);
}
/**
* <p>
......
This diff is collapsed.
......@@ -146,7 +146,8 @@ public class FilterDataDialog extends JDialog {
private void jButtonOK_actionPerformed() {
setVisible(false);
Filter filter = FilterUtils.createFilter(getParameters());
Filter filter = FilterUtils.createFilter(getParameters(),
data.getDistanceModel(), data.getDistanceParameters());
new FilterThread(filter, this.data, MainFrame.getProgressBar(), this)
.start();
}
......
......@@ -13,6 +13,8 @@ import javax.swing.tree.*;
import jcl.Classification;
import jcl.clustering.Cluster;
import jcl.clustering.ClusteringResult;
import jcl.data.distance.DistanceModel;
import jcl.data.distance.DistanceParameter;
import jcl.learning.IterativeClassification;
import jcl.learning.methods.ClassifierUtils;
import jcl.learning.methods.multistrategy.samarah.HybridClassification;
......@@ -107,15 +109,20 @@ public class ClassConfigPanel extends JPanel implements TreeSelectionListener, A
* Constructeur par defaut.
* </p>
* @param classification les classes e afficher
* @param model
* the model used to compute the distance
* @param parameters
* the list of parameters used by the distance model
* @param resultPanel le panel de resultat e rafraichir en cas de modification. peut etre null
*/
public ClassConfigPanel(Classification classification, ResultPanel resultPanel) {
public ClassConfigPanel(Classification classification, ResultPanel resultPanel,
DistanceModel model, DistanceParameter[] parameters) {
super();
this.classification_ = classification;
this.resultPanel_ = resultPanel;
this.setLayout(new BorderLayout());
this.treeScrollPane = new JScrollPane();
this.treeScrollPane.setViewportView(getClusterTree());
this.treeScrollPane.setViewportView(getClusterTree(model, parameters));
this.treeScrollPane.setBorder(BorderFactory.createTitledBorder("Clusters"));
JPanel panel = null;
......@@ -911,12 +918,17 @@ public class ClassConfigPanel extends JPanel implements TreeSelectionListener, A
* <p>
* This method initializes clusterTree.
* </p>
*
* @param model
* the model used to compute the distance
* @param parameters
* the list of parameters used by the distance model
* @return le tree configure
*/
private JTree getClusterTree() {
private JTree getClusterTree(DistanceModel model, DistanceParameter[] parameters) {
ClusteringResult result = this.classification_.getClusteringResult();
this.clusterTree = new JTree(result.getRoot());
this.clusterTree = new JTree(result.getRoot(model, parameters));
this.clusterTree.setRootVisible(true);
this.clusterTree.setSelectionRow(0);
this.clusterTree.addTreeSelectionListener(this);
......
This diff is collapsed.
......@@ -109,7 +109,7 @@ public class HybridClassificationParametersPanel extends JPanel {
this.jSliderPcr.setValue(20);
// this.samarah = new HybridClassification("TEST", data, null);
this.data = null;
this.samarah = new HybridClassification();
this.samarah = new HybridClassification(null, null);
System.out.println(" in HybridClassificationParametersPanel() ");
this.samarah.config.printInfo();
}
......@@ -128,7 +128,7 @@ public class HybridClassificationParametersPanel extends JPanel {
this.jSliderPcr.setValue(20);
// this.samarah = new HybridClassification("TEST", data, null);
this.data = data;
this.samarah = new HybridClassification();
this.samarah = new HybridClassification(data.getDistanceModel(), data.getDistanceParameters());
}
/**
......
......@@ -259,7 +259,8 @@ class MaclawViewer extends ViewerQualityEvolution {
ClusteringResult clusteringResult = null;
clusteringResult = this.learningResult.classify(this.data, false);
quality = clusteringResult.evaluate();
quality = clusteringResult.evaluate(this.data.getDistanceModel(),
this.data.getDistanceParameters()[0]);
quality.setTime(elapsed);
this.monitor.partitionEvolution.add(quality.getQualityIndex(0)
......
......@@ -115,15 +115,12 @@ public class MaclawClassificationParametersPanel extends JPanel {
break;
}
ClassificationWeights weights = new GlobalWeights(new Weights(
this.data.getOneDataObject().getNbAttributes()));
this.param = new ParametersMaclaw(distributed, nbGenerations,
nbIndividuals, nbClusters, nbRefs,
ClassifierModular.PRODUCT, nbCpu, initParams, initParams,
fuzzy, alpha, phi, clusterQualityCriterion,
ClassifierMaclaw.WEIGHTING, ClassifierMaclaw.GENETIC, 1.,
weights);
ClassifierMaclaw.WEIGHTING, ClassifierMaclaw.GENETIC, 1.,
initParams.getModel(), initParams.getDistanceParameters());
}
return this.param;
}
......
......@@ -51,7 +51,8 @@ public class QualityPanel extends JPanel implements Serializable {
this.qualities = qualities;
} else {
this.qualities = ClusteringEvaluation
.getAllQualities(classification);
.getAllQualities(classification, classification.getData().getDistanceModel(),
classification.getData().getDistanceParameters()[0]);
}
int nbIndices = this.qualities.length;
......
......@@ -194,7 +194,9 @@ public class ResultPanel extends JPanel {
/* On garde une trace de la classification */
this.classification = classification;
this.classPanel = new ClassConfigPanel(this.classification, this);
this.classPanel = new ClassConfigPanel(this.classification, this,
classification.getData().getDistanceModel(),
classification.getData().getDistanceParameters()[0]);
this.classFrame = frame;
setLayout(new BorderLayout());
panel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
......
......@@ -37,7 +37,7 @@ public class WriteDistancesPath {
//System.out.println("\t\t " + i + " ===> j = " + (i+1+j));
dataObject2 = dataObjectIter_j.next();
//distance = DistanceDTWMD.getInstance().compute(attMultiDimSequence1, attMultiDimSequence2, parameterDTW);
distance = dataObject1.distance(dataObject2);
distance = dataObject1.distance(dataObject2, data.getDistanceModel(), data.getDistanceParameters()[0]);
line += (distance);
if (dataObjectIter_j.hasNext())
line += ",";
......
......@@ -959,12 +959,6 @@ public class ImageSampler extends Sampler {
return selectedIndexes;
}
@Override
public DataObject getDataObject(int index) {
updateRAMAvailable(false);
return getDataObject(index);
}
/**
* Return the mask list used to generate the data
* It does not affect the whole data functions.
......@@ -1018,8 +1012,8 @@ public class ImageSampler extends Sampler {
this.cursorX = start % sampler.imageWidth;
this.cursorY = start / sampler.imageWidth;
if (end >= sampler.imageHeight * sampler.imageWidth -1) {
this.endY = sampler.imageHeight-1;
this.endX = sampler.imageWidth-1;
this.endY = sampler.imageHeight;
this.endX = sampler.imageWidth;
} else {
this.endX = end % sampler.imageWidth;
this.endY = end / sampler.imageWidth;
......@@ -1091,8 +1085,8 @@ public class ImageSampler extends Sampler {
this.cursorX = start % sampler.imageWidth;
this.cursorY = start / sampler.imageWidth;
if (end >= sampler.imageHeight * sampler.imageWidth -1) {
this.endY = sampler.imageHeight-1;
this.endX = sampler.imageWidth-1;
this.endY = sampler.imageHeight;
this.endX = sampler.imageWidth;
} else {
this.endX = end % sampler.imageWidth;
this.endY = end / sampler.imageWidth;
......@@ -1182,8 +1176,8 @@ public class ImageSampler extends Sampler {
this.cursorX = start % sampler.imageWidth;
this.cursorY = start / sampler.imageWidth;
if (end >= sampler.imageHeight * sampler.imageWidth -1) {
this.endY = sampler.imageHeight-1;
this.endX = sampler.imageWidth-1;
this.endY = sampler.imageHeight;
this.endX = sampler.imageWidth;
} else {
this.endX = end % sampler.imageWidth;
this.endY = end / sampler.imageWidth;
......
......@@ -9,13 +9,11 @@ import java.util.Vector;
import jcl.data.Data;
import jcl.data.DataObject;
import jcl.data.Model;
import jcl.data.SimpleData;
import jcl.data.attribute.AttributeNumerical;
import jcl.data.distance.Distance;
import jcl.data.distance.MetaDistance;
import jcl.data.distance.MetaDistanceEuclidean;
import jcl.data.distance.NumericalEuclideanDistance;
import jcl.data.distance.DistanceModel;
import jcl.data.distance.DistanceParameter;
import jcl.weights.GlobalWeights;
import jsl.Segmentation;
import jsl.io.Descripteur;
import jsl.io.ObjetImage;
......@@ -109,19 +107,18 @@ public class RegionDataBuilder extends SimpleData {
index++;
}
Distance[] distances = new Distance[listDesc.size()]; // a distance is set for every attribute
for (int i = 0; i < listDesc.size(); i++) {
distances[i] = NumericalEuclideanDistance.getInstance(); // first attribute compared with an euclidean distance between numericals
}
MetaDistance metaDistance = MetaDistanceEuclidean.getInstance(); // defines the way the two scores are combined (possibility to weight)
Model model = new Model(distances, metaDistance);
this.data = new SimpleData(allObjects, model);
this.data = new SimpleData(allObjects, null, null);
this.data.setAttributesNames(names);
this.data.setComments("% Donnees de regions");
this.data.setDataName("Regions");
Vector<String> filesName = new Vector<String>();
filesName.add("not assigned");
this.data.setDataFilesName(filesName);
DistanceModel model = DistanceModel.generateDefaultModel(this.data.getOneDataObject(),
new GlobalWeights(this.data.getOneDataObject()));
DistanceParameter[][] parameters = DistanceModel.generateDefaultDistanceParameters(1,model, this.data);
this.data.setDistanceModel(model, parameters);
}
public Data getData() {
......
......@@ -89,7 +89,7 @@ public class TestA2CNES {
classification.setAdvancedParameters(degradation, classRatio, solutionType, kIntern,
kExtern, unificationType, criterion, constraintsWgt);
ClassificationWeights weights = new GlobalWeights(dataTrain);
ClassificationWeights weights = new GlobalWeights(dataTrain.getOneDataObject());
final Vector<Thread> threadList = new Vector<Thread>();
final Vector<Classification> classifList = new Vector<Classification>();
......
......@@ -94,7 +94,7 @@ public class TestA2CNESIterative {
classification.setAdvancedParameters(degradation, classRatio, solutionType, kIntern,
kExtern, unificationType, criterion, constraintsWgt);
ClassificationWeights weights = new GlobalWeights(dataTest);
ClassificationWeights weights = new GlobalWeights(dataTest.getOneDataObject());
final Vector<Thread> threadList = new Vector<Thread>();
final Vector<Classification> classifList = new Vector<Classification>();
......