it.geosolutions.jaiext.lookup
Class LookupTable

java.lang.Object
  extended by it.geosolutions.jaiext.lookup.LookupTable
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
LookupTableByte, LookupTableInt, LookupTableShort, LookupTableUShort

public abstract class LookupTable
extends Object
implements Serializable

This abstract class defines the general methods of a LookupTable. This class contains all the table informations used by its direct subclasses for doing the lookup operation. The Constructor methods are called by all the 4 subclasses(one for every integral data type). The set/unsetROI() and set/unsetNoData() methods are used for setting or unsetting the ROI or No Data Range used by this table. ALl the get() methods are support methods used for retrieve table information in a faster way. Lookup(), lookupFloat() and lookupDouble() are 3 methods that return the table data associated with the selected input image. The lase method called lookup(Raster,WritableRaster,Rectangle) is abstract because its implementation depends on the subClass data type.

See Also:
Serialized Form

Field Summary
protected  DataBuffer data
          The table data.
protected  byte destinationNoDataByte
          Destination no data for Byte images
protected  double destinationNoDataDouble
          Destination no data for Double images
protected  float destinationNoDataFloat
          Destination no data for Float images
protected  int destinationNoDataInt
          Destination no data for Integer images
protected  short destinationNoDataShort
          Destination no data for Short/Ushort images
protected  boolean hasNoData
          Boolean indicating if the image contains No Data values
protected  boolean hasROI
          Boolean indicating if the image contains a ROI
protected  Range noData
          Range object containing no data values
protected  Rectangle roiBounds
          Rectangle containing roi bounds
protected  javax.media.jai.iterator.RandomIter roiIter
          Iterator used for iterating on the roi data
protected  javax.media.jai.PlanarImage srcROIImage
          ROI image
protected  int[] tableOffsets
          The band offset values
protected  boolean useROIAccessor
          Boolean indicating if Roi RasterAccessor must be used
 
Constructor Summary
protected LookupTable(byte[] data)
          Constructs a single-banded byte lookup table.
  LookupTable(byte[][] data)
          Constructs a multi-banded byte lookup table.
  LookupTable(byte[][] data, int offset)
          Constructs a multi-banded byte lookup table where all bands have the same index offset.
protected LookupTable(byte[][] data, int[] offsets)
          Constructs a multi-banded byte lookup table where each band has a different index offset.
protected LookupTable(byte[] data, int offset)
          Constructs a single-banded byte lookup table with an index offset.
protected LookupTable(double[] data)
          Constructs a single-banded double lookup table.
protected LookupTable(double[][] data)
          Constructs a multi-banded double lookup table.
protected LookupTable(double[][] data, int offset)
          Constructs a multi-banded double lookup table where all bands have the same index offset.
protected LookupTable(double[][] data, int[] offsets)
          Constructs a multi-banded double lookup table where each band has a different index offset.
protected LookupTable(double[] data, int offset)
          Constructs a single-banded double lookup table with an index offset.
protected LookupTable(float[] data)
          Constructs a single-banded float lookup table.
protected LookupTable(float[][] data)
          Constructs a multi-banded float lookup table.
protected LookupTable(float[][] data, int offset)
          Constructs a multi-banded float lookup table where all bands have the same index offset.
protected LookupTable(float[][] data, int[] offsets)
          Constructs a multi-banded float lookup table where each band has a different index offset.
protected LookupTable(float[] data, int offset)
          Constructs a single-banded float lookup table with an index offset.
protected LookupTable(int[] data)
          Constructs a single-banded int lookup table.
protected LookupTable(int[][] data)
          Constructs a multi-banded int lookup table.
protected LookupTable(int[][] data, int offset)
          Constructs a multi-banded int lookup table where all bands have the same index offset.
protected LookupTable(int[][] data, int[] offsets)
          Constructs a multi-banded int lookup table where each band has a different index offset.
protected LookupTable(int[] data, int offset)
          Constructs a single-banded int lookup table with an index offset.
protected LookupTable(short[][] data, boolean isUShort)
          Constructs a multi-banded short or unsigned short lookup table.
protected LookupTable(short[][] data, int[] offsets, boolean isUShort)
          Constructs a multi-banded short or unsigned short lookup table where each band has a different index offset.
protected LookupTable(short[][] data, int offset, boolean isUShort)
          Constructs a multi-banded short or unsigned short lookup table where all bands have the same index offset.
