Class PhotometricInterpreterFloat
- java.lang.Object
-
- org.apache.commons.imaging.formats.tiff.photometricinterpreters.PhotometricInterpreter
-
- org.apache.commons.imaging.formats.tiff.photometricinterpreters.floatingpoint.PhotometricInterpreterFloat
-
public class PhotometricInterpreterFloat extends PhotometricInterpreter
Implements a custom photometric interpreter that can be supplied by applications in order to render Java images from real-valued TIFF data products. Most TIFF files include a specification for a "photometric interpreter" that implements logic for transforming the raw data in a TIFF file to a rendered image. But the TIFF standard does not include a specification for a photometric interpreter that can be used for rendering floating-point data. TIFF files are sometimes used to specify non-image data as a floating-point raster. This approach is particularly common in GeoTIFF files (TIFF files that contain tags for supporting geospatial reference metadata for Geographic Information Systems). Because of the limits of the stock photometric interpreters, most floating-point TIFF files to not produce useful images.This class allows an Apache Commons implementation to construct and specify a custom photometric interpreter when reading from a TIFF file. Applications may supply their own palette that maps real-valued data to specified colors.
This class provides two constructors:
- A simple constructor to support gray scales
- A constructor to support a color palette (with potential interpolation)
To use this class, an application must access the TIFF file using the low-level, TIFF-specific API provided by the Apache Commons Imaging library.
-
-
Field Summary
-
Fields inherited from class org.apache.commons.imaging.formats.tiff.photometricinterpreters.PhotometricInterpreter
height, predictor, samplesPerPixel, width
-
-
Constructor Summary
Constructors Constructor Description PhotometricInterpreterFloat(float valueBlack, float valueWhite)
Constructs a photometric interpreter that will produce a gray scale linearly distributed across the RGB color space for values in the range valueBlack to valueWhite.PhotometricInterpreterFloat(List<PaletteEntry> paletteEntries)
Constructs a photometric interpreter that will use the specified palette to assign colors to floating-point values.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description float
getMaxFound()
Gets the maximum value found while rendering the imageint[]
getMaxXY()
Gets the coordinates (x,y) at which the maximum value was identified during processingfloat
getMeanFound()
Get the mean of the values found while processingfloat
getMinFound()
Gets the minimum value found while rendering the imageint[]
getMinXY()
Gets the coordinates (x,y) at which the minimum value was identified during processingvoid
interpretPixel(ImageBuilder imageBuilder, int[] samples, int x, int y)
int
mapValueToARGB(float f)
Provides a method for mapping a pixel value to an integer (ARGB) value.-
Methods inherited from class org.apache.commons.imaging.formats.tiff.photometricinterpreters.PhotometricInterpreter
getBitsPerSample
-
-
-
-
Constructor Detail
-
PhotometricInterpreterFloat
public PhotometricInterpreterFloat(float valueBlack, float valueWhite)
Constructs a photometric interpreter that will produce a gray scale linearly distributed across the RGB color space for values in the range valueBlack to valueWhite. Note that the two values may be given in either ascending order or descending order, but they must not be equal. Infinite values will not result in proper numerical computations.- Parameters:
valueBlack
- the value associated with the dark side of the gray scalevalueWhite
- the value associated with the light side of the gray scale
-
PhotometricInterpreterFloat
public PhotometricInterpreterFloat(List<PaletteEntry> paletteEntries)
Constructs a photometric interpreter that will use the specified palette to assign colors to floating-point values.Although there is no prohibition against using palette entries with overlapping ranges, the behavior of such specifications is undefined and subject to change in the future. Therefore, it is not recommended. The exception in in the use of single-value palette entries which may be used to override the specifications for ranges.
- Parameters:
paletteEntries
- a valid, non-empty list of palette entries
-
-
Method Detail
-
interpretPixel
public void interpretPixel(ImageBuilder imageBuilder, int[] samples, int x, int y) throws ImageReadException, IOException
- Specified by:
interpretPixel
in classPhotometricInterpreter
- Throws:
ImageReadException
IOException
-
getMinFound
public float getMinFound()
Gets the minimum value found while rendering the image- Returns:
- if data was processed, a valid value; otherwise, Positive Infinity
-
getMaxXY
public int[] getMaxXY()
Gets the coordinates (x,y) at which the maximum value was identified during processing- Returns:
- a valid array of length 2.
-
getMaxFound
public float getMaxFound()
Gets the maximum value found while rendering the image- Returns:
- if data was processed, a valid value; otherwise, Negative Infinity
-
getMinXY
public int[] getMinXY()
Gets the coordinates (x,y) at which the minimum value was identified during processing- Returns:
- a valid array of length 2.
-
getMeanFound
public float getMeanFound()
Get the mean of the values found while processing- Returns:
- if data was processed, a valid mean value; otherwise, a zero.
-
mapValueToARGB
public int mapValueToARGB(float f)
Provides a method for mapping a pixel value to an integer (ARGB) value. This method is not defined for the standard photometric interpreters and is provided as a convenience to applications that are processing data outside the standard TIFF image-reading modules.- Parameters:
f
- the floating point value to be mapped to an ARGB value- Returns:
- a valid ARGB value, or zero if no palette specification covers the input value.
-
-