Commit 548ff38d authored by lafabregue's avatar lafabregue
Browse files

first released version v6.0

parents
temporary/*
*.class
# eclipse specific git ignore
*.pydevproject
.project
.metadata
bin/**
tmp/**
tmp/**/*
*.tmp
*.bak
*.swp
*~.nib
local.properties
.classpath
.settings/
.loadpath
*.hprof
File added
12
\ No newline at end of file
12
\ No newline at end of file
package mustic.models.gui.panels;
//t
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JSlider;
import javax.swing.JTextField;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import jcl.Classification;
import jcl.data.Data;
import mustic.models.gui.charts.ScatterPlotChart;
/**
* <p>
* Permet d'affiche un nuage de point qui represente les donnees.
* </p>
*
* @author Germain FORESTIER
*/
public class ScatterPlotPanel extends JPanel {
/** serialVersionUID */
private static final long serialVersionUID = 1L;
/** Attribut des X */
JComboBox bandxCombo = new JComboBox();
/** Attribut des Y */
JComboBox bandyCombo = new JComboBox();
/** Les donnees * */
private Data data;
/** Le nuage de point */
ScatterPlotChart dataChart;
/** Variation du nombre d'objets a afficher */
JSlider nbpixelSlider = new JSlider();
/** Nombre d'objets a afficher */
JTextField nbpixelTextField = new JTextField();
/** Choix des pixels aleatoire ? */
JCheckBox randomCombo = new JCheckBox(" Random choice");
int test;
/**
* <p>
* Construteur de base.
* </p>
*
* @param data
* les donnees
* @param classification
* la classification
*/
public ScatterPlotPanel(Data data, Classification classification) {
this.data = data;
JLabel nbpixelLabel = new JLabel("Number of object");
JLabel bandxLabel = new JLabel("Object for x");
JLabel bandyLabel = new JLabel("Object for y");
JButton applyButton = new JButton("Apply");
JPanel centerPanel = new JPanel();
centerPanel.setLayout(new GridBagLayout());
setLayout(new BorderLayout());
this.randomCombo.setSelected(true);
this.randomCombo
.setToolTipText("select random objets or select only the first objects");
centerPanel.setMaximumSize(new Dimension(250, 250));
centerPanel.setMinimumSize(new Dimension(250, 250));
centerPanel.setPreferredSize(new Dimension(130, 250));
centerPanel.add(bandxLabel, new GridBagConstraints(0, 0, 1, 1, 0.0,
0.0, GridBagConstraints.WEST, GridBagConstraints.NONE,
new Insets(42, 23, 0, 7), 11, 0));
centerPanel.add(this.bandxCombo, new GridBagConstraints(0, 1, 1, 1,
1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE,
new Insets(8, 20, 0, 16), 47, 0));
centerPanel.add(this.bandyCombo, new GridBagConstraints(0, 3, 1, 1,
1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE,
new Insets(8, 20, 0, 16), 47, 0));
centerPanel.add(bandyLabel, new GridBagConstraints(0, 2, 1, 1, 0.0,
0.0, GridBagConstraints.WEST, GridBagConstraints.NONE,
new Insets(19, 23, 0, 9), 8, 0));
centerPanel.add(this.randomCombo, new GridBagConstraints(0, 7, 1, 1,
0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE,
new Insets(7, 7, 0, 0), 0, 0));
centerPanel
.add(this.nbpixelTextField, new GridBagConstraints(0, 6, 1, 1,
1.0, 0.0, GridBagConstraints.WEST,
GridBagConstraints.HORIZONTAL,
new Insets(9, 23, 0, 17), 61, 0));
centerPanel.add(this.nbpixelSlider, new GridBagConstraints(0, 5, 1, 1,
0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
new Insets(6, 7, 0, 0), -100, 0));
centerPanel.add(nbpixelLabel, new GridBagConstraints(0, 4, 1, 1, 0.0,
0.0, GridBagConstraints.WEST, GridBagConstraints.NONE,
new Insets(22, 17, 0, 7), 0, 0));
centerPanel.add(applyButton, new GridBagConstraints(0, 8, 1, 1, 0.0,
0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE,
new Insets(11, 22, 9, 16), 0, 0));
for (int i = 0; i < data.getDataObject(0).getNbAttributes(); i++) {
if (classification == null
|| (classification.getClusteringResult().getWeights(0)
.getWeight(i)) != 0) {
this.bandxCombo.addItem(data.getAttributeName(i));
this.bandyCombo.addItem(data.getAttributeName(i));
}
}
this.dataChart = new ScatterPlotChart(data, classification);
add(centerPanel, BorderLayout.WEST);
add(this.dataChart, BorderLayout.CENTER);
int max = data.getNbObjects();
this.nbpixelSlider.setMaximum(max);
max = max >= 1000 ? 1000 : max;
this.nbpixelSlider.setValue(max);
this.nbpixelTextField.setText(max + "");
/* Applique les modifications */
applyButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
refreshChart();
}
});
/* Change l'attribut a afficher pour les X */
this.bandxCombo.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
refreshChart();
}
});
/* Change l'attribut a afficher pour les Y */
this.bandyCombo.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
refreshChart();
}
});
/* Change le nombre de pixels a afficher */
this.nbpixelSlider.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
ScatterPlotPanel.this.nbpixelTextField.setText(Integer
.toString(ScatterPlotPanel.this.nbpixelSlider
.getValue()));
}
});
}
/**
* <p>
* Met a jour le chart.
* </p>
*/
private void refreshChart() {
// necessaire car, si on a des poids nuls d'attributs l'indice n'est
// plus le bon car il n'est plus dans la liste !
int xIndex = this.data.getAttributeIndex((String) this.bandxCombo
.getSelectedItem());
int yIndex = this.data.getAttributeIndex((String) this.bandyCombo
.getSelectedItem());
try {
// dataChart.refresh(bandxCombo.getSelectedIndex(),
// bandyCombo.getSelectedIndex(),
// Integer.parseInt(nbpixelTextField.getText()),
// randomCombo.isSelected());
this.dataChart.refresh(xIndex, yIndex,
Integer.parseInt(this.nbpixelTextField.getText()),
this.randomCombo.isSelected());
} catch (Exception e) {
e.printStackTrace();
System.exit(1);
}
}
/**
* <p>
* Met a jour le chart avec les dernieres valeurs selectionnees.
* </p>
*/
public void updateChart() {
this.dataChart.updateChart();
}
}
package mustic.utils.transform;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Calendar;
import java.util.Date;
import otbAppWrapping.InfoImage;
import otbAppWrapping.OtbImage;
/**
* Classe utilise pour Transforme un fichier .bmp (Verite Terrain - Ground
* Truth) en fichier ROI
*
* @author grigore
*
*/
public class TransformVeriteTerrainEnRoi {
final static String COMMENT_CHAR = ";";
final static String ROI_COLOR = "; ROI rgb value: ";
final static String ROI_DIMENSION = "; File Dimension: ";
final static String ROI_FILENAME = "; File : ";
final static String ROI_NAME = "; ROI name: ";
final static String ROI_NBPTS = "; ROI npts: ";
final static String ROI_OFFSET_X = "; Offset x: ";
final static String ROI_OFFSET_Y = "; Offset y: ";
public static String getDate() {
Calendar c = Calendar.getInstance();
c.setTime(new Date());
return c.get(Calendar.DAY_OF_MONTH) + "/" + (c.get(Calendar.MONTH) + 1)
+ "/" + c.get(Calendar.YEAR);
}
/**
*
*
* Methode qui genere le fichier ROI a partir d'une IMAGE .bmp VeriteTerrain
*
*
* @param inputfile
* le path du INPUTFILE
* @param path
* le path du repertoire pour le fichier roi
* @param outFilename
* le path complete avec le nom de fichier
* @param fond
* la couleur du fond (Pour le moment 0 = blanche 1 = noir )
* @throws IOException
*/
public static void transform(String inputfile, String path,
String outFilename, int fond) throws IOException {
// TODO Auto-generated method stub
int value;
switch (fond) {
case 0:
value = 255;
break;
case 1:
value = 0;
break;
default:
value = -1;
break;
}
String file = inputfile;
InfoImage info=new InfoImage(file);
long sizeX = info.getSizeX();
long sizeY = info.getSizeY();
System.out.println("nameImage:" + info.getFilename()
+ "\nimage SIZE x:" + sizeX + "\nimage SIZE y:" + sizeY
+ "\nTotalPixels:" + (sizeY * sizeX));
double imageMatrice[][][]=null;
try {
imageMatrice = new OtbImage().loadImage(file, info.getSizeX(), info.getSizeY(), info.getNumberOfBands());
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println("TransformToRoiDialog");
System.out.println(fond);
System.out.println(inputfile);
System.out.println(path);
System.out.println(outFilename);
System.out.println("Pixel Value pour trouver : " + value);
FileWriter fw;
BufferedWriter bf;
PrintWriter pw;
fw = new FileWriter(path + "temp.roi");
bf = new BufferedWriter(fw);
pw = new PrintWriter(bf);
pw.println("; ENVI Output of ROIs");
pw.println("; Description: generated by ModuleIHM Trie par classe, map info de "
+ file + ", date: " + getDate());
pw.println("; Number of ROIs: 1");
pw.println("; File Dimension: " + sizeX + " x " + sizeY);
pw.println(ROI_FILENAME + file);
pw.println(ROI_OFFSET_X + "0");
pw.println(ROI_OFFSET_Y + "0");
pw.println("");
pw.println(ROI_NAME + "crevasse");
pw.println(ROI_COLOR + "{255, 0, 0}");
pw.println(ROI_NBPTS + "");
pw.println("");
pw.println("; Col: ID X Y Class");
int w = 0;
for (int j = 0; j < sizeY; j++) {
for (int i = 0; i < sizeX; i++) {
if (imageMatrice[0][i][j] == value) {
w++;
// longString +=w+" "+i+" "+j+" "+"Noir";
pw.println(w + " " + i + " " + j + " " + "crevasse");
// break;
}
// vec.delete();
//
}
// System.out.println(j);
// start = new itkIndex2();
//
}
// pw.println(longString);
/* Impression des coordonnees */
// v = image.GetPixel(start);
pw.close();
fw = new FileWriter(outFilename);
bf = new BufferedWriter(fw);
pw = new PrintWriter(bf);
FileReader fr = new FileReader(path + "temp.roi");
BufferedReader br = new BufferedReader(fr);
String line = br.readLine();
while ((line = br.readLine()) != null) {
// bf.write(line);
if (line.startsWith(ROI_NBPTS))
pw.println(line + w);
else
pw.println(line);
}
br.close();
fr.close();
File f = new File(path + "temp.roi");
f.delete();
bf.close();
fw.close();
}
}
AgentDialog.0=Annuler
AgentDialog.1=OK
AgentDialog.10=Erreur
AgentDialog.2=Contructeur AgentDialog peut crer ou instancier la ClassifierPanel(null, null, true).
AgentDialog.3=initialization dialogue ok
AgentDialog.4=Classifieur
AgentDialog.5=OK
AgentDialog.6=Annuler
AgentDialog.7=K-means
AgentDialog.8=Everything is OK to classify multi-d
AgentDialog.9=Selectinnez les donnes
AttributeSelectionDialog.0=Poids de la bande
AttributeSelectionDialog.2=ponderation de la bande
AttributeSelectionDialog.3=OK
AttributeSelectionDialog.4=Annuler
ClassifierDialog.0=OK
ClassifierDialog.1=Classifieur
ClassifierDialog.2=OK
ClassifierDialog.3=Selectinez les donnes
ClassifierDialog.4=Erreur
KMeansSeedSelectionDialog.0=Information
KMeansSeedSelectionDialog.15=pixel
KMeansSeedSelectionDialog.21=Appliquer
KMeansSeedSelectionDialog.22=Effacer
KMeansSeedSelectionDialog.29=Niveau de zoom est son minimum...
KMeansSeedSelectionDialog.5=OK
KMeansSeedSelectionDialog.7=Image
KMeansSeedSelectionDialog.8=K-moyens graines
<html>
<head>
<meta name="author" content="WEMMERT C&eacute;dric" >
<title>Appliquer un masque &agrave; une image</title>
<link rel=stylesheet type="text/css" href="../style.css">
</head>
<body>
<h1>Appliquer un masque &agrave; une image</h1>
<h2>Principe du masque</h2>
<p>Le principe du masque consiste &agrave; prendre une image binaire de m&ecirc;me taille que l'image &agrave; classifier. Les pixels dans l'image &agrave; classifier ayant une valeur &eacute;gale &agrave; <b>1</b> dans l'image du masque ne seront pas trait&eacute;s dans les algorithmes de classification. Ce qui revient &agrave; supprimer ces pixels des donn&eacute;es &agrave; classifier.</p>
<h2>Appliquer un masque &agrave; une image</h2>
<p>Pour appliquer un masque &agrave; une image, il est n&eacute;cessaire d'ouvrir une image par l'interm&eacute;diaire du menu <b>File</b> de la fen&ecirc;tre principale du logiciel puis de cliquer sur <b>Open...</b>.</p>
<p>Ensuite, rendez-vous dans le menu <b>Tools</b> de la fen&ecirc;tre principale du logiciel puis cliquez sur <b>Apply mask...</b>. Une fen&ecirc;tre appara&icirc;t alors, vous permettant de choisir l'image &agrave; appliquer comme masque.</p>
</body>
</html>
package mustic.models.gui.database.connection;
import java.awt.Frame;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
import javax.swing.JOptionPane;
import mustic.models.gui.database.DistantFile;
import mustic.models.gui.dialogs.database.SaisieDialog;
import mustic.models.utils.database.ScpReader;
import ch.ethz.ssh2.Connection;
import ch.ethz.ssh2.InteractiveCallback;
import ch.ethz.ssh2.KnownHosts;
import ch.ethz.ssh2.ServerHostKeyVerifier;
/**
* Ouvre une connection vers un serveur SSH et renvoi un flux
*/
public class SSHConnection extends GenericConnection {
/**
* Verifieur pour le certificat renvoye par le serveur lors de la connection
*/
class AdvancedVerifier implements ServerHostKeyVerifier {
int choix;
String message;
public AdvancedVerifier() {
}
@Override
public boolean verifyServerHostKey(String hostname, int port,
String serverHostKeyAlgorithm, byte[] serverHostKey)
throws Exception {
final String host = hostname;
final String algo = serverHostKeyAlgorithm;
/*
* Verifie si le certificat existe deja dans la base de donnees
*/
int result = SSHConnection.this.database.verifyHostkey(hostname,
serverHostKeyAlgorithm, serverHostKey);
switch (result) {
case KnownHosts.HOSTKEY_IS_OK: // Oui
return true;
case KnownHosts.HOSTKEY_IS_NEW: // Non, et c'est un nouveau
this.message = "Do you want to accept the hostkey (type "
+ algo + ") from " + host + " ?\n";
break;
case KnownHosts.HOSTKEY_HAS_CHANGED: // Oui, mais il a change
this.message = "WARNING! Hostkey for " + host
+ " has changed!\nAccept anyway?\n";
break;
default:
throw new IllegalStateException();
}
/*
* Genere l'emprunt du certificat pour le montrer a l'utilisateur
*/
String hexFingerprint = KnownHosts.createHexFingerprint(
serverHostKeyAlgorithm, serverHostKey);
String bubblebabbleFingerprint = KnownHosts
.createBubblebabbleFingerprint(serverHostKeyAlgorithm,
serverHostKey);
this.message += "Hex Fingerprint: " + hexFingerprint
+ "\nBubblebabble Fingerprint: " + bubblebabbleFingerprint;
// TODO ATTENTION : desactive pour que ca fonctionne sous windows
// !!!
// /*
// * Demande a l'utilisateur si il accepte ce certificat
// */
// SwingUtilities.invokeAndWait(
// new Runnable(){
// public void run(){
//
// AdvancedVerifier.this.choix =
// JOptionPane.showConfirmDialog(SSHConnection.this.parent,
// AdvancedVerifier.this.message);
// }
// }
// );
if (this.choix == JOptionPane.YES_OPTION) {
/*
* ajoute le certificat dans la base memoire
*/
String hashedHostname = KnownHosts
.createHashedHostname(hostname);
SSHConnection.this.database.addHostkey(
new String[] { hashedHostname },
serverHostKeyAlgorithm, serverHostKey);
/*
* Essai aussi de l'ajoute dans le fichier des hotes connus
*/
try {
KnownHosts.addHostkeyToFile(new File(
SSHConnection.knownHostPath),
new String[] { hashedHostname },
serverHostKeyAlgorithm, serverHostKey);