protected LookupTable(short[] data, boolean isUShort)
          Constructs a single-banded short or unsigned short lookup table.
protected LookupTable(short[] data, int offset, boolean isUShort)
          Constructs a single-banded short or unsigned short lookup table with an index offset.
 
Method Summary
 byte[][] getByteData()
          Returns the byte table data in array format, or null if the table's data type is not byte.
 byte[] getByteData(int band)
          Returns the byte table data of a specific band in array format, or null if the table's data type is not byte.
 DataBuffer getData()
          Returns the table data as a DataBuffer.
 int getDataType()
          Returns the data type of the table data.
 int getDestNumBands(int srcNumBands)
          Returns the number of bands of the destination image, based on the number of bands of the source image and lookup table.
 SampleModel getDestSampleModel(SampleModel srcSampleModel)
          Returns a SampleModel suitable for holding the output of a lookup operation on the source data described by a given SampleModel with this table.
 SampleModel getDestSampleModel(SampleModel srcSampleModel, int width, int height)
          Returns a SampleModel suitable for holding the output of a lookup operation on the source data described by a given SampleModel with this table.
 double[][] getDoubleData()
          Returns the double table data in array format, or null if the table's data type is not double.
 double[] getDoubleData(int band)
          Returns the double table data of a specific band in array format, or null if table's data type is not double.
 float[][] getFloatData()
          Returns the float table data in array format, or null if the table's data type is not float.
 float[] getFloatData(int band)
          Returns the float table data of a specific band in array format, or null if table's data type is not float.
 int[][] getIntData()
          Returns the integer table data in array format, or null if the table's data type is not int.
 int[] getIntData(int band)
          Returns the integer table data of a specific band in array format, or null if table's data type is not int.
 int getNumBands()
          Returns the number of bands of the table.
 int getNumEntries()
          Returns the number of entries per band of the table.
 int getOffset()
          Returns the index offset of entry 0 for the default band.
 int getOffset(int band)
          Returns the index offset of entry 0 for a specific band.
 int[] getOffsets()
          Returns the index offsets of entry 0 for all bands.
 short[][] getShortData()
          Returns the short table data in array format, or null if the table's data type is not short.
 short[] getShortData(int band)
          Returns the short table data of a specific band in array format, or null if the table's data type is not short.
protected  void initOffsets(int nbands, int offset)
          This method sets the same table offset for all the bands
protected  void initOffsets(int nbands, int[] offset)
          This method sets the table offset related to every band
 boolean isIntegralDataType(int dataType)
          Returns true if the specified data type is an integral data type, such as byte, ushort, short, or int.
 boolean isIntegralDataType(SampleModel sampleModel)
          Validates data type.
 int lookup(int band, int value)
          Performs lookup on a given value belonging to a given source band, and returns the result as an int.
protected abstract  void lookup(Raster source, WritableRaster dst, Rectangle rect, Raster roi)
          Abstract method for calculating the destination tile from the source tile and an eventual ROI raster
 double lookupDouble(int band, int value)
          Performs lookup on a given value belonging to a given source band, and returns the result as a double.
 float lookupFloat(int band, int value)
          Performs lookup on a given value belonging to a given source band, and returns the result as a float.
 void setDestinationNoData(double destinationNoData)
          This method sets destination no data used for No Data or ROI calculation
 void setNoDataRange(Range noData)
          No Data flag is set to true and no data range is taken
 void setROIparams(Rectangle roiBounds, javax.media.jai.iterator.RandomIter roiIter, javax.media.jai.PlanarImage srcROIImage, boolean useROIAccessor)
          ROI flag is set to true and the ROI fields are all filled
 void unsetNoData()
          No Data flag is set to false and no data range is set to null
 void unsetROI()
          ROI flag is set to flag and the ROI fields are all left empty
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

data

protected transient DataBuffer data
The table data.


tableOffsets

protected int[] tableOffsets
The band offset values


destinationNoDataByte

protected byte destinationNoDataByte
Destination no data for Byte images


destinationNoDataShort

protected short destinationNoDataShort
Destination no data for Short/Ushort images


destinationNoDataInt

protected int destinationNoDataInt
Destination no data for Integer images


destinationNoDataFloat

protected float destinationNoDataFloat
Destination no data for Float images


destinationNoDataDouble

protected double destinationNoDataDouble
Destination no data for Double images


noData

protected Range noData
Range object containing no data values


