Commit 409682f0 authored by lafabregue's avatar lafabregue

Add agent constrained samarah

parent bae79103
No preview for this file type
......@@ -1012,7 +1012,9 @@ public class ConstraintsSelectionFrame extends JFrame implements ImageAddOn {
}
public void refresh() {
container.updateUI();
if (container != null) {
container.updateUI();
}
imageDisplayer.refresh(false);
}
......
......@@ -74,90 +74,90 @@ public class ImageResultPanel extends ResultPanel implements TreeSelectionListen
private MultiResolutionClusterMap clusterMap = null;
protected File currentDirectory = null;
protected File currentDirectory = null;
/** Coordinates of the current position of the top left corner
* of the screen image in the original image */
private Point currentTopLeft = new Point(0,0);
private Point currentTopLeft = new Point(0,0);
/** l'image contenant les donnees d'origine */
private BufferedImage data;
private BufferedImage data;
/** l'image contenant les donnees d'origine */
protected BufferedImage data_zoomed;
protected BufferedImage data_zoomed;
/** panel that displays the image */
protected ZoomBoxPanel displayPanel = null;
protected ZoomBoxPanel displayPanel = null;
/** the list of add on that the displayer has subscribed to */
private Vector<ImageAddOn> imageAddOns = new Vector<ImageAddOn>();
private Vector<ImageAddOn> imageAddOns = new Vector<ImageAddOn>();
/** the parent session */
private ImageManager imageManager = null;
private ImageManager imageManager = null;
private ImageData imgData;
private ImageData imgData;
protected JInternalFrame jif_saveResult = new JInternalFrame();
protected JInternalFrame jif_saveResult = new JInternalFrame();
protected JLayeredPane lpane = new JLayeredPane();
protected JLayeredPane lpane = new JLayeredPane();
/** width of the screen image */
private int lastWidth = 0;
private int lastWidth = 0;
/** height of the screen image */
private int lastHeight = 0;
private int lastHeight = 0;
protected int[] map = null;
protected int[] map = null;
/** classification */
// protected Classification classification;
/** image initiale */
/** record the position of the mouse when it has been pressed */
private Point mousePressedCoordinates = null;
private Point mousePressedCoordinates = null;
// protected RawImage mRawImage;
// protected RawImage mRawImage;
/** zoom level */
protected double mZoomRate = 1.0f;
protected double mZoomRate = 1.0f;
/** zoom step */
private double mZoomStep = 0.7f;
private double mZoomStep = 0.7f;
// clusters' opacity
// up to 0 - 1
private float opacity = 1;
private float opacity = 1;
private float opacityCluster = 1;
private float opacityCluster = 1;
/** */
protected JPanel panelResSave = new JPanel();
protected JPanel panelResSave = new JPanel();
/** offset between the panel and the actual displayed image */
private Point screenOffset = new Point(0,0);
private Point screenOffset = new Point(0,0);
protected ClusteringResult result;
protected ClusteringResult result;
protected boolean[] resultSave = null;
protected boolean[] resultSave = null;
private ROIImage roi = null;
private ROIImage roi = null;
protected int rx = 0;
protected int rx = 0;
protected int ry = 0;
protected int ry = 0;
private float scaleFactor = 1.0f;
private float scaleFactor = 1.0f;
/** */
protected JToolBar tools = new JToolBar();
protected JToolBar tools = new JToolBar();
protected JButton vectorise = new JButton("Segmentation");
protected JButton vectorise = new JButton("Segmentation");
/** the viewer that allows to reader the image */
private ImageViewer viewer = null;
private ClusteringImageViewer viewer = null;
/** */
protected BufferedImage zoomed;
protected BufferedImage zoomed = null;
/**
*
......@@ -1692,8 +1692,14 @@ public class ImageResultPanel extends ResultPanel implements TreeSelectionListen
@Override
public BufferedImage getBirdViewImage(double zoomFactor) {
// we want the original image in the birdview so we hide every clusters
viewer.disableClustersDisplay();
BufferedImage result = viewer.getScreenImage(0, 0, (int) (viewer.getRealImageWidth()*zoomFactor),
(int) (viewer.getRealImageHeight()*zoomFactor), zoomFactor, false);
viewer.enableClustersDisplay();
return result;
}
......
......@@ -1894,6 +1894,10 @@ public class ClassifierPanel extends JPanel {
*/
public void updateParams(final int m, final boolean isImport) {
String[] method = ClassifierUtils.METHODS.get(new Integer(m));
if (isImport) {
method = ClassifierUtils.METHODS.get(new Integer(m+1000));
}
System.out.println("method : "+m);
this.paramsPanel.removeAll();
this.paramsPanel.setLayout(this.paramsGridLayout);
this.paramsGridLayout.setRows(method.length / 2);
......
package mustic.models.gui.panels;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.lang.management.ManagementFactory;
import java.util.*;
......@@ -485,7 +487,11 @@ public class HybridClassificationMonitor extends JPanel implements Observer {
/** le panel pour l'affichage de la tendance */
private JPanel trendPanel = new JPanel();
private MyTableCellRenderer historyTableCellRenderer;
/** Button to ask the classification to stop */
private JButton stopButton = new JButton("Stop Classification");
/**
* <p>
......@@ -547,13 +553,24 @@ public class HybridClassificationMonitor extends JPanel implements Observer {
trendPanel.add(Box.createHorizontalGlue());
trendPanel.add(conflictsLabel);
trendPanel.add(Box.createHorizontalGlue());
stopButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
HybridClassificationMonitor.this.classification.stopLearning();
}
});
JPanel southPane = new JPanel(new BorderLayout());
southPane.add(trendPanel, BorderLayout.CENTER);
southPane.add(stopButton, BorderLayout.SOUTH);
// creation du panel contenant les operateurs
JPanel operationsPanel = new JPanel(new GridLayout(2, 1, 10, 10));
operationsPanel.setBorder(BorderFactory.createTitledBorder("Evaluation"));
updateTrendPanel(0, -1);
JPanel jp = new JPanel(new BorderLayout());
jp.add(trendPanel, BorderLayout.SOUTH);
jp.add(southPane, BorderLayout.SOUTH);
jp.add(Box.createVerticalGlue(), BorderLayout.CENTER);
jp.add(historyTablePanel, BorderLayout.NORTH);
// jp.add(operationsPanel, BorderLayout.SOUTH);
......
......@@ -8,11 +8,13 @@ import mustic.io.RawImage;
public class ClusteringImageViewer extends ImageViewer {
private ImageViewer sourceViewer = null;
private ImageViewer sourceViewer = null;
private MultiResolutionClusterMap clusterMap = null;
private MultiResolutionClusterMap clusterMap = null;
private BufferedImage screenImage = null;
private BufferedImage screenImage = null;
private boolean clusterDisplayed = true;
public ClusteringImageViewer(ImageViewer sourceViewer, MultiResolutionClusterMap clusterMap) {
this.sourceViewer = sourceViewer;
......@@ -41,7 +43,7 @@ public class ClusteringImageViewer extends ImageViewer {
public BufferedImage getScreenImage(int x, int y, int width, int height, double zoomRate, boolean saved) {
BufferedImage buffer = sourceViewer.getScreenImage(x, y, width, height, zoomRate, saved);
if (buffer != null) {
if (buffer != null && clusterDisplayed) {
for (int i = 0 ; i < buffer.getWidth(); i++) {
for (int j = 0 ; j < buffer.getHeight() ; j++) {
Color c = clusterMap.getClusterColor(((int) (x*zoomRate))+i, ((int) (y*zoomRate))+j, zoomRate);
......@@ -162,5 +164,13 @@ public class ClusteringImageViewer extends ImageViewer {
public void adjustTransparency(float t1, float t2) {
sourceViewer.adjustTransparency(t1, t2);
}
public void enableClustersDisplay() {
clusterDisplayed = true;
}
public void disableClustersDisplay() {
clusterDisplayed = false;
}
}
package mustic.utils.transform;
import java.awt.Color;
import java.awt.Point;
import java.awt.image.BufferedImage;
import java.util.ArrayList;
import java.util.List;
import java.util.Vector;
......@@ -17,6 +19,7 @@ import jcl.data.distance.NumericalEuclideanDistance;
import jsl.Segmentation;
import jsl.io.Descripteur;
import jsl.io.ObjetImage;
import jsl.regionalisation.caracterisation.Caracterize;
/**
* <p>
......@@ -28,7 +31,7 @@ import jsl.io.ObjetImage;
* @author uberall
*
*/
public class RegionDataBuilder {
public class RegionDataBuilder extends SimpleData {
/** Les donnees construites a partir de tous les attributs */
private Data data;
......@@ -52,6 +55,36 @@ public class RegionDataBuilder {
names[i] = d.getNom();
}
int w = s.getImageInitiale().getXDim();
int h = s.getImageInitiale().getYDim();
int x;
int y;
int[] mapS = new int[w * h];
for (ObjetImage oi : s.getResultat().getObjectsImage()) {
int cB1 = (int) Double.parseDouble(oi.getObjetDescripteur(Caracterize.SIGNB1).getValeur());
int cB2 = (int) Double.parseDouble(oi.getObjetDescripteur(Caracterize.SIGNB2).getValeur());
int cB3 = (int) Double.parseDouble(oi.getObjetDescripteur(Caracterize.SIGNB3).getValeur());
Color c;
c = new Color(cB1, cB2, cB3);
// c= new Color(255-cB1, 255-cB2, 255-cB3);
for (Point p : oi.getPixels())
mapS[p.x + p.y * w] = c.hashCode();
}
BufferedImage imageSegmentee = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
for (int i = 0; i < w * h; i++) {
x = (i % w);
y = (i / w);
if (x >= 0 && x < w) {
if (y >= 0 && y < h) {
imageSegmentee.setRGB(x, y, mapS[i]);
}
}
}
// on cree les donnees
List<DataObject> allObjects = new ArrayList<DataObject>(s.getResultat().getNombreRegions());
DataObject current;
......
......@@ -41,6 +41,8 @@ import mustic.models.thread.ClassificationThread;
import mustic.utils.io.CSVUtils;
public class TestA2CNES {
public void customClassify() {
HybridClassification classification = new HybridClassification();
......@@ -53,7 +55,6 @@ public class TestA2CNES {
Data dataTrain = getDataFromFile(dataPath+datasetPath+"/train/"+datasetName+".data", '\t', "train", null);
Data dataTest = getDataFromFile(dataPath+datasetPath+"/test/"+datasetName+".data", '\t', "test", null);
// AttributeMultiDimSequence.setMode(AttributeMultiDimSequence.EUCLIDIEN);
AttributeMultiDimSequence.setMode(AttributeMultiDimSequence.DTW_BARYCENTRE);
......
......@@ -52,8 +52,8 @@ public class TestA2CNESIterative {
final String datasetName = "FacesUCR";
final String datasetPath = "FacesUCR";
final String dataPath = "~/A2CNES/";
final String resultPath = "~/A2CNES/results_iter/";
final String dataPath = System.getProperty("user.home") + "/A2CNES/";
final String resultPath = System.getProperty("user.home") + "/A2CNES/results_iter/";
final int nInf = 12;
final int nSup = 17;
final int ag1_seeds = 16;
......
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