Class TLcdSemanticsOp

java.lang.Object
com.luciad.imaging.operator.ALcdImageOperator
com.luciad.imaging.operator.TLcdSemanticsOp

public class TLcdSemanticsOp extends ALcdImageOperator
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
In most cases the default behavior is what is desired. For example a conversion from (measurement, 1 band, ubyte, normalized range=[0,255]) to (color, 1 band, ubyte, normalized range=[0,1]) will automatically get a scale factor of 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
  • Field Details

  • Constructor Details

    • TLcdSemanticsOp

      public TLcdSemanticsOp()
      Default constructor.
  • Method Details

    • apply

      public ALcdImage apply(ILcdDataObject aParameters)
      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 class ALcdImageOperator
      Parameters:
      aParameters - the parameters for the operator
      Returns:
      the image produced by the operator
    • semantics

      public static ALcdImage semantics(ALcdImage aImage, ALcdBandSemantics[] aBandSemantics)
      Set new band semantics on an image.
      Parameters:
      aImage - the input image
      aBandSemantics - 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 the aScales and aOffsets parameters is equivalent to those in TLcdPixelRescaleOp. The length of the scale and offset arrays must match the number of bands.
      Parameters:
      aImage - the input image
      aBandSemantics - semantics to set on the image
      aScales - scale factors to be applied to the values of each band
      aOffsets - offsets to be applied to the values of each band
      Returns:
      the input image with the new band semantics
    • semantics

      public static ALcdImage semantics(ALcdImage aImage, List<ALcdBandSemantics> aBandSemantics)
      Equivalent to semantics(com.luciad.imaging.ALcdImage, com.luciad.imaging.ALcdBandSemantics[]), but takes a list instead of an array as input.
      Parameters:
      aImage - the input image
      aBandSemantics - 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)
      Parameters:
      aImage - the input image
      aBandSemantics - semantics to set on the image
      aScales - scale factors to be applied to the values of each band
      aOffsets - offsets to be applied to the values of each band
      Returns:
      the input image with the new band semantics
    • semantics

      public static ALcdImage semantics(ALcdImage aSource, ALcdBandSemantics.DataType aOutputFormat)
      Changes the ALcdBandSemantics.getDataType() data type of all bands.
      Parameters:
      aSource - the input image
      aOutputFormat - the output format
      Returns:
      the operator