roiBounds

protected Rectangle roiBounds
Rectangle containing roi bounds


roiIter

protected javax.media.jai.iterator.RandomIter roiIter
Iterator used for iterating on the roi data


useROIAccessor

protected boolean useROIAccessor
Boolean indicating if Roi RasterAccessor must be used


srcROIImage

protected javax.media.jai.PlanarImage srcROIImage
ROI image


hasNoData

protected boolean hasNoData
Boolean indicating if the image contains No Data values


hasROI

protected boolean hasROI
Boolean indicating if the image contains a ROI

Constructor Detail

LookupTable

protected LookupTable(byte[] data)
Constructs a single-banded byte lookup table. The index offset is 0.

Parameters:
data - The single-banded byte data.
Throws:
IllegalArgumentException - if data is null.

LookupTable

protected LookupTable(byte[] data,
                      int offset)
Constructs a single-banded byte lookup table with an index offset.

Parameters:
data - The single-banded byte data.
offset - The offset.
Throws:
IllegalArgumentException - if data is null.

LookupTable

public LookupTable(byte[][] data)
Constructs a multi-banded byte lookup table. The index offset for each band is 0.

Parameters:
data - The multi-banded byte data in [band][index] format.
Throws:
IllegalArgumentException - if data is null.

LookupTable

public LookupTable(byte[][] data,
                   int offset)
Constructs a multi-banded byte lookup table where all bands have the same index offset.

Parameters:
data - The multi-banded byte data in [band][index] format.
offset - The common offset for all bands.
Throws:
IllegalArgumentException - if data is null.

LookupTable

protected LookupTable(byte[][] data,
                      int[] offsets)
Constructs a multi-banded byte lookup table where each band has a different index offset.

Parameters:
data - The multi-banded byte data in [band][index] format.
offsets - The offsets for the bands.
Throws:
IllegalArgumentException - if data is null.

LookupTable

protected LookupTable(short[] data,
                      boolean isUShort)
Constructs a single-banded short or unsigned short lookup table. The index offset is 0.

Parameters:
data - The single-banded short data.
isUShort - True if data type is DataBuffer.TYPE_USHORT; false if data type is DataBuffer.TYPE_SHORT.
Throws:
IllegalArgumentException - if data is null.

LookupTable

protected LookupTable(short[] data,
                      int offset,
                      boolean isUShort)
Constructs a single-banded short or unsigned short lookup table with an index offset.

Parameters:
data - The single-banded short data.
offset - The offset.
isUShort - True if data type is DataBuffer.TYPE_USHORT; false if data type is DataBuffer.TYPE_SHORT.
Throws:
IllegalArgumentException - if data is null.

LookupTable

protected LookupTable(short[][] data,
                      boolean isUShort)
Constructs a multi-banded short or unsigned short lookup table. The index offset for each band is 0.

Parameters:
data - The multi-banded short data in [band][index] format.
isUShort - True if data type is DataBuffer.TYPE_USHORT; false if data type is DataBuffer.TYPE_SHORT.
Throws:
IllegalArgumentException - if data is null.

LookupTable

protected LookupTable(short[][] data,
                      int offset,
                      boolean isUShort)
Constructs a multi-banded short or unsigned short lookup table where all bands have the same index offset.

Parameters:
data - The multi-banded short data in [band][index] format.
offset - The common offset for all bands.
isUShort - True if data type is DataBuffer.TYPE_USHORT; false if data type is DataBuffer.TYPE_SHORT.
Throws:
IllegalArgumentException - if data is null.

LookupTable

protected LookupTable(short[][] data,
                      int[] offsets,
                      boolean isUShort)
Constructs a multi-banded short or unsigned short lookup table where each band has a different index offset.

Parameters:
data - The multi-banded short data in [band][index] format.
offsets - The offsets for the bands.
isUShort - True if data type is DataBuffer.TYPE_USHORT; false if data type is DataBuffer.TYPE_SHORT.
Throws:
IllegalArgumentException - if data is null.

LookupTable

protected LookupTable(int[] data)
Constructs a single-banded int lookup table. The index offset is 0.

Parameters:
data - The single-banded int data.
Throws:
IllegalArgumentException - if data is null.

LookupTable

protected LookupTable(int[] data,
                      int offset)
Constructs a single-banded int lookup table with an index offset.

