Package org.apache.commons.imaging.formats.tiff

## Class TiffRasterDataFloat

- java.lang.Object
- - org.apache.commons.imaging.formats.tiff.TiffRasterData
  - - org.apache.commons.imaging.formats.tiff.TiffRasterDataFloat

-     public class TiffRasterDataFloat
      extends 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.

  Note: The getData() and getIntData() methods can return direct references to the internal arrays stored in instances of this class. Because these are not safe copies of the data, an application that modified the arrays returned by these methods will change the content of the associated instance. This approach is used for purposes of efficiency when dealing with very large TIFF images.

  Data layout: The elements in the returned array are stored in row-major order. In cases where the data contains multiple samples per raster cell (pixel), the data is organized into blocks of data one sample at a time. The first block contains width*height values for the first sample for each cell, the second block contains width*height values for the second sample for each cell, etc. Thus, the array index for a particular value is computed as

          index = y*width + x + iSample * width *height;

- - ### Field Summary

    - ### Fields inherited from class org.apache.commons.imaging.formats.tiff.TiffRasterData

      `height, nCells, planarOffset, samplesPerPixel, width`

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `TiffRasterDataFloat​(int width, int height)` | Construct an instance allocating memory for the specified dimensions.
    `TiffRasterDataFloat​(int width, int height, float[] data)` | Construct an instance allocating memory for the specified dimensions.
    `TiffRasterDataFloat​(int width, int height, int samplesPerPixel)` | Construct an instance allocating memory for the specified dimensions.
    `TiffRasterDataFloat​(int width, int height, int samplesPerCell, float[] data)` | Construct an instance allocating memory for the specified dimensions.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `float[]` | `getData()` | Returns a reference to the data array stored in this instance.
    `TiffRasterDataType` | `getDataType()` | Gets the raster data type from the instance.
    `int[]` | `getIntData()` | Returns an array of integer approximations for the floating-point content stored as an array in this instance.
    `int` | `getIntValue​(int x, int y)` | Gets the value stored at the specified raster coordinates.
    `int` | `getIntValue​(int x, int y, int i)` | Gets the value stored at the specified raster coordinates.
    `TiffRasterStatistics` | `getSimpleStatistics()` | Tabulates simple statistics for the raster and returns an instance containing general metadata.
    `TiffRasterStatistics` | `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.
    `float` | `getValue​(int x, int y, int i)` | Gets the value stored at the specified raster coordinates.
    `void` | `setIntValue​(int x, int y, int value)` | Sets the value stored at the specified raster coordinates.
    `void` | `setIntValue​(int x, int y, int i, int value)` | Sets the value stored at the specified raster coordinates.
    `void` | `setValue​(int x, int y, float value)` | Sets the value stored at the specified raster coordinates.
    `void` | `setValue​(int x, int y, int i, float value)` | Sets the value stored at the specified raster coordinates.

    - ### Methods inherited from class org.apache.commons.imaging.formats.tiff.TiffRasterData

      `checkCoordinatesAndComputeIndex, getHeight, getSamplesPerPixel, getWidth`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### TiffRasterDataFloat

          public TiffRasterDataFloat​(int width,
                                     int height)

      Construct an instance allocating memory for the specified dimensions.
      Parameters:
        `width` - a value of 1 or greater
        `height` - a value of 1 or greater

    - #### TiffRasterDataFloat

          public TiffRasterDataFloat​(int width,
                                     int height,
                                     int samplesPerPixel)

      Construct an instance allocating memory for the specified dimensions.
      Parameters:
        `width` - a value of 1 or greater
        `height` - a value of 1 or greater
        `samplesPerPixel` - a value of 1 or greater

    - #### TiffRasterDataFloat

          public TiffRasterDataFloat​(int width,
                                     int height,
                                     float[] data)

      Construct an instance allocating memory for the specified dimensions.
      Parameters:
        `width` - a value of 1 or greater
        `height` - a value of 1 or greater
        `data` - the data to be stored in the raster.

    - #### TiffRasterDataFloat

          public TiffRasterDataFloat​(int width,
                                     int height,
                                     int samplesPerCell,
                                     float[] data)

      Construct an instance allocating memory for the specified dimensions.
      Parameters:
        `width` - a value of 1 or greater
        `height` - a value of 1 or greater
        `samplesPerCell` - the number of samples per pixel
        `data` - the data to be stored in the raster.

  - ### Method Detail

    - #### getDataType

          public TiffRasterDataType getDataType()

      Gets the raster data type from the instance.
      Specified by:
        `getDataType` in class `TiffRasterData`
      Returns:
        a value of TiffRasterDataType.FLOAT.

    - #### setValue

          public void setValue​(int x,
                               int y,
                               float value)

      Sets the value stored at the specified raster coordinates.
      Specified by:
        `setValue` in class `TiffRasterData`
      Parameters:
        `x` - integer coordinate in the columnar direction
        `y` - integer coordinate in the row direction
        `value` - the value to be stored at the specified location; potentially a Float.NaN.

    - #### setValue

          public void setValue​(int x,
                               int y,
                               int i,
                               float value)

      Sets the value stored at the specified raster coordinates.
      Specified by:
        `setValue` in class `TiffRasterData`
      Parameters:
        `x` - integer coordinate in the columnar direction
        `y` - integer coordinate in the row direction
        `i` - integer sample index (for data sets giving multiple samples per raster cell).
        `value` - 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.
      Specified by:
        `getValue` in class `TiffRasterData`
      Parameters:
        `x` - integer coordinate in the columnar direction
        `y` - integer coordinate in the row direction
      Returns:
        the value stored at the specified location; potentially a Float.NaN.

    - #### getValue

          public float getValue​(int x,
                                int y,
                                int i)

      Gets the value stored at the specified raster coordinates.
      Specified by:
        `getValue` in class `TiffRasterData`
      Parameters:
        `x` - integer coordinate in the columnar direction
        `y` - integer coordinate in the row direction
        `i` - integer sample index (for data sets giving multiple samples per raster cell).
      Returns:
        the value stored at the specified location; potentially a Float.NaN.

    - #### setIntValue

          public void setIntValue​(int x,
                                  int y,
                                  int value)

      Sets the value stored at the specified raster coordinates.
      Specified by:
        `setIntValue` in class `TiffRasterData`
      Parameters:
        `x` - integer coordinate in the columnar direction
        `y` - integer coordinate in the row direction
        `value` - the value to be stored at the specified location

    - #### setIntValue

          public void setIntValue​(int x,
                                  int y,
                                  int i,
                                  int value)

      Sets the value stored at the specified raster coordinates.
      Specified by:
        `setIntValue` in class `TiffRasterData`
      Parameters:
        `x` - integer coordinate in the columnar direction
        `y` - integer coordinate in the row direction
        `i` - integer sample index (for data sets giving multiple samples per raster cell).
        `value` - the value to be stored at the specified location

    - #### getIntValue

          public int getIntValue​(int x,
                                 int y)

      Gets the value stored at the specified raster coordinates.
      Specified by:
        `getIntValue` in class `TiffRasterData`
      Parameters:
        `x` - integer coordinate in the columnar direction
        `y` - integer coordinate in the row direction
      Returns:
        the value stored at the specified location

    - #### getIntValue

          public int getIntValue​(int x,
                                 int y,
                                 int i)

      Gets the value stored at the specified raster coordinates.
      Specified by:
        `getIntValue` in class `TiffRasterData`
      Parameters:
        `x` - integer coordinate in the columnar direction
        `y` - integer coordinate in the row direction
        `i` - integer sample index (for data sets giving multiple samples per raster cell).
      Returns:
        the value stored at the specified location

    - #### getSimpleStatistics

          public TiffRasterStatistics getSimpleStatistics()

      Tabulates simple statistics for the raster and returns an instance containing general metadata.
      Specified by:
        `getSimpleStatistics` in class `TiffRasterData`
      Returns:
        a valid instance containing a safe copy of the current simple statistics for the raster.

    - #### getSimpleStatistics

          public TiffRasterStatistics getSimpleStatistics​(float valueToExclude)

      Tabulates simple statistics for the raster excluding the specified value and returns an instance containing general metadata.
      Specified by:
        `getSimpleStatistics` in class `TiffRasterData`
      Parameters:
        `valueToExclude` - exclude samples with this specified value.
      Returns:
        a valid instance.

    - #### getData

          public float[] getData()

      Returns a reference to the data array stored in this instance. Note that the array returned is not a safe copy and that modifying it directly affects 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.

      See the class API documentation above for notes on accessing array elements.

      Specified by:
        `getData` in class `TiffRasterData`
      Returns:
        a direct reference to the data array stored in this instance.

    - #### getIntData

          public int[] getIntData()

      Returns an array of integer approximations for the floating-point content stored as an array in this instance.

      See the class API documentation above for notes on accessing array elements.

      Specified by:
        `getIntData` in class `TiffRasterData`
      Returns:
        the integer equivalents to the data content stored in this instance.