Package com.luciad.imaging.operator
Class TLcdSemanticsOp
java.lang.Object
com.luciad.imaging.operator.ALcdImageOperator
com.luciad.imaging.operator.TLcdSemanticsOp
Adjusts the
semantics
of an image.
This can for example be used to interpret 3 measurement bands as the red, green and blue component of a color.
This operator can be used to change the semantics in any way except for the number of bands. This operator also does
not allow re-ordering bands. The semantics of the i'th input band is changed to the i'th semantics that are specified.
When changing the semantics the values can be adjusted using a scale and offset. If no explicit scale and offset
are specified then the behavior is as follows:
- measurement to measurement: value is not changed
- otherwise: the normalized range of the input band is mapped to the normalized range of the output band
1 / 255
on the normalized values. However in case of a conversion from (measurement, 1 band, float,
normalized range=[-Inf,+Inf]) to (color, 1 band, ubyte, normalized range=[0,1]) the scale factor should usually be
specified to get a sensible results. In this case if you for example want to map the float range in [-100,100] to
[0,1], you would use offset 100
and scale 1 / 200
. You can find more details about the image
processing model here
.
Example
// Using the static method
ALcdImage inputImage = ...;
ALcdImage outputImage = TLcdSemanticsOp.semantics(inputImage, ALcdBandSemantics.DataType.FLOAT);
// Using a data object
ALcdImage inputImage = ...;
double[] scales = ...;
double[] offsets = ...;
TLcdSemanticsOp op = new TLcdSemanticsOp();
ILcdDataObject params = op.getParameterDataType().newInstance();
params.setValue(TLcdSemanticsOp.BAND_SEMANTICS, ALcdBandSemantics.DataType.FLOAT);
params.setValue(TLcdSemanticsOp.SCALES, scales);
params.setValue(TLcdSemanticsOp.OFFSETS, offsets);
ALcdImage outputImage = op.apply(params);
- Since:
- 2014.0
-
Nested Class Summary
Nested classes/interfaces inherited from class com.luciad.imaging.operator.ALcdImageOperator
ALcdImageOperator.ImageOperatorTypeBuilder
-
Field Summary
Modifier and TypeFieldDescriptionstatic final TLcdDataProperty
Semantics to set on the image.static final TLcdDataProperty
The input image.static final String
Name of the operator.static final TLcdDataProperty
The (optional) offset to apply to the scaled input image values.static final TLcdDataProperty
The (optional) scale to apply to the input image values.static final TLcdDataType
Input data type of the operator.Fields inherited from class com.luciad.imaging.operator.ALcdImageOperator
INPUT_IMAGE_NAME
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionapply
(ILcdDataObject aParameters) Applies this operator to the given input parameters.static ALcdImage
semantics
(ALcdImage aImage, ALcdBandSemantics[] aBandSemantics) Set new band semantics on an image.static ALcdImage
semantics
(ALcdImage aImage, ALcdBandSemantics[] aBandSemantics, double[] aScales, double[] aOffsets) Set new band semantics on an image and additionally apply scales and offsets to the values in each band.static ALcdImage
semantics
(ALcdImage aSource, ALcdBandSemantics.DataType aOutputFormat) Changes theALcdBandSemantics.getDataType()
data type of all bands.static ALcdImage
semantics
(ALcdImage aImage, List<ALcdBandSemantics> aBandSemantics) Equivalent tosemantics(com.luciad.imaging.ALcdImage, com.luciad.imaging.ALcdBandSemantics[])
, but takes a list instead of an array as input.static ALcdImage
semantics
(ALcdImage aImage, List<ALcdBandSemantics> aBandSemantics, double[] aScales, double[] aOffsets) Equivalent tosemantics(com.luciad.imaging.ALcdImage, com.luciad.imaging.ALcdBandSemantics[], double[], double[])
, but takes a list instead of an array as input.Methods inherited from class com.luciad.imaging.operator.ALcdImageOperator
createTypeBuilder, createTypeBuilder, equals, getParameterDataType, hashCode, toString
-
Field Details
-
NAME
Name of the operator.- See Also:
-
INPUT_IMAGE
The input image. -
BAND_SEMANTICS
Semantics to set on the image. -
SCALES
The (optional) scale to apply to the input image values.- See Also:
-
OFFSETS
The (optional) offset to apply to the scaled input image values.- See Also:
-
SEMANTICS_FILTER_TYPE
Input data type of the operator.
-
-
Constructor Details
-
TLcdSemanticsOp
public TLcdSemanticsOp()Default constructor.
-
-
Method Details
-
apply
Description copied from class:ALcdImageOperator
Applies this operator to the given input parameters. The parameters are stored in a data object which must be of the type given by ALcdImageOperator.getParameterDataType().- Specified by:
apply
in classALcdImageOperator
- Parameters:
aParameters
- the parameters for the operator- Returns:
- the image produced by the operator
-
semantics
Set new band semantics on an image.- Parameters:
aImage
- the input imageaBandSemantics
- semantics to set on the image- Returns:
- the input image with the new band semantics
-
semantics
public static ALcdImage semantics(ALcdImage aImage, ALcdBandSemantics[] aBandSemantics, double[] aScales, double[] aOffsets) Set new band semantics on an image and additionally apply scales and offsets to the values in each band. The interpretation of theaScales
andaOffsets
parameters is equivalent to those inTLcdPixelRescaleOp
. The length of the scale and offset arrays must match the number of bands.- Parameters:
aImage
- the input imageaBandSemantics
- semantics to set on the imageaScales
- scale factors to be applied to the values of each bandaOffsets
- offsets to be applied to the values of each band- Returns:
- the input image with the new band semantics
-
semantics
Equivalent tosemantics(com.luciad.imaging.ALcdImage, com.luciad.imaging.ALcdBandSemantics[])
, but takes a list instead of an array as input.- Parameters:
aImage
- the input imageaBandSemantics
- semantics to set on the image- Returns:
- the input image with the new band semantics
-
semantics
public static ALcdImage semantics(ALcdImage aImage, List<ALcdBandSemantics> aBandSemantics, double[] aScales, double[] aOffsets) Equivalent tosemantics(com.luciad.imaging.ALcdImage, com.luciad.imaging.ALcdBandSemantics[], double[], double[])
, but takes a list instead of an array as input.- Parameters:
aImage
- the input imageaBandSemantics
- semantics to set on the imageaScales
- scale factors to be applied to the values of each bandaOffsets
- offsets to be applied to the values of each band- Returns:
- the input image with the new band semantics
-
semantics
Changes theALcdBandSemantics.getDataType()
data type of all bands.- Parameters:
aSource
- the input imageaOutputFormat
- the output format- Returns:
- the operator
-