Parameters:
data - The single-banded int data.
offset - The offset.
Throws:
IllegalArgumentException - if data is null.

LookupTable

protected LookupTable(int[][] data)
Constructs a multi-banded int lookup table. The index offset for each band is 0.

Parameters:
data - The multi-banded int data in [band][index] format.
Throws:
IllegalArgumentException - if data is null.

LookupTable

protected LookupTable(int[][] data,
                      int offset)
Constructs a multi-banded int lookup table where all bands have the same index offset.

Parameters:
data - The multi-banded int data in [band][index] format.
offset - The common offset for all bands.
Throws:
IllegalArgumentException - if data is null.

LookupTable

protected LookupTable(int[][] data,
                      int[] offsets)
Constructs a multi-banded int lookup table where each band has a different index offset.

Parameters:
data - The multi-banded int data in [band][index] format.
offsets - The offsets for the bands.
Throws:
IllegalArgumentException - if data is null.

LookupTable

protected LookupTable(float[] data)
Constructs a single-banded float lookup table. The index offset is 0.

Parameters:
data - The single-banded float data.
Throws:
IllegalArgumentException - if data is null.

LookupTable

protected LookupTable(float[] data,
                      int offset)
Constructs a single-banded float lookup table with an index offset.

Parameters:
data - The single-banded float data.
offset - The offset.
Throws:
IllegalArgumentException - if data is null.

LookupTable

protected LookupTable(float[][] data)
Constructs a multi-banded float lookup table. The index offset for each band is 0.

Parameters:
data - The multi-banded float data in [band][index] format.
Throws:
IllegalArgumentException - if data is null.

LookupTable

protected LookupTable(float[][] data,
                      int offset)
Constructs a multi-banded float lookup table where all bands have the same index offset.

Parameters:
data - The multi-banded float data in [band][index] format.
offset - The common offset for all bands.
Throws:
IllegalArgumentException - if data is null.

LookupTable

protected LookupTable(float[][] data,
                      int[] offsets)
Constructs a multi-banded float lookup table where each band has a different index offset.

Parameters:
data - The multi-banded float data in [band][index] format.
offsets - The offsets for the bands.
Throws:
IllegalArgumentException - if data is null.

LookupTable

protected LookupTable(double[] data)
Constructs a single-banded double lookup table. The index offset is 0.

Parameters:
data - The single-banded double data.
Throws:
IllegalArgumentException - if data is null.

LookupTable

protected LookupTable(double[] data,
                      int offset)
Constructs a single-banded double lookup table with an index offset.

Parameters:
data - The single-banded double data.
offset - The offset.
Throws:
IllegalArgumentException - if data is null.

LookupTable

protected LookupTable(double[][] data)
Constructs a multi-banded double lookup table. The index offset for each band is 0.

Parameters:
data - The multi-banded double data in [band][index] format.
Throws:
IllegalArgumentException - if data is null.

LookupTable

protected LookupTable(double[][] data,
                      int offset)
Constructs a multi-banded double lookup table where all bands have the same index offset.

Parameters:
data - The multi-banded double data in [band][index] format.
offset - The common offset for all bands.
Throws:
IllegalArgumentException - if data is null.

LookupTable

protected LookupTable(double[][] data,
                      int[] offsets)
Constructs a multi-banded double lookup table where each band has a different index offset.

Parameters:
data - The multi-banded double data in [band][index] format.
offsets - The offsets for the bands.
Throws:
IllegalArgumentException - if data is null.
Method Detail

getData

public DataBuffer getData()
Returns the table data as a DataBuffer.


getByteData

public byte[][] getByteData()
Returns the byte table data in array format, or null if the table's data type is not byte.


getByteData

public byte[] getByteData(int band)
Returns the byte table data of a specific band in array format, or null if the table's data type is not byte.


getShortData

public short[][] getShortData()
Returns the short table data in array format, or null if the table's data type is not short. This includes both signed and unsigned short table data.


getShortData

public short[] getShortData(int band)
Returns the short table data of a specific band in array format, or null if the table's data type is not short.


getIntData

public int[][] getIntData()
Returns the integer table data in array format, or null if the table's data type is not int.


getIntData

public int[] getIntData(int band)
Returns the integer table data of a specific band in array format, or null if table's data type is not int.


getFloatData

public float[][] getFloatData()
Returns the float table data in array format, or null if the table's data type is not float.


getFloatData

public float[] getFloatData(int band)
Returns the float table data of a specific band in array format, or null if table's data type is not float.


getDoubleData

public double[][] getDoubleData()
Returns the double table data in array format, or null if the table's data type is not double.


getDoubleData

public double[] getDoubleData(int band)
Returns the double table data of a specific band in array format, or null if table's data type is not double.


getOffsets

public int[] getOffsets()
Returns the index offsets of entry 0 for all bands.


getOffset

public int getOffset()
Returns the index offset of entry 0 for the default band.


getOffset

public int getOffset(int band)
Returns the index offset of entry 0 for a specific band.


getNumBands

public int getNumBands()
Returns the number of bands of the table.


getNumEntries

public int getNumEntries()
Returns the number of entries per band of the table.


getDataType

public int getDataType()
Returns the data type of the table data.


getDestNumBands

public int getDestNumBands(int srcNumBands)
Returns the number of bands of the destination image, based on the number of bands of the source image and lookup table.

Parameters:
srcNumBands - The number of bands of the source image.
Returns:
the number of bands in destination image.

getDestSampleModel

public SampleModel getDestSampleModel(SampleModel srcSampleModel)
Returns a SampleModel suitable for holding the output of a lookup operation on the source data described by a given SampleModel with this table. The width and height of the destination SampleModel are the same as that of the source. This method will return null if the source SampleModel has a non-integral data type.

Parameters:
srcSampleModel - The SampleModel of the source image.
Returns:
sampleModel suitable for the destination image.
Throws:
IllegalArgumentException - if srcSampleModel is null.

getDestSampleModel

public SampleModel getDestSampleModel(SampleModel srcSampleModel,
                                      int width,
                                      int height)
Returns a SampleModel suitable for holding the output of a lookup operation on the source data described by a given SampleModel with this table. This method will return null if the source SampleModel has a non-integral data type.

Parameters:
srcSampleModel - The SampleModel of the source image.
width - The width of the destination SampleModel.
height - The height of the destination SampleModel.
Returns:
sampleModel suitable for the destination image.
Throws:
IllegalArgumentException - if srcSampleModel is null.

isIntegralDataType

public boolean isIntegralDataType(SampleModel sampleModel)
Validates data type. Returns true if it's one of the integral data types; false otherwise.

Throws:
IllegalArgumentException - if sampleModel is null.

isIntegralDataType

public boolean isIntegralDataType(int dataType)
Returns true if the specified data type is an integral data type, such as byte, ushort, short, or int.


lookup

public int lookup(int band,
                  int value)
Performs lookup on a given value belonging to a given source band, and returns the result as an int. NoData Range or ROI are not considered.

Parameters:
band - The source band the value is from.
value - The source value to be placed through the lookup table.

lookupFloat

public float lookupFloat(int band,
                         int value)
Performs lookup on a given value belonging to a given source band, and returns the result as a float. NoData Range or ROI are not considered.

Parameters:
band - The source band the value is from.
value - The source value to be placed through the lookup table.

lookupDouble

public double lookupDouble(int band,
                           int value)
Performs lookup on a given value belonging to a given source band, and returns the result as a double. NoData Range or ROI are not considered.

Parameters:
band - The source band the value is from.
value - The source value to be placed through the lookup table.

initOffsets

protected void initOffsets(int nbands,
                           int offset)
This method sets the same table offset for all the bands


initOffsets

protected void initOffsets(int nbands,
                           int[] offset)
This method sets the table offset related to every band


setDestinationNoData

public void setDestinationNoData(double destinationNoData)
This method sets destination no data used for No Data or ROI calculation


setNoDataRange

public void setNoDataRange(Range noData)
No Data flag is set to true and no data range is taken


unsetNoData

public void unsetNoData()
No Data flag is set to false and no data range is set to null


setROIparams

public void setROIparams(Rectangle roiBounds,
                         javax.media.jai.iterator.RandomIter roiIter,
                         javax.media.jai.PlanarImage srcROIImage,
                         boolean useROIAccessor)
ROI flag is set to true and the ROI fields are all filled


unsetROI

public void unsetROI()
ROI flag is set to flag and the ROI fields are all left empty


lookup

protected abstract void lookup(Raster source,
                               WritableRaster dst,
                               Rectangle rect,
                               Raster roi)
Abstract method for calculating the destination tile from the source tile and an eventual ROI raster



Copyright © 2006–2015 GeoSolutions. All rights reserved.