Class TransferFunction
java.lang.Object
org.apache.sis.referencing.operation.transform.TransferFunction
- All Implemented Interfaces:
Serializable
,Cloneable
The function converting raster sample values to geophysics values.
The function is usually linear, but can sometimes be logarithmic or exponential.
The latter occur most often when measuring concentration of something.
Type | Equation |
---|---|
LINEAR |
y = scale⋅x + offset |
LOGARITHMIC |
y = scale⋅logbase(x) + offset |
EXPONENTIAL |
y = scale⋅basex + offset |
Missing values
ThisTransferFunction
class handles only the continuous part of transfer functions.
This class does not handle missing values other than NaN
.
For a more complete class with support for non-NaN missing values,
see org.apache.sis.coverage.SampleDimension
.
Serialization
Serialized instances of this class are not guaranteed to be compatible with future SIS versions. Serialization should be used only for short term storage or RMI between applications running the same SIS version.- Since:
- 0.5
- Version:
- 1.0
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate double
The logarithmic base.private double
The scale factor, orNaN
if unknown.private double
The scale factor, orNaN
if unknown.private static final long
For cross-version compatibility.private org.opengis.referencing.operation.MathTransform1D
The transform created from above information, ornull
if not yet created.private org.opengis.metadata.content.TransferFunctionType
Whether the function is linear, logarithmic or exponential. -
Constructor Summary
ConstructorsConstructorDescriptionCreates a transfer function initialized to the identity transform. -
Method Summary
Modifier and TypeMethodDescriptionclone()
Returns a clone of this transfer function.private org.opengis.referencing.operation.MathTransform
createAffineTransform
(org.opengis.referencing.operation.MathTransformFactory factory, boolean withScale) Returns a linear transform created using the given factory.org.opengis.referencing.operation.MathTransform
createTransform
(org.opengis.referencing.operation.MathTransformFactory factory) Creates a transform from sample values to geophysics values using the given factory.double
getBase()
Returns the logarithm or exponent base in the transfer function.double
Returns the offset of the transfer function.double
getScale()
Returns the scale factor of the transfer function.org.opengis.referencing.operation.MathTransform1D
Returns the transform from sample values to geophysics values, as specified by the current properties of thisTransferFunction
.org.opengis.metadata.content.TransferFunctionType
getType()
Returns the transfer function type (linear, logarithmic or exponential).boolean
Returnstrue
if this transfer function is identity.void
setBase
(double base) Sets the logarithm or exponent base in the transfer function.private void
setLinearTerms
(LinearTransform function) void
setOffset
(double offset) Sets the offset of the transfer function.void
setScale
(double scale) Sets the scale factor of the transfer function.void
setTransform
(org.opengis.referencing.operation.MathTransform1D function) Sets the transform from sample values to geophysics values.void
setType
(org.opengis.metadata.content.TransferFunctionType type) Sets the transfer function type.toString()
Returns a string representation of this transfer function for debugging purpose.
-
Field Details
-
serialVersionUID
private static final long serialVersionUIDFor cross-version compatibility.- See Also:
-
type
private org.opengis.metadata.content.TransferFunctionType typeWhether the function is linear, logarithmic or exponential. -
base
private double baseThe logarithmic base. Ignored iftype
isLINEAR
. -
scale
private double scaleThe scale factor, orNaN
if unknown. -
offset
private double offsetThe scale factor, orNaN
if unknown. -
transform
private org.opengis.referencing.operation.MathTransform1D transformThe transform created from above information, ornull
if not yet created. Conversely, may be the transform given to the constructor from which above information were inferred.This field is serialized because the transform may be a user-provided one.
-
-
Constructor Details
-
TransferFunction
public TransferFunction()Creates a transfer function initialized to the identity transform.- See Also:
-
-
Method Details
-
isIdentity
public boolean isIdentity()Returnstrue
if this transfer function is identity. The function is identity if its type is linear, its scale is 1 and its offset is 0.- Returns:
- whether this transfer function is identity.
- Since:
- 1.0
-
getType
public org.opengis.metadata.content.TransferFunctionType getType()Returns the transfer function type (linear, logarithmic or exponential).- Returns:
- the transfer function type.
-
setType
public void setType(org.opengis.metadata.content.TransferFunctionType type) Sets the transfer function type. The default value isTransferFunctionType.LINEAR
.- Parameters:
type
- the transfer function type.
-
getBase
public double getBase()Returns the logarithm or exponent base in the transfer function. This value is always 1 forTransferFunctionType.LINEAR
, and usually (but not necessarily) 10 for the logarithmic and exponential types.- Returns:
- the logarithmic or exponent base.
-
setBase
public void setBase(double base) Sets the logarithm or exponent base in the transfer function. This value is ignored forTransferFunctionType.LINEAR
. For other supported types, the default value is 10.- Parameters:
base
- the new logarithm or exponent base.- Throws:
IllegalArgumentException
- if the given base is NaN, negative, zero or infinite.
-
getScale
public double getScale()Returns the scale factor of the transfer function.- Returns:
- the scale factor.
-
setScale
public void setScale(double scale) Sets the scale factor of the transfer function. The default value is 1.- Parameters:
scale
- the new scale factor.- Throws:
IllegalArgumentException
- if the given scale is NaN, zero or infinite.
-
getOffset
public double getOffset()Returns the offset of the transfer function.- Returns:
- the offset.
-
setOffset
public void setOffset(double offset) Sets the offset of the transfer function. The default value is 0.- Parameters:
offset
- the new offset.- Throws:
IllegalArgumentException
- if the given scale is NaN or infinite.
-
createAffineTransform
private org.opengis.referencing.operation.MathTransform createAffineTransform(org.opengis.referencing.operation.MathTransformFactory factory, boolean withScale) throws org.opengis.util.FactoryException Returns a linear transform created using the given factory. This method is used only when the user specify explicitly a factory to use.- Parameters:
factory
- the factory to use.withScale
-true
for usingscale
, orfalse
for replacing the scale by zero.- Throws:
org.opengis.util.FactoryException
-
createTransform
public org.opengis.referencing.operation.MathTransform createTransform(org.opengis.referencing.operation.MathTransformFactory factory) throws org.opengis.util.FactoryException Creates a transform from sample values to geophysics values using the given factory. This method constructs a transform mathematically equivalent to the one returned bygetTransform()
, but allows to specify another factory than the default one.- Parameters:
factory
- the factory to use for creating a transform.- Returns:
- the transform from sample to geophysics values.
- Throws:
org.opengis.util.FactoryException
- if the given factory failed to create a transform.- Since:
- 1.0
-
getTransform
public org.opengis.referencing.operation.MathTransform1D getTransform()Returns the transform from sample values to geophysics values, as specified by the current properties of thisTransferFunction
.- Returns:
- the transform from sample to geophysics values.
-
setTransform
public void setTransform(org.opengis.referencing.operation.MathTransform1D function) throws IllegalArgumentException Sets the transform from sample values to geophysics values. This method infers the base, scale and offset values from the given transform.- Parameters:
function
- the transform to set.- Throws:
IllegalArgumentException
- if this method does not recognize the given transform.
-
setLinearTerms
- Parameters:
function
- the transform to set.- Throws:
IllegalArgumentException
- if this method does not recognize the given transform.
-
clone
Returns a clone of this transfer function. -
toString
Returns a string representation of this transfer function for debugging purpose. The string returned by this method may change in any future SIS version.
-