Class TLcdRasterReferencingUtil

java.lang.Object
com.luciad.format.raster.TLcdRasterReferencingUtil

public class TLcdRasterReferencingUtil extends Object
This class creates model bounds for rasters, based on a given model reference and on additional information about the raster's position. The additional information can be
  • a set of tie points that link points in the image (expressed in pixel coordinates) to their corresponding locations in the model reference (expressed in model coordinates),
  • transformation matrices that express the relation between image coordinates and model coordinates.

The model reference can optionally be modified first, in order to provide better matching bounds. More specifically, a grid reference can be rotated. A geodetic reference can be replaced by a rotated grid reference or by a better suited grid reference with an orthographic projection.

For instance, positioning an axis-aligned raster of 500x500 pixels based on 3 tie points:


 int imageWidth  = 500;
 int imageHeight = 500;

 ILcdModelReference modelReference =
   new TLcdGeodeticReference(new TLcdGeodeticDatum());

 ILcdPoint[] imageTiePoints = new ILcdPoint[] {
   new TLcdXYPoint(0, 0),
   new TLcdXYPoint(imageWidth, 0),
   new TLcdXYPoint(0, imageHeight),
 };

 ILcdPoint[] modelTiePoints = new ILcdPoint[] {
   new TLcdLonLatPoint(20.0,  0.0),
   new TLcdLonLatPoint(20.0, 20.0),
   new TLcdLonLatPoint( 0.0,  0.0),
 };

 TLcdRasterReferencingUtil util =
   new TLcdRasterReferencingUtil(imageWidth, imageHeight);

 ILcdBounds bounds =
   util.createAxisAlignedBounds(modelReference, imageTiePoints, modelTiePoints, 100);
 

In this example, the 3 tie points provide a perfect reference. If necessary, especially with more tie points, a least squares approximation is computed. With only 2 tie points, the scaling is assumed to be uniform. With only a single tie point, the scale is assumed to be 1.

If required, we can also allow the model reference to be rotated first, or have it replaced by a better suited grid reference with an orthographic projection. For instance, with a geodetic reference that may be updated:


 .....

 modelReference =
   util.createRotatedModelReference(modelReference, imageTiePoints, modelTiePoints, true);

 ILcdBounds bounds =
   util.createAxisAlignedBounds(modelReference, imageTiePoints, modelTiePoints, 100);
 
For the tie points from the first example, this doesn't make a difference, since the rotation is 0. For other tie points, the resulting model reference may be different from the original one. Note that the model tie points are updated accordingly, resulting in different axis-aligned bounds.
Since:
8.0
  • Constructor Details

    • TLcdRasterReferencingUtil

      public TLcdRasterReferencingUtil(int aImageWidth, int aImageHeight)
      Creates a new TLcdRasterReferencingUtil for the given image size.
      Parameters:
      aImageWidth - the width of the raster, expressed in pixels.
      aImageHeight - the height of the raster, expressed in pixels.
  • Method Details

    • createRotatedModelReference

      public ILcdModelReference createRotatedModelReference(ILcdModelReference aModelReference, ILcdPoint[] aImageTiePoints, ILcdPoint[] aModelTiePointsSFCT, boolean aAllowOrthographicReferencing) throws IOException
      Computes a suitably rotated model reference for the given tie points. Also transforms the given model tie points, as a side effect.
      Parameters:
      aModelReference - the reference of the raster, defining the model coordinates in which the raster will be positioned.
      aImageTiePoints - the image tie points, expressed in pixel coordinates.
      aModelTiePointsSFCT - the corresponding model tie points, expressed in model coordinates. These points are updated on return, reflecting the modified model reference.
      aAllowOrthographicReferencing - specifies whether a geodetic model reference may be replaced by a grid reference with better suited orthographic projection, if necessary.
      Returns:
      the rotated model reference that corresponds best to the given tie points.
      Throws:
      IOException - if the model reference can't be computed.
    • createRotatedModelReference

      public ILcdModelReference createRotatedModelReference(ILcdModelReference aModelReference, double[][] aRotationMatrixSFCT, double[] aTranslationMatrixSFCT) throws IOException
      Computes a suitably rotated model reference for the given transformation matrices. Also transforms the given transformation matrices to remove the rotation, as a side effect.
      Parameters:
      aModelReference - the reference of the raster, defining the model coordinates in which the raster will be positioned.
      aRotationMatrixSFCT - the 2x2 rotation and scaling matrix for going from pixel coordinates to model coordinates.
      aTranslationMatrixSFCT - the given translation matrix for going from pixel coordinates to model coordinates.
      Returns:
      the rotated model reference that corresponds best to the given tie points.
      Throws:
      IOException - if the model reference can't be computed.
    • createAxisAlignedBounds

      public ILcdBounds createAxisAlignedBounds(ILcdModelReference aModelReference, ILcdPoint[] aImageTiePoints, ILcdPoint[] aModelTiePoints, double aMaximumResidualTiePointError) throws IOException
      Computes the model bounds for a raster with the given size, and given tie points, in a given model reference.
      Parameters:
      aModelReference - the reference of the raster, defining the model coordinates in which the raster will be positioned.
      aImageTiePoints - the image tie points, expressed in pixel coordinates.
      aModelTiePoints - the corresponding model tie points, expressed in model coordinates.
      aMaximumResidualTiePointError - the maximum average residual tie point error, expressed in pixels.
      Returns:
      the bounds that correspond best to the given tie points.
      Throws:
      IOException - if the given maximum residual tie point error is exceeded or if the bounds can't be computed.
    • createAxisAlignedBounds

      public ILcdBounds createAxisAlignedBounds(ILcdModelReference aModelReference, ILcdPoint[] aImageTiePoints, ILcdPoint[] aModelTiePoints, double aScaleX, double aScaleY, double aMaximumResidualTiePointError) throws IOException
      Returns the model bounds for a raster with the tie points and (optional) scale, in the given model reference.
      Parameters:
      aModelReference - the reference of the raster, defining the model coordinates in which the raster will be positioned.
      aImageTiePoints - the image tie points, expressed in pixel coordinates.
      aModelTiePoints - the corresponding model tie points, expressed in model coordinates.
      aScaleX - the scaling factor on the image x axis, expressed in model coordinates per pixel. If 0.0, the scaling factor is derived from the tie points.
      aScaleY - the scaling factor on the image y axis, expressed in model coordinates per pixel. If 0.0, the scaling factor is derived from the tie points.
      aMaximumResidualTiePointError - the maximum average residual tie point error, expressed in pixels.
      Returns:
      the bounds that correspond best to the given tie points.
      Throws:
      IOException - if the given maximum residual tie point error is exceeded or if the bounds can't be computed.
    • createAxisAlignedBounds

      public ILcdBounds createAxisAlignedBounds(ILcdModelReference aModelReference, double[][] aRotationMatrix, double[] aTranslationMatrix) throws IOException
      Returns the model bounds for a raster with the given transformation matrices, in the given model reference.
      Parameters:
      aModelReference - the reference of the raster, defining the model coordinates in which the raster will be positioned.
      aRotationMatrix - the 2x2 rotation and scaling matrix for going from pixel coordinates to model coordinates.
      aTranslationMatrix - the given translation matrix for going from pixel coordinates to model coordinates.
      Throws:
      IOException - if the bounds can't be computed.