Commit 048cfaef authored by lafabregue's avatar lafabregue

integration of multicubetools project

parent b2b142b3
......@@ -50,6 +50,8 @@ import jcl.learning.methods.multistrategy.samarah.SamarahConfig;
import jcl.weights.ClassificationWeights;
import jcl.weights.GlobalWeights;
import jsl.Segmentation;
import multiCube.tools.image.ImageHelper;
import multiCube.tools.util.gui.ProgressStatus;
import mustic.gui.dialog.*;
import mustic.gui.dialog.arff.ArffLoadDialog;
import mustic.gui.dialog.arff.ArffToDataDialog;
......@@ -72,10 +74,8 @@ import mustic.models.thread.ClassificationThread;
import mustic.utils.UnZipSub;
import mustic.utils.filters.ImageFileFilter;
import mustic.utils.filters.ZipFileFilter;
import mustic.utils.image.ImageHelper;
import mustic.utils.io.CSVUtils;
import mustic.utils.io.dataExchange.DataCsvExchange;
import mustic.utils.tools.ProgressStatus;
import net.infonode.tabbedpanel.*;
import net.infonode.tabbedpanel.titledtab.TitledTab;
import net.infonode.util.Direction;
......@@ -1545,7 +1545,7 @@ public class MainFrame extends JFrame {
// =============== Creation of the Desktop ================
JPanel panel_desktop = new JPanel(new BorderLayout());
panel_desktop.setOpaque(false);
panel_desktop.setBorder(Borders.DIALOG);
panel_desktop.setBorder(Borders.DIALOG_BORDER);
panel_desktop.add(this.desktop);
sif_desktop = new SimpleInternalFrame(Messages.getString("MainFrame.72")); //$NON-NLS-1$
......@@ -1559,7 +1559,7 @@ public class MainFrame extends JFrame {
JPanel panel = new JPanel(new BorderLayout());
panel.setOpaque(false);
panel.setBorder(Borders.DIALOG);
panel.setBorder(Borders.DIALOG_BORDER);
panel.add(pane);
// =============== Creation of the Progress Panel => South
......@@ -1680,7 +1680,7 @@ public class MainFrame extends JFrame {
// =============== Creation of the Desktop ================
JPanel panel_desktop = new JPanel(new BorderLayout());
panel_desktop.setOpaque(false);
panel_desktop.setBorder(Borders.DIALOG);
panel_desktop.setBorder(Borders.DIALOG_BORDER);
panel_desktop.add(this.desktop);
sif_desktop = new SimpleInternalFrame(Messages.getString("MainFrame.72")); //$NON-NLS-1$
......@@ -1694,7 +1694,7 @@ public class MainFrame extends JFrame {
JPanel panel = new JPanel(new BorderLayout());
panel.setOpaque(false);
panel.setBorder(Borders.DIALOG);
panel.setBorder(Borders.DIALOG_BORDER);
panel.add(pane);
// =============== Creation of the Progress Panel => South
......
......@@ -18,11 +18,11 @@ import javax.swing.JTextField;
import jcl.data.mask.IntArrayMask;
import jcl.data.mask.Mask;
import jcl.data.mask.MultiIDIntArrayMask;
import multiCube.tools.image.reader.GDALImageReaderWrapper;
import multiCube.tools.image.reader.ReaderWrapper;
import mustic.gui.dialog.Messages;
import mustic.gui.panels.data.DataConstructPanel;
import mustic.io.RawImage;
import mustic.utils.image.reader.GDALImageReaderWrapper;
import mustic.utils.image.reader.ReaderWrapper;
import mustic.utils.io.CSVUtils;
......
......@@ -29,11 +29,9 @@ import javax.swing.JScrollPane;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import loci.formats.FormatException;
import mustic.gui.ImageDesktopFrame;
import mustic.gui.ImageSession;
import mustic.gui.MainFrame;
import mustic.io.PictureTool;
import mustic.io.RawImage;
import mustic.utils.documentFilter.ToUpdateObject;
......@@ -297,11 +295,8 @@ public class SequenceDialog extends JDialog {
* Return the list of image path constituting the selected sequence
*
* @return the list of ordered file path
*
* @throws FormatException
* if the images don't have the same dimensions
*/
public Vector<RawImage> getSequenceData() throws FormatException {
public Vector<RawImage> getSequenceData() {
int nb = this.dlmSeq.getSize();
Donnee donnee;
Vector<RawImage> paths = new Vector<RawImage>();
......@@ -325,11 +320,8 @@ public class SequenceDialog extends JDialog {
* Return the list of image sessions constituting the selected sequence
*
* @return the list of ordered session
*
* @throws FormatException
* if the images don't have the same dimensions
*/
public Vector<ImageSession> getSequenceSessions() throws FormatException {
public Vector<ImageSession> getSequenceSessions() {
int nb = this.dlmSeq.getSize();
Donnee donnee;
Vector<ImageSession> paths = new Vector<ImageSession>();
......
......@@ -22,9 +22,9 @@ import javax.swing.JTextField;
import javax.swing.SpinnerNumberModel;
import javax.swing.text.NumberFormatter;
import multiCube.tools.image.ImageHelper;
import mustic.gui.MainFrame;
import mustic.utils.filters.ImageFileFilter;
import mustic.utils.image.ImageHelper;
import otbAppWrapping.ExecCommand;
public class WaterIndiceExtractionDialog extends JFrame {
......
......@@ -24,10 +24,10 @@ import jcl.data.Data;
import jcl.data.DataObject;
import jcl.data.SimpleData;
import jcl.data.attribute.AttributeMultiDimSequence;
import multiCube.tools.image.ImageHelper;
import mustic.gui.MainFrame;
import mustic.gui.dialog.Messages;
import mustic.utils.documentFilter.ToUpdateObject;
import mustic.utils.image.ImageHelper;
import mustic.utils.io.CSVUtils;
......
......@@ -20,10 +20,10 @@ import javax.swing.JPanel;
import javax.swing.JTextField;
import jcl.data.Data;
import multiCube.tools.image.ImageHelper;
import mustic.gui.DataDesktopFrame;
import mustic.gui.MainFrame;
import mustic.gui.dialog.Messages;
import mustic.utils.image.ImageHelper;
import mustic.utils.io.dataExchange.DataOGRExchange;
/**
......
......@@ -30,10 +30,11 @@ import jcl.learning.methods.monostrategy.SingleClassification;
import jcl.learning.methods.monostrategy.ahc.LearningResultAHC;
import jcl.learning.methods.monostrategy.ahc.ParametersAHC;
import jcl.utils.exceptions.JCLFormatException;
import jcl.utils.exceptions.MethodNotImplementedException;
import jcl.utils.io.JCLModelExchange;
import jsl.Segmentation;
import jsl.regionalisation.vectorisation.Filters;
import multiCube.tools.image.tiff.TiffUtils;
import multiCube.tools.util.exceptions.MethodNotImplementedException;
import mustic.gui.*;
import mustic.gui.dialog.FilterDialog;
import mustic.gui.dialog.classifier.ConstraintsSelectionFrame;
......@@ -54,7 +55,6 @@ import mustic.utils.image.viewer.ClusteringImageViewer;
import mustic.utils.image.viewer.GDALPyramidImageViewer;
import mustic.utils.image.viewer.ImageViewer;
import mustic.utils.image.viewer.MultiResolutionClusterMap;
import mustic.utils.io.tiff.TiffUtils;
import org.apache.batik.svggen.SVGGraphics2DIOException;
......
......@@ -18,7 +18,6 @@ import jcl.learning.methods.multistrategy.modular.ClassifierModular;
import jcl.learning.methods.multistrategy.modular.maclaw.ClassifierMaclaw;
import jcl.learning.methods.multistrategy.modular.maclaw.ParametersMaclaw;
import jcl.weights.*;
import loci.formats.FormatException;
import mustic.gui.*;
import mustic.gui.dialog.classifier.ClassifierDialog;
import mustic.gui.panels.classifier.SelectionModel;
......@@ -119,11 +118,7 @@ public class MaclawClassificationParametersPanel extends JPanel implements Param
if (this.initMethodClassifierDialog.classifiersPanel.getApproachPanel().getDataComboBox().getSelectedIndex() == nbSessions) {
this.data = desktopFrames[this.initMethodClassifierDialog.classifiersPanel.sequenceDialog.getFirstIndex()].getImageSession()
.getImageData();
try {
this.data.setSequence(this.initMethodClassifierDialog.classifiersPanel.sequenceDialog.getSequenceData());
} catch (FormatException e) {
e.printStackTrace();
}
this.data.setSequence(this.initMethodClassifierDialog.classifiersPanel.sequenceDialog.getSequenceData());
}
else {
this.data = desktopFrames[this.initMethodClassifierDialog.classifiersPanel.getApproachPanel().getDataComboBox()
......@@ -173,11 +168,7 @@ public class MaclawClassificationParametersPanel extends JPanel implements Param
if (this.initMethodClassifierDialog.classifiersPanel.getApproachPanel().getDataComboBox().getSelectedIndex() == nbSession) {
this.data = desktopFrames[this.initMethodClassifierDialog.classifiersPanel.sequenceDialog.getFirstIndex()].getImageSession()
.getImageData();
try {
this.data.setSequence(this.initMethodClassifierDialog.classifiersPanel.sequenceDialog.getSequenceData());
} catch (FormatException e) {
e.printStackTrace();
}
this.data.setSequence(this.initMethodClassifierDialog.classifiersPanel.sequenceDialog.getSequenceData());
}
else {
imgSession = desktopFrames[this.initMethodClassifierDialog.classifiersPanel.getApproachPanel().getDataComboBox()
......
......@@ -64,10 +64,10 @@ public class SegmentationPanel extends JPanel implements ActionListener, MouseLi
/*** truc ImageSession */
/** zoom level */
protected float mZoomRate = 1.0f; // 1.9f;
protected double mZoomRate = 1.0; // 1.9f;
/** zoom step */
protected float mZoomStep = 0.1f; // 0.2f;
protected double mZoomStep = 0.1; // 0.2f;
/** brightness value */
float offset = 10;
......
......@@ -264,7 +264,7 @@ public class SegmentationPanelResultatImage extends JPanel {
* Apply the zoom factor. And display the image. When another operation is finished, this method
* <b>must be called<b>.
*/
public void doZoomOp(float mZoomRate) {
public void doZoomOp(double mZoomRate) {
AffineTransform trans = AffineTransform.getScaleInstance(mZoomRate, mZoomRate);
AffineTransformOp op = new AffineTransformOp(trans, AffineTransformOp.TYPE_NEAREST_NEIGHBOR);
this.zoomed = op.filter(this.imageContours, null); // this.colored
......@@ -459,7 +459,7 @@ public class SegmentationPanelResultatImage extends JPanel {
}
public void clickSurImage(int x, int y, float mZoomRate) {
public void clickSurImage(int x, int y, double mZoomRate) {
if (x >= 0 && x < this.zoomed.getWidth() && y >= 0 && y < this.zoomed.getHeight()) {
this.setClicked(this.getPointWithReelCoordinates(x, y, mZoomRate));
this.updateInformationPanel(x, y, mZoomRate);
......@@ -472,7 +472,7 @@ public class SegmentationPanelResultatImage extends JPanel {
* @param y the y co-ordinate of the point which is clicked.
* @return the point with the reel co-ordinates.
*/
public Point getPointWithReelCoordinates(int x, int y, float mZoomRate) {
public Point getPointWithReelCoordinates(int x, int y, double mZoomRate) {
int xreel, yreel;
xreel = (int) (((double) x / mZoomRate) + this.rx);
yreel = (int) (((double) y / mZoomRate) + this.ry);
......@@ -520,7 +520,7 @@ public class SegmentationPanelResultatImage extends JPanel {
* @param x x coord.
* @param y y coord.
*/
private void updateInformationPanel(int ex, int ey, float mZoomRate) {
private void updateInformationPanel(int ex, int ey, double mZoomRate) {
double w1 = contoursLabel.getWidth();
double w2 = contoursLabel.getIcon().getIconWidth();
......@@ -566,7 +566,7 @@ public class SegmentationPanelResultatImage extends JPanel {
}
}
public void setRegionToolTip(int x, int y, float mZoomRate) {
public void setRegionToolTip(int x, int y, double mZoomRate) {
if (x >= 0 && x < this.zoomed.getWidth() && y >= 0 && y < this.zoomed.getHeight()) {
Point clicked = this.getPointWithReelCoordinates(x, y, mZoomRate);
this.updateRegionInfos(clicked);
......
......@@ -10,7 +10,7 @@ import jcl.data.attribute.AttributeMultiDimSequence;
import jcl.data.attribute.AttributeNumerical;
import jcl.data.mask.Mask;
import jcl.data.sampling.Sampler;
import jcl.utils.exceptions.MethodNotImplementedException;
import multiCube.tools.util.exceptions.MethodNotImplementedException;
import mustic.gui.ImageSession;
import mustic.gui.MainFrame;
import mustic.models.thread.ProgressThreadJCL;
......
......@@ -8,8 +8,8 @@ import java.io.IOException;
import java.util.Iterator;
import jcl.data.mask.Mask;
import mustic.utils.image.reader.GDALImageReaderWrapper;
import mustic.utils.image.reader.ReaderWrapper;
import multiCube.tools.image.reader.GDALImageReaderWrapper;
import multiCube.tools.image.reader.ReaderWrapper;
//import mustic.io.bsq.BSQImage;
......
......@@ -18,16 +18,16 @@ import mustic.gui.Messages;
import mustic.gui.dialog.MaskImportDialog;
import mustic.io.roi.ROIImage;
import mustic.io.roi.RegionOfInterest;
import mustic.utils.image.reader.GDALImageReaderWrapper;
import mustic.utils.image.reader.ReaderWrapper;
import otbAppWrapping.*;
import com.l2fprod.common.propertysheet.DefaultProperty;
import com.l2fprod.common.propertysheet.Property;
import jcl.data.mask.Mask;
import jcl.utils.MemoryFlush;
import jcl.utils.exceptions.MethodNotImplementedException;
import multiCube.tools.image.reader.GDALImageReaderWrapper;
import multiCube.tools.image.reader.ReaderWrapper;
import multiCube.tools.util.MemoryFlush;
import multiCube.tools.util.exceptions.MethodNotImplementedException;
/**
* <p>
......@@ -617,8 +617,20 @@ public class RawImage extends Observable implements Serializable, MemoryFlush
{
try
{
setDataMatrice(replacer.loadImage(info.getTempPath(), info.getSizeX(), info.getSizeY(),
info.getNumberOfBands()));
// setDataMatrice(replacer.loadImage(info.getTempPath(), info.getSizeX(), info.getSizeY(),
// info.getNumberOfBands()));
GDALImageReaderWrapper reader = new GDALImageReaderWrapper(info.getPath());
double data[][][] = new double[reader.getChannelCount()][reader.getImageWidth()][reader.getImageHeight()];
for(int x = 0 ; x < reader.getImageWidth() ; x++) {
for (int y = 0 ; y < reader.getImageHeight() ; y++) {
double[] pixel = reader.getPixel(x, y);
for (int c = 0 ; c < pixel.length ; c++) {
data[c][x][y] = pixel[c];
}
}
}
setDataMatrice(data);
MainFrame.getProgressBar().setValue(MainFrame.getProgressBar().getValue() + 50);
}
catch (Exception e)
......@@ -897,11 +909,11 @@ public class RawImage extends Observable implements Serializable, MemoryFlush
}
/**
* Retourne une image au format fr.unistra.pelican. TODO ne marche pas
* Retourne une image au format fr.unistra.pelican. TODO old methods, that is too memory consuming and support only 4 channels images
*/
public image.Image getPiafImage()
{
image.Image image = new image.ByteImage(this.getWidth(), this.getHeight(), 1, 1, this.getNbBands());
image.Image image = new image.DoubleImage(this.getWidth(), this.getHeight(), 1, 1, this.getNbBands());
double[][][] buffer = load(0, 0, getWidth(), getHeight());
......@@ -910,24 +922,24 @@ public class RawImage extends Observable implements Serializable, MemoryFlush
for (int b = 0; b < this.getNbBands(); b++)
{
int pixelValue = (int) buffer[b][x][y];
double pixelValue = (double) buffer[b][x][y];
if (b == this.r)
{
image.setPixelXYBByte(x, y, 0, pixelValue);
image.setPixelXYBDouble(x, y, 0, pixelValue);
// System.out.println(b+" "+this.r);
}
else if (b == this.g)
{
image.setPixelXYBByte(x, y, 1, (int) buffer[b][x][y]);
image.setPixelXYBDouble(x, y, 1, buffer[b][x][y]);
}
else if (b == this.b)
{
image.setPixelXYBByte(x, y, 2, (int) buffer[b][x][y]);
image.setPixelXYBDouble(x, y, 2, buffer[b][x][y]);
}
else
{
image.setPixelXYBByte(x, y, 3, (int) buffer[b][x][y]);
image.setPixelXYBDouble(x, y, 3, buffer[b][x][y]);
}
}
if (MainFrame.DEBUG_MODE)
......
......@@ -24,6 +24,7 @@ import jcl.Classification;
import jcl.data.Data;
import jcl.jcld.database.SSHParameters;
import jcl.learning.methods.monostrategy.SingleClassification;
import multiCube.tools.util.gui.ProgressStatus;
import mustic.gui.DataSession;
import mustic.gui.MainFrame;
import mustic.gui.panels.ImageResultPanel;
......@@ -33,7 +34,6 @@ import mustic.models.gui.panels.HybridClassificationMonitor;
import mustic.models.gui.panels.MaclawClassificationMonitor;
import mustic.models.gui.panels.ResultPanel;
import mustic.models.gui.widgets.ClassificationManager;
import mustic.utils.tools.ProgressStatus;
import net.infonode.tabbedpanel.Tab;
import net.infonode.tabbedpanel.TabDragEvent;
import net.infonode.tabbedpanel.TabEvent;
......
......@@ -15,7 +15,7 @@ import javax.swing.tree.DefaultMutableTreeNode;
import jcl.Classification;
import jcl.clustering.Cluster;
import jcl.utils.exceptions.MethodNotImplementedException;
import multiCube.tools.util.exceptions.MethodNotImplementedException;
import mustic.models.gui.panels.ResultPanel;
import mustic.models.gui.panels.utils.ClassTreeRenderer;
......
......@@ -14,7 +14,7 @@ import javax.swing.JSpinner;
import jcl.Classification;
import jcl.clustering.Cluster;
import jcl.utils.exceptions.MethodNotImplementedException;
import multiCube.tools.util.exceptions.MethodNotImplementedException;
import mustic.models.gui.panels.ResultPanel;
public class SplitDialog extends JDialog {
......
......@@ -17,7 +17,7 @@ import jcl.learning.IterativeClassification;
import jcl.learning.methods.ClassifierUtils;
import jcl.learning.methods.multistrategy.samarah.HybridClassification;
import jcl.utils.Matrix;
import jcl.utils.exceptions.MethodNotImplementedException;
import multiCube.tools.util.exceptions.MethodNotImplementedException;
import mustic.gui.ClassificationImage;
import mustic.gui.DataDesktopFrame;
import mustic.gui.MainFrame;
......
......@@ -9,8 +9,8 @@ import jcl.clustering.constraints.Constraint;
import jcl.jcld.RmiServer;
import jcl.learning.IterativeClassification;
import jcl.learning.methods.multistrategy.samarah4.comm.ClassificationSAM4;
import multiCube.tools.util.gui.ProgressStatus;
import mustic.models.gui.ClassificationModel;
import mustic.utils.tools.ProgressStatus;
/**
* <p>
......
......@@ -5,8 +5,8 @@ import java.util.Date;
import javax.swing.JProgressBar;
import jcl.utils.Progressable;
import multiCube.tools.util.gui.ProgressStatus;
import mustic.gui.MainFrame;
import mustic.utils.tools.ProgressStatus;
/**
* <p>
......
......@@ -10,7 +10,7 @@ import java.awt.image.SampleModel;
import java.awt.image.SinglePixelPackedSampleModel;
import java.awt.image.WritableRaster;
import mustic.utils.image.reader.ReaderWrapper;
import multiCube.tools.image.reader.ReaderWrapper;
/**
* Class that allows buffer manipulation and creation from images.
......
package mustic.utils.image;
import java.io.File;
import image.Image;
public class ImageHelper {
/**
* Remove extension from a file name
* @param str
* the file name
* @return the file name without extension
*/
public static String stripExtension (String str) {
// Handle null case specially.
if (str == null) return null;
// Get position of last '.'.
int pos = str.lastIndexOf(".");
// If there wasn't any '.' just return the string as is.
if (pos == -1) return str;
// Otherwise return the string, up to the dot.
return str.substring(0, pos);
}
/**
* Return the extension from a file name
* @param str
* the file name
* @return the file extension
*/
public static String getExtension (String str) {
// Handle null case specially.
if (str == null) return null;
// Get position of last '.'.
int pos = str.lastIndexOf(".");
// If there wasn't any '.' just return the string as is.
if (pos == -1) return "";
// Otherwise return the string, up to the dot.
return str.substring(pos, str.length());
}
/**
* Extract the file name from a path
* @param path
* the file full path
* @return the file name without extension
*/
public static String extractFileName (String path) {
// Handle null case specially.
if (path == null) return null;
// Get position of last '.'.
int pos = path.lastIndexOf(File.pathSeparator);
// If there wasn't any '.' just return the string as is.
if (pos == -1) return path;
// Otherwise return the string, up to the dot.
return path.substring(pos, path.length());
}
}
package mustic.utils.image.reader;
import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.io.IOException;
import java.util.Arrays;
import loci.formats.FormatException;
import loci.formats.FormatTools;
import loci.formats.ImageReader;
/**
* <p>
* Wrapper au dessus des fonctions de lecture d'image de la libraire
* bio-formats qui permet de lire les images par tuile.
* <p>
*
* @author Baptiste LAFABREGUE
*
*/
public class ImageReaderWrapper {
ImageReader reader = null;
int currentImageIndex = 0;
public ImageReaderWrapper() {
reader = new ImageReader();
}
/**
* <p>
* Definit l'image a utiliser
* <p>
*
* @param path
* le chemin d'acces de l'image
*
* @throws FormatException
* @throws IOException
*/
public void setImage(String path) throws FormatException, IOException {
reader.setId(path);
}
/**
* <p>
* Renvoi un tableau de byte qui contient pour chaque coordonnee contient sa
* valeur sous la forme d'un tableau de byte pour une vue donnee de l'image.
* Format : byte[x][y][pixels]
*
* A noter que si les pixels font n bytes, les n premiers bytes seront pour la bande 1,
* les n suivant pour la bande 2, ect ..
* <p>
*
* @param x
* l'absisse du coin haut-gauche de la vue
* @param y
* l'ordonnee du coin haut-gauche de la vue
* @param w
* la largeur de la vue
* @param h
* la hauteur de la vue
* @return le tableau de byte contenant les valeus de la vue
*
* @throws IOException
* si il y a eu un probleme en lisant le fichier
* @throws FormatException
* si il y a eu un probleme en parsant les metadata du fichier
*/
public byte[][][] getPixels(int x, int y, int w, int h) throws FormatException, IOException {
byte[] rawData = reader.openBytes(currentImageIndex, x, y, w, h);
int channelCount = reader.getRGBChannelCount();
int pixelSize = reader.getBitsPerPixel()/8;
// test si on a bien le nombre attendu de pixels
if(rawData.length != w * h * channelCount * pixelSize) {
throw new IndexOutOfBoundsException("La taille du tableau de byte renvoye n'est pas celle attendue.");
}
int channelGap = rawData.length / channelCount;
byte[][][] result = new byte[w][h][channelCount*pixelSize];
int index = 0;
for(int j = 0 ; j < h ; j++) {
for(int i = 0 ; i < w ; i++) {
for(int c = 0 ; c < channelCount ; c++) {
for(int p = 0 ; p < pixelSize ; p++) {
result[i][j][c*pixelSize+p] = rawData[index+channelGap*c+p];
}
}
index++;
}
}
return result;
}
/**
* <p>
* Renvoi un tableau de byte qui contient pour chaque coordonnee sa
* valeur sous la forme d'un byte pour une vue donnee de l'image.
* L'image ne doit avoir qu'une seul bande avec un byte par pixel.
* Format : byte[x][y]
*
* <p>
*
* @param x
* l'absisse du coin haut-gauche de la vue
* @param y
* l'ordonnee du coin haut-gauche de la vue
* @param w
* la largeur de la vue
* @param h
* la hauteur de la vue
* @return le tableau de byte contenant les valeus de la vue
*
* @throws IOException
* si il y a eu un probleme en lisant le fichier
* @throws FormatException
* si il y a eu un probleme en parsant les metadata du fichier ou si
* l'image ne verifie pas les conditions d'une bande a 1 byte pixels
*/
public byte[][] get1BytePixels(int x, int y, int w, int h) throws FormatException, IOException {
int pixelSize = reader.getBitsPerPixel()/8;
int channelCount = reader.getRGBChannelCount();
if (pixelSize != 1 || channelCount != 1) {
throw new FormatException("The function get1BitPixels can only be called on images with "+
"only one chanel of one byte pixels.");
}
// test si on a bien qu'un seul byte par pixel et une seule bande sinon l'algorithme
byte[] rawData = reader.openBytes(currentImageIndex, x, y, w, h);
// test si on a bien le nombre attendu de pixels
if(rawData.length != w * h * channelCount * pixelSize) {
throw new IndexOutOfBoundsException("La taille du tableau de byte renvoye n'est pas celle attendue.");
}
byte[][] result = new byte[w][h];
int index = 0;
for(int j = 0 ; j < h ; j++) {
for(int i = 0 ; i < w ; i++) {
result[i][j] = rawData[index];
index++;
}
}
return result;
}
/**
* <p>
* Renvoi le nombre de bytes composant la valeur
* <p>
*
* @return le nombre de butes par pixel
*/
public int getBytesPerPixel() {
return reader.getBitsPerPixel()/8;
}
/**
* <p>
* Renvoi l'index d'image actuellement utilise
* <p>
*
* @return l'index d'image utilise
*/
public int getCurrentImageIndex() {
return currentImageIndex;
}
/**
* <p>
* Modifie l'image qui sera utilise pour les prochaines operations
* <p>
*