Class TiffRasterData
java.lang.Object
org.apache.commons.imaging.formats.tiff.TiffRasterData
Provides a simple container for floating-point data. Some TIFF files are used
to store floating-point data rather than images. This class is intended to
support access to those TIFF files.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionTiffRasterData
(int width, int height) Construct an instance allocating memory for the specified dimensions.TiffRasterData
(int width, int height, float[] data) Construct an instance allocating memory for the specified dimensions. -
Method Summary
Modifier and TypeMethodDescriptionfloat[]
getData()
Returns a reference to the data array stored in this instance.int
Gets the height (number of rows) of the raster.Tabulates simple statistics for the raster and returns an instance containing general metadata.getSimpleStatistics
(float valueToExclude) Tabulates simple statistics for the raster excluding the specified value and returns an instance containing general metadata.float
getValue
(int x, int y) Gets the value stored at the specified raster coordinates.int
getWidth()
Gets the width (number of columns) of the raster.void
setValue
(int x, int y, float value) Sets the value stored at the specified raster coordinates.
-
Field Details
-
width
private final int width -
height
private final int height -
data
private final float[] data
-
-
Constructor Details
-
TiffRasterData
public TiffRasterData(int width, int height) Construct an instance allocating memory for the specified dimensions.- Parameters:
width
- a value of 1 or greaterheight
- a value of 1 or greater
-
TiffRasterData
public TiffRasterData(int width, int height, float[] data) Construct an instance allocating memory for the specified dimensions.- Parameters:
width
- a value of 1 or greaterheight
- a value of 1 or greaterdata
- the data to be stored in the raster.
-
-
Method Details
-
setValue
public void setValue(int x, int y, float value) Sets the value stored at the specified raster coordinates.- Parameters:
x
- integer coordinate in the columnar directiony
- integer coordinate in the row directionvalue
- the value to be stored at the specified location; potentially a Float.NaN.
-
getValue
public float getValue(int x, int y) Gets the value stored at the specified raster coordinates.- Parameters:
x
- integer coordinate in the columnar directiony
- integer coordinate in the row direction- Returns:
- the value stored at the specified location; potentially a Float.NaN.
-
getSimpleStatistics
Tabulates simple statistics for the raster and returns an instance containing general metadata.- Returns:
- a valid instance containing a safe copy of the current simple statistics for the raster.
-
getSimpleStatistics
Tabulates simple statistics for the raster excluding the specified value and returns an instance containing general metadata.- Parameters:
valueToExclude
- exclude samples with this specified value.- Returns:
- a valid instance.
-
getWidth
public int getWidth()Gets the width (number of columns) of the raster.- Returns:
- the width of the raster
-
getHeight
public int getHeight()Gets the height (number of rows) of the raster.- Returns:
- the height of the raster.
-
getData
public float[] getData()Returns a reference to the data array stored in this instance. Note that value is not a safe copy and that modifying it would directly affect the content of the instance. While this design approach carries some risk in terms of data security, it was chosen for reasons of performance and memory conservation. TIFF images that contain floating-point data are often quite large. Sizes of 100 million raster cells are common. Making a redundant copy of such a large in-memory object might exceed the resources available to a Java application.- Returns:
- a direct reference to the data array stored in this instance.
-