Commit 11dbff3d authored by lafabregue's avatar lafabregue

add some simplemodifications

parent 21098208
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -66,7 +66,7 @@ public class ImageSession {
public SSHParameters sshparameters = null;
/** enable the image to display the image or not, for a memory usage matter */
private boolean displayEnable = true;
private boolean displayEnable = false;
/**
* @param aImage
......
This diff is collapsed.
......@@ -128,8 +128,7 @@ public class RgbBandChooserInternalFrame extends JInternalFrame {
currentImageSession.getBirdViewPanel().setR(red);
currentImageSession.getBirdViewPanel().setG(green);
currentImageSession.getBirdViewPanel().setB(blue);
currentImageSession.getBirdViewPanel().syncImage(
currentImageSession);
currentImageSession.getBirdViewPanel().syncImage();
MainFrame.getInstance().getCurrentImageSession().getBirdViewPanel()
.refresh();
......
......@@ -253,9 +253,7 @@ public class SequenceDialog extends JDialog {
.getInstance()
.getCurrentImageSession()
.getBirdViewPanel()
.syncImage(
MainFrame.getInstance()
.getCurrentImageSession());
.syncImage();
PictureTool.setR(MainFrame.getInstance()
.getCurrentImageSession().getRawImage()
.getBirdview(), 0);
......
......@@ -23,8 +23,8 @@ import javax.swing.SpinnerNumberModel;
import javax.swing.text.NumberFormatter;
import mustic.gui.MainFrame;
import mustic.utils.ImageHelper;
import mustic.utils.filters.ImageFileFilter;
import mustic.utils.image.ImageHelper;
import otbAppWrapping.ExecCommand;
public class WaterIndiceExtractionDialog extends JFrame {
......
......@@ -34,8 +34,8 @@ import mustic.gui.dialog.Messages;
import mustic.gui.dialog.SequenceDialog;
import mustic.io.ImageData;
import mustic.io.RawImage;
import mustic.utils.ImageHelper;
import mustic.utils.documentFilter.ToUpdateObject;
import mustic.utils.image.ImageHelper;
import mustic.utils.io.CSVUtils;
import mustic.utils.io.dataExchange.DataArffExchange;
import weka.core.Instance;
......
......@@ -13,6 +13,8 @@ import mustic.gui.*;
import mustic.io.RawImage;
import mustic.io.roi.RegionOfInterest;
import mustic.utils.filters.ZipFileFilter;
import mustic.utils.image.BufferedImageViewer;
import mustic.utils.image.ImageViewer;
/**
* Display an image and allows the user to do some operations on it (zoom, contrast..)
......@@ -20,60 +22,60 @@ import mustic.utils.filters.ZipFileFilter;
public class ImagePanel extends JPanel {
/** */
private static final long serialVersionUID = 1L;
private static final long serialVersionUID = 1L;
/** The transparency must be between 0.0 and 1.0 */
public static float transparency = new Float(0.50);
public static float transparency = new Float(0.50);
/** brightness value */
private float brightnessValue = 10;
private float brightnessValue = 10;
protected JMenuItem classifyAll;
protected JMenuItem classifyAll = null;
public Image img;
public Image img = null;
private boolean isDataBaseImage = false;
private boolean isDataBaseImage = false;
/** panel used to pick up information on the birdview selection */
protected BirdViewPanel mBirdPanell;
protected BirdViewPanel mBirdPanell = null;
/** label which contains the image */
public JLabel mImageLabel;
public JLabel mImageLabel = null;
/** panel used to update the informations when mouse moved */
protected ImageInformationPanel mInfoPanel;
protected ImageInformationPanel mInfoPanel = null;
protected MouseListener mouseListener = new MouseClickedListener();
/** screen image */
protected BufferedImage mScreenImage;
/**
* original image
*/
protected BufferedImage mSourceImage;
protected MouseListener mouseListener = new MouseClickedListener();
/** zoom level */
protected float mZoomRate = 1.9f;
protected float mZoomRate = 1.9f;
/** zoom step */
private float mZoomStep = 0.2f;
private float mZoomStep = 0.2f;
/** brightness step */
private float offsetStep = 5.0f;
private float offsetStep = 5.0f;
private ClassList pl_label;
private ClassList pl_label = null;
/** operation of rescaling */
RescaleOp rescale;
RescaleOp rescale = null;
/** contrast value */
private float scaleFactor = 1.0f;
private float scaleFactor = 1.0f;
/** contrast step */
private float scaleFactorStep = 0.1f;
private float scaleFactorStep = 0.1f;
private RawImage rawImage = null;
private RawImage rawImage = null;
private ImageViewer viewer = null;
/** screen image */
protected BufferedImage mScreenImage = null;
/** original image */
protected BufferedImage mSourceImage = null;
/**
* Create a new ImagePanel from a BufferedImage.
......@@ -82,11 +84,11 @@ public class ImagePanel extends JPanel {
public ImagePanel(BufferedImage aImage) {
if (MainFrame.DEBUG_MODE)
System.out.println("ImagePanel 1");
this.mSourceImage = aImage;
this.mScreenImage = aImage;
this.mImageLabel = new JLabel(new ImageIcon(this.mScreenImage));
this.mImageLabel.setHorizontalAlignment(SwingConstants.CENTER);
this.viewer = new BufferedImageViewer(aImage);
setLayout(new BorderLayout());
this.mImageLabel = new JLabel(new ImageIcon(viewer.getmScreenImage(0, 0,
this.getHeight(), this.getWidth(), mZoomRate)));
this.mImageLabel.setHorizontalAlignment(SwingConstants.CENTER);
add(this.mImageLabel, BorderLayout.CENTER);
}
......@@ -794,7 +796,7 @@ public class ImagePanel extends JPanel {
// ip.birdViewPanel
imageSession.getBirdViewPanel().syncImage(jInternalFrames[s].getImageSession());
imageSession.getBirdViewPanel().syncImage();
ip.reloadPoint(imageSession.getBirdViewPanel().xxsave, imageSession.getBirdViewPanel().yysave,
imageSession.getBirdViewPanel().rxsave, imageSession.getBirdViewPanel().rysave);
......@@ -857,7 +859,7 @@ public class ImagePanel extends JPanel {
for (int s = 0; s < jInternalFrames.length; s++) {
//ImagePanel ip = jInternalFrames[s].getImageSession().getImagePanel();
ImageSession imageSes = jInternalFrames[s].getImageSession();
imageSes.getBirdViewPanel().syncImage(jInternalFrames[s].getImageSession());
imageSes.getBirdViewPanel().syncImage();
}
}
}
......
......@@ -30,12 +30,12 @@ import jcl.learning.methods.monostrategy.SingleClassification;
import jcl.learning.methods.monostrategy.ahc.LearningResultAHC;
import jcl.learning.methods.monostrategy.ahc.ParametersAHC;
//<<<< TRANSPARENCE
import jcl.utils.Images.StreamedImageReaderWrapper;
//import jcl.utils.Images.StreamedImageReaderWrapper;
//>>>> TRANSPARENCE
import jsl.Segmentation;
import jsl.regionalisation.vectorisation.Filters;
//<<<< TRANSPARENCE
import loci.formats.FormatException;
//import loci.formats.FormatException;
//>>>> TRANSPARENCE
import mustic.gui.*;
import mustic.gui.dialog.FilterDialog;
......@@ -46,6 +46,7 @@ import mustic.models.gui.ClassificationModel;
import mustic.models.gui.panels.*;
import mustic.utils.Packager;
import mustic.utils.filters.*;
import mustic.utils.io.tiff.TiffUtils;
import org.apache.batik.svggen.SVGGraphics2DIOException;
......@@ -129,21 +130,21 @@ public class ImageResultPanel extends ResultPanel implements TreeSelectionListen
protected BufferedImage zoomed;
//<<<< TRANSPARENCE
// clusters' opacity
// up to 0 - 1
public static float opacity = 1;
public static float opacityCluster = 1;
public float getOpacity()
{
return opacity;
}
public float getOpacityCluster()
{
return opacityCluster;
}
// // clusters' opacity
// // up to 0 - 1
// public static float opacity = 1;
//
// public static float opacityCluster = 1;
//
// public float getOpacity()
// {
// return opacity;
// }
//
// public float getOpacityCluster()
// {
// return opacityCluster;
// }
//>>>> TRANSPARENCE
/**
......@@ -658,7 +659,7 @@ public class ImageResultPanel extends ResultPanel implements TreeSelectionListen
updateImageColors();
if (imgData.getAssociatedImageSessions() != null && imgData.getAssociatedImageSessions().size() > 0) {
imgData.getAssociatedImageSessions().get(0).getBirdViewPanel().syncImage(imgData.getAssociatedImageSessions().get(0));
imgData.getAssociatedImageSessions().get(0).getBirdViewPanel().syncImage();
}
this.resultTabbedPane.addTab("Image Result", this.panelImage);
......@@ -824,8 +825,11 @@ public class ImageResultPanel extends ResultPanel implements TreeSelectionListen
/** Sauvegarde de l'image couleur */
// retrieve image
BufferedImage bi = imgPanel.getFullColorImage();
File outputfile = new File("imageColor");
ImageIO.write(bi, "png", outputfile);
String outputPath = "imageColor.tif";
File outputfile = new File(outputPath);
// ImageIO.write(bi, "png", outputfile);
TiffUtils.writeRGBTiffwithMetaData(bi, outputPath,
imgPanel.getImgData().getDataFilesName().get(0));
Packager.zipFile(out, name + "/imageColor.tif", outputfile);
outputfile.delete();
out.closeEntry();
......@@ -1385,7 +1389,7 @@ public class ImageResultPanel extends ResultPanel implements TreeSelectionListen
this.colored = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
// <<<< TRANSPARENCE
StreamedImageReaderWrapper wrapper = new StreamedImageReaderWrapper(imgData.getDataFilesName().get(0));
// StreamedImageReaderWrapper wrapper = new StreamedImageReaderWrapper(imgData.getDataFilesName().get(0));
// >>>> TRANSPARENCE
int current = 0;
for (int i = 0; i < width * height; i++) {
......@@ -1399,61 +1403,65 @@ public class ImageResultPanel extends ResultPanel implements TreeSelectionListen
if (x >= 0 && x < w && y >= 0 && y < h) {
Cluster c = this.classification.getClusteringResult().getCluster(map[current]);
if (c != null) {
if (c.isVisible()) // cluster's color
{
if (c.isVisible()) {// cluster's color
// <<<< TRANSPARENCE
if (getOpacityCluster() == 1.0) {
// if (getOpacityCluster() == 1.0) {
// >>>> TRANSPARENCE
couleur = c.getColor().getRGB();
} else {
// couleur = Color.black.getRGB();
} else {
// << TO COMMENT IF TRANSPARENCE IS USED
couleur = Color.black.getRGB();
// >> TO COMMENT IF TRANSPARENCE IS USED
// <<<< TRANSPARENCE
try
{
int r = (int)wrapper.getPixel(x, y)[0];
int g = (int)wrapper.getPixel(x, y)[1];
int b = (int)wrapper.getPixel(x, y)[2];
Color couleurFont = new Color(r, g, b);
couleurFont = blend(Color.black, couleurFont, getOpacity());
couleur = blend(couleurFont, c.getColor(), getOpacityCluster()).getRGB();
}
catch (FormatException e)
{
e.printStackTrace();
}
catch (IOException e)
{
e.printStackTrace();
}
}
}
else // font image's color
{
try
{
int r = (int)wrapper.getPixel(x, y)[0];
int g = (int)wrapper.getPixel(x, y)[1];
int b = (int)wrapper.getPixel(x, y)[2];
Color couleurFont = new Color(r, g, b);
couleur = blend(Color.black, couleurFont, getOpacity()).getRGB();
}
catch (FormatException e)
{
e.printStackTrace();
}
catch (IOException e)
{
e.printStackTrace();
}
}
// <<<< TRANSPARENCE
// try
// {
// int r = (int)wrapper.getPixel(x, y)[0];
// int g = (int)wrapper.getPixel(x, y)[1];
// int b = (int)wrapper.getPixel(x, y)[2];
//
// Color couleurFont = new Color(r, g, b);
// couleurFont = blend(Color.black, couleurFont, getOpacity());
//
// couleur = blend(couleurFont, c.getColor(), getOpacityCluster()).getRGB();
// }
// catch (FormatException e)
// {
// e.printStackTrace();
// }
// catch (IOException e)
// {
// e.printStackTrace();
// }
// }
// }
// else { // font image's color
//
// try
// {
// int r = (int)wrapper.getPixel(x, y)[0];
// int g = (int)wrapper.getPixel(x, y)[1];
// int b = (int)wrapper.getPixel(x, y)[2];
//
// if (r > 255) r = 255;
// if (g > 255) g = 255;
// if (b > 255) b = 255;
// Color couleurFont = new Color(r, g, b);
//
// couleur = blend(Color.black, couleurFont, getOpacity()).getRGB();
// }
// catch (FormatException e)
// {
// e.printStackTrace();
// }
// catch (IOException e)
// {
// e.printStackTrace();
// }
// >>>> TRANSPARENCE
}
this.colored.setRGB(x, y, couleur);
}
this.colored.setRGB(x, y, couleur);
}
}
current++;
}
......
......@@ -6,7 +6,7 @@ import javax.swing.JComboBox;
import javax.swing.JLabel;
import jcl.learning.LearningParameters;
import mustic.gui.DesktopFrame;
import mustic.gui.ImageDesktopFrame;
import mustic.gui.MainFrame;
import mustic.io.ImageData;
import mustic.io.RawImage;
......@@ -28,7 +28,7 @@ class RemoteSensingClassifierDialog extends ClassifierDialog {
ImageData bidouille = null;
JComboBox dataBox = new JComboBox();
JComboBox<String> dataBox = new JComboBox<String>();
JLabel dataLabel = new JLabel("Donnees de l'agent");
public RemoteSensingClassifierDialog(HybridClassificationParametersPanel sg) {
......@@ -38,8 +38,8 @@ class RemoteSensingClassifierDialog extends ClassifierDialog {
dataGroup.setTitle("Data");
dataGroup.add(this.dataLabel);
DesktopFrame[] desktopFrames = MainFrame.getInstance().getDesktop()
.getAllDesktopFrames();
ImageDesktopFrame[] desktopFrames = MainFrame.getInstance().getDesktop()
.getAllImageDesktopFrames();
int nbSessions = desktopFrames.length;
for (int i = 0; i < nbSessions; i++)
......@@ -77,7 +77,7 @@ class RemoteSensingClassifierDialog extends ClassifierDialog {
RawImage img = null;
if (this.bidouille == null) {
img = MainFrame.getInstance().getDesktop().getAllDesktopFrames()[this.dataBox
img = MainFrame.getInstance().getDesktop().getAllImageDesktopFrames()[this.dataBox
.getSelectedIndex()].getImageSession().getRawImage();
this.bidouille = new ImageData(img);
}
......
......@@ -320,8 +320,13 @@ public class SourceSelectionPanel extends JPanel {
}
if (allGeoReferenced) {
int[] boundaries = RawImage.getGeoOverlappingPixelBoundaries(rawImages);
fatherContainer.setSample(new ImageSampler(fatherContainer.getSequenceDialog()
.getSequenceData(), geoTranslateVectors, boundaries[0], boundaries[1], boundaries[2], boundaries[3]));
if (boundaries != null) {
fatherContainer.setSample(new ImageSampler(fatherContainer.getSequenceDialog()
.getSequenceData(), geoTranslateVectors, boundaries[0], boundaries[1], boundaries[2], boundaries[3]));
} else {
fatherContainer.setSample(new ImageSampler(fatherContainer
.getSequenceDialog().getSequenceData()));
}
} else {
fatherContainer.setSample(new ImageSampler(fatherContainer
.getSequenceDialog().getSequenceData()));
......
......@@ -1128,8 +1128,8 @@ public class SegmentationPanelResultatImage extends JPanel {
@Override
public void addResult(Classification result, String title, TabbedPanel pane) {
SegmentationResultPanel rp = new SegmentationResultPanel(result, this, MainFrame.getInstance().getCurrentImageSession().getRawImage(), s,
getLabelRandomColors(), -1);
SegmentationResultPanel rp = new SegmentationResultPanel(result, this, ((ImageData) MainFrame.getInstance()
.getCurrentImageSession().getData()), s, getLabelRandomColors(), -1);
Tab tabResult = ClassificationModel.createTab("Result " + ResultPanel.nbResult,
new ImageIcon(getClass().getResource("/icons/actions/document-open-result.png")), rp,
true);
......@@ -1144,8 +1144,8 @@ public class SegmentationPanelResultatImage extends JPanel {
// Si le résultat est classique
if (!(result.isMultiresolution())) {
SegmentationResultPanel srp = new SegmentationResultPanel(result, this,
MainFrame.getInstance().getCurrentImageSession().getRawImage(), s, getLabelRandomColors(), -1);
SegmentationResultPanel srp = new SegmentationResultPanel(result, this, ((ImageData) MainFrame.getInstance()
.getCurrentImageSession().getData()), s, getLabelRandomColors(), -1);
Tab tabResult = ClassificationModel.createTab("Result " + ResultPanel.nbResult,
new ImageIcon(getClass().getResource("/icons/actions/document-open-result.png")),
srp, true);
......@@ -1173,7 +1173,7 @@ public class SegmentationPanelResultatImage extends JPanel {
if (MainFrame.DEBUG_MODE)
System.out.println("Création depuis le segmentation panel");
ClassifierPanel cp = new ClassifierPanel(classificationImage, false, true);
ClassifierPanel cp = new ClassifierPanel(classificationImage, false);
cp.setTabbed();
cp.votingDataComboBox.addItem("segmentation");
......@@ -1186,7 +1186,7 @@ public class SegmentationPanelResultatImage extends JPanel {
classificationImage.tabbedPane.addTab(tabClassifier);
classificationImage.tabbedPane.getTabAt(1).setSelected(true);
final TitledTab tab = new TitledTab("Clustering Segpan" + ImageSession.nbClustering++, null, classificationImage.tabbedPane, new JPanel());
final TitledTab tab = new TitledTab("Clustering Segpan" + ResultPanel.nbResult++, null, classificationImage.tabbedPane, new JPanel());
tab.setFocusableComponent(null);
JButton closeButton = new JButton(new ImageIcon(tab.getClass().getResource("/icons/cluster-invisible.png")));
......@@ -1199,9 +1199,7 @@ public class SegmentationPanelResultatImage extends JPanel {
public void actionPerformed(ActionEvent e) {
tab.getTabbedPanel().removeTab(tab);
MainFrame.getInstance().getCurrentImageSession().getWorkSpace().removeTab(tab);
MainFrame.getInstance().getCurrentImageSession().getResultPanels().removeAllElements();
// MainFrame.getInstance().getCurrentImageSession().getResultPanels().removeAllElements();
}
});
tab.setHighlightedStateTitleComponent(closeButton);
......
......@@ -270,7 +270,7 @@ public class ImageData extends SimpleData implements Serializable {
dimensions[0] = rawImages.get(0).width;
dimensions[1] = rawImages.get(0).height;
new ProgressThreadJCL(sampler, MainFrame.getProgressBar(), MainFrame.getProgressStatus()).start();
// new ProgressThreadJCL(sampler, MainFrame.getProgressBar(), MainFrame.getProgressStatus()).start();
if (mask != null) {
currentView = sampler.getDataObjects(mask);
} else {
......@@ -358,7 +358,7 @@ public class ImageData extends SimpleData implements Serializable {
dimensions[0] = rawImages.get(0).width;
dimensions[1] = rawImages.get(0).height;
new ProgressThreadJCL(sampler, MainFrame.getProgressBar(), MainFrame.getProgressStatus()).start();
// new ProgressThreadJCL(sampler, MainFrame.getProgressBar(), MainFrame.getProgressStatus()).start();
if (mask != null) {
currentView = sampler.getDataObjects(mask);
......
......@@ -2758,16 +2758,18 @@ public class RawImage extends Thread implements Serializable, MemoryFlush
*
* @param images
* images to analyse
* @return the boundary {startX, startY, endX, endY}
* @return the boundary {startX, startY, endX, endY},
* null if all images are exactly at the same position
*/
public static int[] getGeoOverlappingPixelBoundaries(RawImage[] images)
{
int[] boundaries = new int[4];
boolean changed = false;
double xLower = images[0].getInitPosGeoX();
double xUpper = images[0].getInitPosGeoX() + (images[0].getWidth() - 1) * Math.abs(images[0].getPixelSizeX());
double xUpper = images[0].getInitPosGeoX() + images[0].getWidth() * Math.abs(images[0].getPixelSizeX());
double yLower = images[0].getInitPosGeoY();
double yUpper = images[0].getInitPosGeoY() + (images[0].getHeight() - 1) * Math.abs(images[0].getPixelSizeY());
double yUpper = images[0].getInitPosGeoY() + images[0].getHeight() * Math.abs(images[0].getPixelSizeY());
// System.out.println(images[0].getWidth());
// compute all extremums
......@@ -2776,26 +2778,33 @@ public class RawImage extends Thread implements Serializable, MemoryFlush
if (images[i].getInitPosGeoX() > xLower)
{
xLower = images[i].getInitPosGeoX();
changed = true;
}
// System.out.println(images[i].getInitPosGeoX() + "+"+
// (images[i].getWidth()-1)+ "*"+Math.abs(images[i].getPixelSizeX())
// +" ( "+ (images[i].getInitPosGeoX() +
// (images[i].getWidth()-1)*Math.abs(images[i].getPixelSizeX()))+")
// < "+ xUpper);
if (images[i].getInitPosGeoX() + (images[i].getWidth() - 1) * Math.abs(images[i].getPixelSizeX()) < xUpper)
if (images[i].getInitPosGeoX() + images[i].getWidth() * Math.abs(images[i].getPixelSizeX()) < xUpper)
{
xUpper = images[i].getInitPosGeoX() + (images[i].getWidth() - 1) * Math.abs(images[i].getPixelSizeX());
xUpper = images[i].getInitPosGeoX() + images[i].getWidth() * Math.abs(images[i].getPixelSizeX());
changed = true;
// System.out.println(images[i].getWidth());
}
if (images[i].getInitPosGeoY() > yLower)
{
yLower = images[i].getInitPosGeoY();
changed = true;
}
if (images[i].getInitPosGeoY() + images[i].getHeight() * Math.abs(images[i].getPixelSizeY()) < yUpper)
{
yUpper = images[i].getInitPosGeoY() + images[i].getHeight() * Math.abs(images[i].getPixelSizeY());
changed = true;
}
}
if (!changed) {
return null;
}
// retro-compute the coordinate on first image proportions
boundaries[0] = (int) Math.ceil((xLower - images[0].getInitPosGeoX()) / images[0].getPixelSizeX());
boundaries[1] = (int) Math.ceil((yLower - images[0].getInitPosGeoY()) / images[0].getPixelSizeY());
......
......@@ -63,7 +63,7 @@ public class ProgressThreadJCL extends Thread {
{
while (prog != 100) {
prog = this.p.getProgress();
status = this.p.getStatus();
// status = this.p.getStatus();
this.b.setValue(prog);
MainFrame.getProgressStatus().setMessage(status);
try {
......
package mustic.utils.image;
import java.awt.image.BufferedImage;
import jcl.data.mask.Mask;
public class BufferedImageViewer implements ImageViewer {
/** screen image */
protected BufferedImage mScreenImage = null;
/** original image */
protected BufferedImage mSourceImage = null;
public BufferedImageViewer(BufferedImage image) {
this.mSourceImage = image;
this.mScreenImage = image;
}
@Override
public void decreaseBrightness() {
// TODO Auto-generated method stub
}
@Override
public void increaseBrightness() {
// TODO Auto-generated method stub
}
@Override
public float getBrightnessValue() {
// TODO Auto-generated method stub
return 0;
}
@Override
public void setBrightnessValue(float brightnessValue) {
// TODO Auto-generated method stub
}
@Override
public float getContrastValue() {
// TODO Auto-generated method stub
return 0;
}
@Override
public void setContrastValue(float contrastValue) {
// TODO Auto-generated method stub
}
@Override
public void decreaseContrast() {
// TODO Auto-generated method stub
}
@Override
public void increaseContrast() {
// TODO Auto-generated method stub
}
@Override
public void setContrastStep(float contrastStep) {
// TODO Auto-generated method stub
}
@Override
public float getContrastStep() {