|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.geotools.image.io.SampleConverter
public abstract class SampleConverter
Converts samples from the values stored in the image file to the values stored in the raster. Some typical conversions are:
NaN
if the target type is
float
or double
, or 0 if the target type is an integer.
Note that pad values are replaced by 0 in the integer case, not by an arbitrary number,
because 0 is the result of (int) NaN
cast. While not mandatory, this property
make some mathematics faster during conversions between geophysics and
display views in the coverage module.
There is no scaling because this class is not for samples to geophysics values
conversions (except the replacement of pad values by NaN
). This class is
about the minimal changes needed in order to comply to the contraints of a target
color model, e.g. for working around negative numbers.
Sample converters work on int
, float
or double
primitive types,
which match the primitive types expected by the Raster
API.
Field Summary | |
---|---|
static SampleConverter |
IDENTITY
A sample converter that do not performs any conversion. |
Constructor Summary | |
---|---|
protected |
SampleConverter()
Constructs a sample converter. |
Method Summary | |
---|---|
abstract double |
convert(double value)
Converts a double-precision value before to store it in the raster. |
abstract float |
convert(float value)
Converts a float-precision value before to store it in the raster. |
abstract int |
convert(int value)
Converts a float-precision value before to store it in the raster. |
static SampleConverter |
createOffset(double offset,
double padValue)
Creates a sample converter that replaces a pad value by NaN or
0 , and applies an offset on all other values. |
static SampleConverter |
createOffset(double offset,
double[] padValues)
Creates a sample converter that replaces an arbitrary amount of pad values by NaN or 0 , and applies an offset on all other values. |
static SampleConverter |
createPadValueMask(double padValue)
Creates a sample converter that replaces a single pad value by NaN
for floating point numbers, or 0 for integers. |
static SampleConverter |
createPadValuesMask(double[] padValues)
Creates a sample converter that replaces an arbitrary amount of pad values by NaN for floating point numbers, or 0 for integers. |
double |
getOffset()
If this converter applies an offset, returns the offset. |
java.lang.String |
toString()
Returns a string representation of this sample converter. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final SampleConverter IDENTITY
Constructor Detail |
---|
protected SampleConverter()
Method Detail |
---|
public static SampleConverter createPadValueMask(double padValue)
NaN
for floating point numbers, or 0
for integers.
padValue
- The pad values to replace by NaN
or 0
.public static SampleConverter createPadValuesMask(double[] padValues)
NaN
for floating point numbers, or 0
for integers.
padValue
- The pad values to replace by NaN
or 0
,
or null
if none.public static SampleConverter createOffset(double offset, double padValue)
NaN
or
0
, and applies an offset on all other values. This is typically used in
order to shift a range of arbitrary (including negative) integer values to a range
of strictly positive values. The later is more manageable by
index color model.
An
- offset to add to the values to be read, before to store them in the raster. This
is used primarily for transforming signed short into unsigned short.padValue
- The pad value to replace. This the value before the offset is applied.public static SampleConverter createOffset(double offset, double[] padValues)
NaN
or 0
, and applies an offset on all other values.
An
- offset to add to the values to be read, before to store them in the raster.padValue
- The pad values to replace. They the values before the offset is applied.public abstract double convert(double value)
Double.NaN
value.
value
- The value read from the image file.
public abstract float convert(float value)
Float.NaN
value.
value
- The value read from the image file.
public abstract int convert(int value)
value
- The value read from the image file.
public double getOffset()
public java.lang.String toString()
toString
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |