|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
ObjectSampleConverter
@Immutable 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 constraints of a target
color model, for example in order to workaround
the fact that IndexColorModel does not accept negative numbers.
SampleConverters are typically created and used by the SpatialImageReader
class and subclasses. They are created (directly or indirectly) by the
getImageType method and used by the
read method.
SampleConversionType
| coverage/geotk-coverageio (download) | View source code for this class |
| 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. |
void |
convert(double[] values,
int offset,
int length)
Converts in-place an array of double-precision values. |
abstract float |
convert(float value)
Converts a float-precision value before to store it in the raster. |
void |
convert(float[] values,
int offset,
int length)
Converts in-place an array of single-precision values. |
abstract int |
convert(int value)
Converts a float-precision value before to store it in the raster. |
void |
convert(int[] values,
int offset,
int length)
Converts in-place an array of integer values. |
void |
convert(short[] values,
int offset,
int length)
Converts in-place an array of short values. |
void |
convertUnsigned(byte[] values,
int offset,
int length)
Converts in-place an array of unsigned byte values. |
void |
convertUnsigned(short[] values,
int offset,
int length)
Converts in-place an array of unsigned short values. |
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. |
String |
toString()
Returns a string representation of this sample converter. |
| Methods inherited from class 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.
padValues - 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.
offset - 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.
offset - An offset to add to the values to be read, before to store them in the raster.padValues - 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 void convert(double[] values,
int offset,
int length)
values - The values to convert.offset - Index of the first sample to convert.length - Number of samples to convert.
public void convert(float[] values,
int offset,
int length)
values - The values to convert.offset - Index of the first sample to convert.length - Number of samples to convert.
public void convert(int[] values,
int offset,
int length)
values - The values to convert.offset - Index of the first sample to convert.length - Number of samples to convert.
public void convert(short[] values,
int offset,
int length)
values - The values to convert.offset - Index of the first sample to convert.length - Number of samples to convert.
public void convertUnsigned(short[] values,
int offset,
int length)
values - The values to convert.offset - Index of the first sample to convert.length - Number of samples to convert.
public void convertUnsigned(byte[] values,
int offset,
int length)
values - The values to convert.offset - Index of the first sample to convert.length - Number of samples to convert.public double getOffset()
public String toString()
toString in class Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||