Commit 704cea5d authored by lafabregue's avatar lafabregue

allow channel index modification for rgb color

parent 1e2ec39f
......@@ -27,6 +27,10 @@ import javax.swing.border.EmptyBorder;
import javax.swing.event.*;
import javax.swing.tree.*;
import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;
import jcl.Classification;
import jcl.clustering.Cluster;
import jcl.clustering.ClusteringResult;
......@@ -343,7 +347,8 @@ public class MainFrame extends JFrame {
if (this.currentImageSession == null)
return;
RgbBandChooserInternalFrame rgbBandChooserInternalFrame = new RgbBandChooserInternalFrame(currentImageSession);
RgbBandChooserInternalFrame rgbBandChooserInternalFrame = new RgbBandChooserInternalFrame
(currentImageSession.getRawImage());
this.desktop.add(rgbBandChooserInternalFrame);
this.desktop.setSelectedFrame(rgbBandChooserInternalFrame);
rgbBandChooserInternalFrame.toFront();
......@@ -3713,7 +3718,7 @@ public class MainFrame extends JFrame {
private void customClassify() {
HybridClassification classification = new HybridClassification();
String datasetName = "StarLightCurves";
String datasetName = "ECML";
String dataPath = "/home/baptiste/A2CNES/";
String resultPath = "/home/baptiste/A2CNES/results/";
String testResultPath = "/home/baptiste/A2CNES/Train_results/";
......@@ -3723,6 +3728,7 @@ public class MainFrame extends JFrame {
DataDesktopFrame[] desktopFrames = MainFrame.getInstance().getDesktop().getAllDataDesktopFrames();
DataSession testSession = desktopFrames[desktopFrames.length-1].getDataSession();
final DateTime startTime = DateTime.now();
int nInf = 3;
int nSup = 5;
......@@ -3736,7 +3742,7 @@ public class MainFrame extends JFrame {
// parametre qualite/similitude
double ps = 0.2;
double pq = 1.0 - ps;
double constraintsWgt = 85;
double constraintsWgt = 0;
double valueKExtern = 60;
double kExtern = valueKExtern * ((100-constraintsWgt)/100);
double kIntern = (100 - valueKExtern) * ((100-constraintsWgt)/100);
......@@ -3757,14 +3763,14 @@ public class MainFrame extends JFrame {
final Vector<Classification> classifList = new Vector<Classification>();
// we search for all constraints files
//// <<<< START FOR PARAM config
// <<<< START FOR PARAM config
// for (int i = 0 ; i < 6 ; i++) {
// HybridClassification classif = (HybridClassification) classification.clone();
// if (i % 2 == 1 ) {
// classification.setParameters(nInf, nSup, minC, 0.4, 0.6, pcr);
// }
// if (i <= 4)
// classif.addAgent(new ParametersKmeans(11, 10, weights), dataTrain);
// classif.addAgent(new ParametersKmeans(10, 10, weights), dataTrain);
// classif.addAgent(new ParametersKmeans(13, 10, weights), dataTrain);
// classif.addAgent(new ParametersKmeans(16, 10, weights), dataTrain);
// if (i >= 2)
......@@ -3776,120 +3782,121 @@ public class MainFrame extends JFrame {
// classif.setName(testResultPath+datasetName+"/clusteing"+i);
// classif.setData(dataTrain);
//// >>>> END FOR PARAM config1
// for (int i = 0 ; i < 10 ; i++) {
// HybridClassification classif = (HybridClassification) classification.clone();
// classif.addAgent(new ParametersKmeans(4, 15, weights), dataTest);
// classif.addAgent(new ParametersKmeans(6, 15, weights), dataTest);
// classif.addAgent(new ParametersKmeans(8, 15, weights), dataTest);
//
// classif.setName(resultPath+datasetName+"/clustering"+i);
// classif.setData(dataTest);
for (int i = 0 ; i < 5 ; i++) {
HybridClassification classif = (HybridClassification) classification.clone();
classif.addAgent(new ParametersKmeans(10, 15, weights), dataTest);
classif.addAgent(new ParametersKmeans(13, 15, weights), dataTest);
classif.addAgent(new ParametersKmeans(16, 15, weights), dataTest);
classif.addAgent(new ParametersKmeans(19, 15, weights), dataTest);
classif.setName(resultPath+datasetName+"/clustering"+i);
classif.setData(dataTest);
//// >>>> REPLACE PARAM
// Thread t = null;
//
// ClassificationImage classificationImage = new ClassificationImage(dataTest,
// Messages.getString("ClassifierPanel.73") + DataSession.nbClustering, //$NON-NLS-1$
// true);
//
//
// t = new ClassificationThread(classif, classificationImage.getProgressBar(),
// classificationImage, null);
// t.start();
// try {
// testSession.associatedFrame.setMaximum(true);
// } catch (PropertyVetoException e1) {}
// testSession.addClassifier(classificationImage);
// try {
// testSession.associatedFrame.setSelected(true);
// testSession.associatedFrame.toFront();
// } catch (PropertyVetoException e) {
// e.printStackTrace();
// }
// classificationImage.toFront();
// classificationImage.setVisible(true);
//
// threadList.add(t);
// classifList.add(classif);
// }
// <<<< CONSTRAINTS
try (DirectoryStream<Path> dirStream = Files.newDirectoryStream(
Paths.get(dataPath+datasetName+"/test/"), "*constraints")) {
Iterator<Path> iter = dirStream.iterator();
while(iter.hasNext()) {
Vector<Constraint> constraints = new Vector<Constraint>();
String filename = iter.next().getFileName().toString();
System.out.println(filename);
CSVUtils reader = null;
try {
reader = new CSVUtils(new File(dataPath+datasetName+"/test/"+filename), '\t');
List<String> line;
while((line = reader.readNext()) != null) {
switch (Integer.parseInt(line.get(line.size()-1))) {
case Constraint.MUST_LINK_TYPE :
try {
int index1 = Integer.parseInt(line.get(0))-1;
int index2 = Integer.parseInt(line.get(1))-1;
constraints.add(new MustLinkConstraint(index1, index2));
} catch(Exception e) {
e.printStackTrace();
}
break;
case Constraint.CANNOT_LINK_TYPE :
try {
int index1 = Integer.parseInt(line.get(0))-1;
int index2 = Integer.parseInt(line.get(1))-1;
constraints.add(new CannotLinkConstraint(index1, index2));
} catch(Exception e) {
e.printStackTrace();
}
break;
}
}
} catch (FileNotFoundException e) {
e.printStackTrace();
}
HybridClassification classif = (HybridClassification) classification.clone();
Data currentData = (Data) dataTest.clone();
currentData.updateAndSetConstraintsToSample(constraints);
classif.addAgent(new ParametersKmeans(4, 15, weights), currentData);
classif.addAgent(new ParametersKmeans(6, 15, weights), currentData);
classif.addAgent(new ParametersKmeans(8, 15, weights), currentData);
classif.setName(resultPath+datasetName+"/"+
ImageHelper.stripExtension(filename)+
".clustering");
classif.setData(dataTest);
Thread t = null;
ClassificationImage classificationImage = new ClassificationImage(currentData,
Messages.getString("ClassifierPanel.73") + DataSession.nbClustering, //$NON-NLS-1$
true);
t = new ClassificationThread(classif, classificationImage.getProgressBar(),
classificationImage, null);
t.start();
try {
testSession.associatedFrame.setMaximum(true);
} catch (PropertyVetoException e1) {}
testSession.addClassifier(classificationImage);
try {
testSession.associatedFrame.setSelected(true);
testSession.associatedFrame.toFront();
} catch (PropertyVetoException e) {
e.printStackTrace();
}
classificationImage.toFront();
classificationImage.setVisible(true);
threadList.add(t);
classifList.add(classif);
}
} catch (IOException e2) {
e2.printStackTrace();
Thread t = null;
ClassificationImage classificationImage = new ClassificationImage(dataTest,
Messages.getString("ClassifierPanel.73") + DataSession.nbClustering, //$NON-NLS-1$
true);
t = new ClassificationThread(classif, classificationImage.getProgressBar(),
classificationImage, null);
t.start();
try {
testSession.associatedFrame.setMaximum(true);
} catch (PropertyVetoException e1) {}
testSession.addClassifier(classificationImage);
try {
testSession.associatedFrame.setSelected(true);
testSession.associatedFrame.toFront();
} catch (PropertyVetoException e) {
e.printStackTrace();
}
classificationImage.toFront();
classificationImage.setVisible(true);
threadList.add(t);
classifList.add(classif);
}
// <<<< CONSTRAINTS
// try (DirectoryStream<Path> dirStream = Files.newDirectoryStream(
// Paths.get(dataPath+datasetName+"/test/"), "*constraints")) {
// Iterator<Path> iter = dirStream.iterator();
// while(iter.hasNext()) {
// Vector<Constraint> constraints = new Vector<Constraint>();
// String filename = iter.next().getFileName().toString();
// System.out.println(filename);
// CSVUtils reader = null;
// try {
// reader = new CSVUtils(new File(dataPath+datasetName+"/test/"+filename), '\t');
// List<String> line;
// while((line = reader.readNext()) != null) {
// switch (Integer.parseInt(line.get(line.size()-1))) {
// case Constraint.MUST_LINK_TYPE :
// try {
// int index1 = Integer.parseInt(line.get(0))-1;
// int index2 = Integer.parseInt(line.get(1))-1;
// constraints.add(new MustLinkConstraint(index1, index2));
// } catch(Exception e) {
// e.printStackTrace();
// }
// break;
// case Constraint.CANNOT_LINK_TYPE :
// try {
// int index1 = Integer.parseInt(line.get(0))-1;
// int index2 = Integer.parseInt(line.get(1))-1;
// constraints.add(new CannotLinkConstraint(index1, index2));
// } catch(Exception e) {
// e.printStackTrace();
// }
// break;
// }
// }
// } catch (FileNotFoundException e) {
// e.printStackTrace();
// }
// HybridClassification classif = (HybridClassification) classification.clone();
// Data currentData = (Data) dataTest.clone();
// currentData.updateAndSetConstraintsToSample(constraints);
//
// classif.addAgent(new ParametersKmeans(4, 15, weights), currentData);
// classif.addAgent(new ParametersKmeans(6, 15, weights), currentData);
// classif.addAgent(new ParametersKmeans(8, 15, weights), currentData);
//
// classif.setName(resultPath+datasetName+"/"+
// ImageHelper.stripExtension(filename)+
// ".clustering");
// classif.setData(dataTest);
//
// Thread t = null;
//
// ClassificationImage classificationImage = new ClassificationImage(currentData,
// Messages.getString("ClassifierPanel.73") + DataSession.nbClustering, //$NON-NLS-1$
// true);
//
//
// t = new ClassificationThread(classif, classificationImage.getProgressBar(),
// classificationImage, null);
// t.start();
// try {
// testSession.associatedFrame.setMaximum(true);
// } catch (PropertyVetoException e1) {}
// testSession.addClassifier(classificationImage);
// try {
// testSession.associatedFrame.setSelected(true);
// testSession.associatedFrame.toFront();
// } catch (PropertyVetoException e) {
// e.printStackTrace();
// }
// classificationImage.toFront();
// classificationImage.setVisible(true);
//
// threadList.add(t);
// classifList.add(classif);
// }
// } catch (IOException e2) {
// e2.printStackTrace();
// }
// >>>> CONSTRAINTS
new Thread() {
......@@ -3909,7 +3916,9 @@ public class MainFrame extends JFrame {
e.printStackTrace();
}
}
System.out.println("wrote final results");
DateTimeFormatter formatter = DateTimeFormat.forPattern("MM/dd/yyyy HH:mm:ss");
System.out.println("Start at "+ formatter.print(startTime));
System.out.println("wrote final results at "+ formatter.print(DateTime.now()));
}
}.start();
......
......@@ -12,62 +12,89 @@ import javax.swing.JComboBox;
import javax.swing.JInternalFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.SwingConstants;
import mustic.gui.ImageSession;
import mustic.gui.MainFrame;
import mustic.io.RawImage;
public class RgbBandChooserInternalFrame extends JInternalFrame {
/** liste de choix pour la bande bleu */
private JComboBox blueComboBox;
/** liste de choix pour la bande verte */
private JComboBox greenComboBox;
/** */
private static final long serialVersionUID = 1L;
/** liste de choix pour la bande rouge */
private JComboBox rougeComboBoxr;
private JComboBox<String> redComboBox;
private JTextArea redMin;
private JTextArea redMax;
/** liste de choix si noir et blanc */
private JComboBox whiteBlackComboBox;
/** liste de choix pour la bande verte */
private JComboBox<String> greenComboBox;
private JTextArea greenMin;
private JTextArea greenMax;
/** liste de choix pour la bande bleu */
private JComboBox<String> blueComboBox;
private JTextArea blueMin;
private JTextArea blueMax;
public RgbBandChooserInternalFrame(ImageSession currentImageSession) {
/** liste de choix si noir et blanc */
private JComboBox<String> whiteBlackComboBox;
/** min/max used for scale image colors */
private double[] scaledMax;
private double[] scaledMin;
public RgbBandChooserInternalFrame(final RawImage rawImage) {
super();
this.rougeComboBoxr = new JComboBox();
this.greenComboBox = new JComboBox();
this.blueComboBox = new JComboBox();
this.whiteBlackComboBox = new JComboBox();
this.scaledMax = rawImage.getScaledMaxValues();
this.scaledMin = rawImage.getScaledMinValues();
this.redComboBox = new JComboBox<String>();
this.redMin = new JTextArea();
this.redMax = new JTextArea();
this.greenComboBox = new JComboBox<String>();
this.greenMin = new JTextArea();
this.greenMax = new JTextArea();
this.blueComboBox = new JComboBox<String>();
this.blueMin = new JTextArea();
this.blueMax = new JTextArea();
this.whiteBlackComboBox = new JComboBox<String>();
this.setTitle(Messages.getString("RgbBandChooserInternalFrame.0")); //$NON-NLS-1$
this.whiteBlackComboBox.addItem(""); //$NON-NLS-1$
int nb_band = currentImageSession.getRawImage().getNbBands();
int nb_band = rawImage.getNbBands();
for (int i = 1; i <= nb_band; i++) {
this.rougeComboBoxr.addItem(Messages.getString("RgbBandChooserInternalFrame.2") + i); //$NON-NLS-1$
this.greenComboBox.addItem(Messages.getString("RgbBandChooserInternalFrame.3") + i); //$NON-NLS-1$
this.blueComboBox.addItem(Messages.getString("RgbBandChooserInternalFrame.4") + i); //$NON-NLS-1$
this.whiteBlackComboBox.addItem(Messages.getString("RgbBandChooserInternalFrame.5") + i); //$NON-NLS-1$
this.redComboBox.addItem(Messages.getString("RgbBandChooserInternalFrame.2") + i); //$NON-NLS-1$
this.greenComboBox.addItem(Messages.getString("RgbBandChooserInternalFrame.2") + i); //$NON-NLS-1$
this.blueComboBox.addItem(Messages.getString("RgbBandChooserInternalFrame.2") + i); //$NON-NLS-1$
this.whiteBlackComboBox.addItem(Messages.getString("RgbBandChooserInternalFrame.2") + i); //$NON-NLS-1$
}
this.rougeComboBoxr.setSelectedIndex(currentImageSession
.getBirdViewPanel().getR());
this.greenComboBox.setSelectedIndex(currentImageSession
.getBirdViewPanel().getG());
this.blueComboBox.setSelectedIndex(currentImageSession
.getBirdViewPanel().getB());
this.redComboBox.setSelectedIndex(rawImage.getR());
this.redMin.setText(""+scaledMin[rawImage.getR()]);
this.redMax.setText(""+scaledMax[rawImage.getR()]);
this.greenComboBox.setSelectedIndex(rawImage.getG());
this.greenMin.setText(""+scaledMin[rawImage.getG()]);
this.greenMax.setText(""+scaledMax[rawImage.getG()]);
this.blueComboBox.setSelectedIndex(rawImage.getB());
this.blueMin.setText(""+scaledMin[rawImage.getB()]);
this.blueMax.setText(""+scaledMax[rawImage.getB()]);
this.whiteBlackComboBox.setSelectedIndex(0);
JPanel centerPanel = new JPanel(new BorderLayout());
JPanel panelColor = new JPanel(new GridLayout(3, 2));
JPanel panelColor = new JPanel(new GridLayout(3, 1));
panelColor.setBorder(BorderFactory
.createTitledBorder(Messages.getString("RgbBandChooserInternalFrame.6"))); //$NON-NLS-1$
panelColor.add(new JLabel(Messages.getString("RgbBandChooserInternalFrame.7"), SwingConstants.CENTER)); //$NON-NLS-1$
panelColor.add(this.rougeComboBoxr);
panelColor.add(new JLabel(Messages.getString("RgbBandChooserInternalFrame.8"), SwingConstants.CENTER)); //$NON-NLS-1$
panelColor.add(this.greenComboBox);
panelColor.add(new JLabel(Messages.getString("RgbBandChooserInternalFrame.9"), SwingConstants.CENTER)); //$NON-NLS-1$
panelColor.add(this.blueComboBox);
panelColor.add(createChannelPanel(redComboBox, redMin, redMax,
Messages.getString("RgbBandChooserInternalFrame.7"))); //$NON-NLS-1$
panelColor.add(createChannelPanel(greenComboBox, greenMin, greenMax,
Messages.getString("RgbBandChooserInternalFrame.8"))); //$NON-NLS-1$
panelColor.add(createChannelPanel(blueComboBox, blueMin, blueMax,
Messages.getString("RgbBandChooserInternalFrame.9"))); //$NON-NLS-1$
centerPanel.add(panelColor, BorderLayout.NORTH);
JPanel panelNG = new JPanel(new GridLayout(1, 2));
panelNG.setBorder(BorderFactory
......@@ -99,44 +126,40 @@ public class RgbBandChooserInternalFrame extends JInternalFrame {
int green;
int blue;
// avec la methode .getParent() on parcurir la hierarchie des
// elements graphiques pour ariver a la component
// RgbBandChooserInternalFrame
RgbBandChooserInternalFrame rgbBandChooserInternalFrame = (RgbBandChooserInternalFrame) (((JButton) e
.getSource()).getParent().getParent().getParent()
.getParent().getParent());
if (!rgbBandChooserInternalFrame.whiteBlackComboBox
if (!whiteBlackComboBox
.getSelectedItem().equals("")) { //$NON-NLS-1$
red = rgbBandChooserInternalFrame.whiteBlackComboBox
red = whiteBlackComboBox
.getSelectedIndex() - 1;
green = rgbBandChooserInternalFrame.whiteBlackComboBox
green = whiteBlackComboBox
.getSelectedIndex() - 1;
blue = rgbBandChooserInternalFrame.whiteBlackComboBox
blue = whiteBlackComboBox
.getSelectedIndex() - 1;
} else {
red = rgbBandChooserInternalFrame.rougeComboBoxr
.getSelectedIndex();
green = rgbBandChooserInternalFrame.greenComboBox
.getSelectedIndex();
blue = rgbBandChooserInternalFrame.blueComboBox
.getSelectedIndex();
red = redComboBox.getSelectedIndex();
green = greenComboBox.getSelectedIndex();
blue = blueComboBox.getSelectedIndex();
}
System.out.println(red+" "+green+" "+blue);
ImageSession currentImageSession = MainFrame.getInstance()
.getCurrentImageSession();
currentImageSession.getBirdViewPanel().setR(red);
currentImageSession.getBirdViewPanel().setG(green);
currentImageSession.getBirdViewPanel().setB(blue);
currentImageSession.getBirdViewPanel().syncImage();
MainFrame.getInstance().getCurrentImageSession().getBirdViewPanel()
.refresh();
rgbBandChooserInternalFrame.setVisible(false);
MainFrame.getInstance().getDesktop()
.setSelectedFrame(currentImageSession.associatedFrame);
scaledMin[red] = Double.parseDouble(redMin.getText());
scaledMax[red] = Double.parseDouble(redMax.getText());
scaledMin[green] = Double.parseDouble(greenMin.getText());
scaledMax[green] = Double.parseDouble(greenMax.getText());
scaledMin[blue] = Double.parseDouble(blueMin.getText());
scaledMax[blue] = Double.parseDouble(blueMax.getText());
rawImage.setR(red);
rawImage.setG(green);
rawImage.setB(blue);
rawImage.setScaledMinValues(scaledMin);
rawImage.setScaledMaxValues(scaledMax);
rawImage.notifyObservers();
RgbBandChooserInternalFrame.this.setVisible(false);
MainFrame.getInstance().getDesktop().setSelectedFrame(
MainFrame.getInstance().getCurrentImageSession().associatedFrame);
}
});
......@@ -181,7 +204,7 @@ public class RgbBandChooserInternalFrame extends JInternalFrame {
}
});*/
this.setSize(180, 195);
this.setSize(400, 500);
this.setResizable(false);
this.setMaximizable(true);
this.setIconifiable(true);
......@@ -189,5 +212,24 @@ public class RgbBandChooserInternalFrame extends JInternalFrame {
this.setLocation(90, 90);
this.setVisible(true);
}
private JPanel createChannelPanel(JComboBox<String> cb, JTextArea taMin, JTextArea taMax, String title) {
JPanel result = new JPanel(new GridLayout(2,2));
result.add(new JLabel(Messages.getString("RgbBandChooserInternalFrame.22")));
result.add(cb);
JPanel minPanel = new JPanel(new GridLayout(1, 2));
minPanel.add(new JLabel(Messages.getString("RgbBandChooserInternalFrame.20")));
minPanel.add(taMin);
result.add(minPanel);
JPanel maxPanel = new JPanel(new GridLayout(1, 2));
maxPanel.add(new JLabel(Messages.getString("RgbBandChooserInternalFrame.21")));
maxPanel.add(taMax);
result.add(maxPanel);
result.setBorder(BorderFactory.createTitledBorder(title));
return result;
}
}
......@@ -572,7 +572,7 @@ public class ConstraintsSelectionDialog extends JInternalFrame implements mustic
return true;
}
private void addConstraint(List<String> line, boolean isImageRelated) {
void addConstraint(List<String> line, boolean isImageRelated) {
switch (Integer.parseInt(line.get(line.size() - 1))) {
case Constraint.MUST_LINK_TYPE:
try {
......
......@@ -245,14 +245,14 @@ RgbBandChooserInternalFrame.12=Ok
RgbBandChooserInternalFrame.15=To delete some channels look at
RgbBandChooserInternalFrame.16="Clustering" menu or
RgbBandChooserInternalFrame.17="Crop" menu.
RgbBandChooserInternalFrame.2=channel
RgbBandChooserInternalFrame.3=channel
RgbBandChooserInternalFrame.4=channel
RgbBandChooserInternalFrame.5=channel
RgbBandChooserInternalFrame.2=Channel
RgbBandChooserInternalFrame.6=Color display
RgbBandChooserInternalFrame.7=R
RgbBandChooserInternalFrame.8=G
RgbBandChooserInternalFrame.9=B
RgbBandChooserInternalFrame.20=Min
RgbBandChooserInternalFrame.21=Max
RgbBandChooserInternalFrame.22=Channel index :
SegmentationDialog.0=Browse
SegmentationDialog.1=<html>Apply the algorithm of Region Merging.</html>
SegmentationDialog.14=Segmentation \:
......
......@@ -210,13 +210,13 @@ RgbBandChooserInternalFrame.15=Pour supprimer des bandes voir le
RgbBandChooserInternalFrame.16=menu "Clustering" ou le menu
RgbBandChooserInternalFrame.17="Crop".
RgbBandChooserInternalFrame.2=bande
RgbBandChooserInternalFrame.3=bande
RgbBandChooserInternalFrame.4=bande
RgbBandChooserInternalFrame.5=bande
RgbBandChooserInternalFrame.6=Coleur d'affichage
RgbBandChooserInternalFrame.7=R
RgbBandChooserInternalFrame.8=G
RgbBandChooserInternalFrame.9=B
RgbBandChooserInternalFrame.20=Min
RgbBandChooserInternalFrame.21=Max
RgbBandChooserInternalFrame.22=Index de bande :
SegmentationDialog.0=Parcourir...
SegmentationDialog.1=<html>Appliquez l'algorithme de Fusion de Rgion.</html>
SegmentationDialog.14=Segmentation \:
......
......@@ -171,6 +171,11 @@ public class BirdViewPanel extends JPanel implements MouseListener,
}
/** Get the red value */
public int getR() {
return this.r;
}
/** Get the blue value */
public int getB() {
return this.b;
......@@ -189,11 +194,6 @@ public class BirdViewPanel extends JPanel implements MouseListener,
return this.mImage.getNbBands();
}
/** Get the red value */
public int getR() {
return this.r;
}
public BufferedImage getSaveImage() {
return this.bImage;
}
......
......@@ -3,6 +3,8 @@ package mustic.gui.panels;
import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
import java.util.Observable;
import java.util.Observer;
import java.util.Vector;
import javax.swing.*;
......@@ -23,7 +25,7 @@ import mustic.utils.image.Zoomable;
/**
* Display an image and allows the user to do some operations on it (zoom, contrast..)
*/
public class ImagePanel extends JPanel implements Zoomable {
public class ImagePanel extends JPanel implements Zoomable, Observer {
/** */
private static final long serialVersionUID = 1L;
......@@ -121,6 +123,7 @@ public class ImagePanel extends JPanel implements Zoomable {
*/
public ImagePanel(RawImage aImage, ImageSession session) {
this.rawImage = aImage;
rawImage.addObserver(this);
if (session.isDisplayEnable()) {
this.viewer = new PyramidImageViewer(aImage, true);
......@@ -1212,4 +1215,20 @@ public class ImagePanel extends JPanel implements Zoomable {
return new Point(0,0);
}
@Override
public void update(Observable o, Object arg) {
if (o instanceof RawImage) {
RawImage rawImg = (RawImage) o;
int[] rgb = new int[3];
rgb[0] = rawImg.getR();
rgb[1] = rawImg.getG();
rgb[2] = rawImg.getB();
viewer.setRgbChannels(rgb);
viewer.setMinMaxValues(rawImg.getMinValues(), rawImg.getMaxValues());
displayPanel.repaint();
}
}
}
......@@ -824,9 +824,13 @@ public class ImageResultPanel extends ResultPanel implements TreeSelectionListen
BufferedImage bi = imgPanel.getFullColorImage();
String outputPath = "imageColor.tif";
File outputfile = new File(outputPath);
Vector<Color> colors = new Vector<Color>();
for (int k = 0 ; k < imgPanel.getClassification().getNbClusters(); k++) {
colors.add(imgPanel.getClassification().getClusteringResult().getCluster(k).getColor());
}
// ImageIO.write(bi, "png", outputfile);
TiffUtils.writeRGBTiffwithMetaData(bi, outputPath,
imgPanel.getImgData().getDataFilesName().get(0));
TiffUtils.writeIndexColorTiffwithMetaData(bi, outputPath,
imgPanel.getImgData().getDataFilesName().get(0), colors);
Packager.zipFile(out, name + "/imageColor.tif", outputfile);
outputfile.delete();
out.closeEntry();
......
......@@ -4,6 +4,7 @@ import java.awt.*;
import java.awt.image.*;
import java.io.*;
import java.util.Vector;
import java.util.Observable;
import javax.imageio.ImageReadParam;
import javax.swing.JOptionPane;
......@@ -25,13 +26,12 @@ import jcl.utils.exceptions.MethodNotImplementedException;
/**
* <p>
* RawImage is the generic class for all geoimages and provides functions for
* loading parts and birdview from the image.
* RawImage is the generic class for all geoimages.
* </p>
*
* @author Benoit Pradelle (benoit.pradelle@eturs.u-strasbg.fr)
*/
public class RawImage implements Serializable, MemoryFlush
public class RawImage extends Observable implements Serializable, MemoryFlush
{