Class TLcdJPEG2000ModelEncoder

java.lang.Object
com.luciad.format.jpeg2000.TLcdJPEG2000ModelEncoder
All Implemented Interfaces:
ILcdModelEncoder, Serializable

@LcdService(service=ILcdModelEncoder.class, priority=20000) public class TLcdJPEG2000ModelEncoder extends Object implements ILcdModelEncoder
This ILcdModelEncoder encodes raster models into georeferenced JPEG2000 files. The encoder will encode the first ILcdRaster or ILcdMultilevelRaster element in the model. Any other elements are ignored. The georeference is encoded by means of an embedded GeoTIFF box.

The encoder output

The property imageOutputStreamFactory provides some control over the destination of the encoded images. By default, they are written to files.

Wavelet decomposition levels

The number of DWT levels is specified by the property levelCount. Each level effectively reduces the image dimensions by a factor of two. If not specified, the number of levels is computed such that the smallest image tile (or the entire image if tiling is not used) will have a size of at least 64x64 pixels.

Lossy/Lossless compression

The encoder supports both lossless and lossy compression.
  • Lossless compression is well suited for images that have an indexed color model and for vector images having up to 24 bits per pixel. Lossless compression does not bring very large space saving. It is not supported for 32 bit images.
  • Lossy compression is better suited for pictures, like satellite imagery, typically with a large number of colors. Whith lossy compression it is possible to specify the quality of the output image as a number between 0 (lowest) and 8.0 (highest quality). The size of the output image will be higher if the quality is higher. The default value is 0.8 .

Quality layers

The encoder can write out JPEG2000 (.jp2) files that are encoded in several quality layers, as specified by the property layerCount. The quality layers are used for progressive image transmission - each new layer adds new details to the already existing layers. The quality parameter of the encoder only affects the last layer (the most detailed one); the qualities of the other layers are computed automatically. Up to 60 layers can be specified. The default value is 1.

Tiling

The encoder can write out tiled images. The tile dimensions are specified by the properties tileWidth and tileHeight. Tiled images can improve access times when they are used, since only the required parts of the images need be decoded and cached, but may introduce compression artifacts at the tile boundaries. By default, tiling is not used.

Color Models

The encoder supports both direct color model rasters and indexed color model rasters.
  • Direct Color Model rasters having 24 bits (RGB) or 32 bits per pixel (RGBA) are encoded as JPEG2000 24/32 bits direct color model images. Rasters having 8 bits per pixel (gray levels) are encoded and stored as Indexed Color Model images with a default color map. For rasters with 32 bits per pixel (RGBA) lossless compression is not supported.
  • Indexed Color Model rasters having 8 or 16 bits per pixel are encoded as JPEG2000 8/16 bit indexed color images. For rasters with 16 bits per pixel, the current implementation does not encode the color map (it is lost). It it is the responsibility of the user to set an adequate color map after decoding the JPEG2000 image. The 16 bit rasters can be used to encode elevation maps.

    When encoding any indexed color map raster, you should use lossless compression and 1 level and quality layer. Other settings (ex. multiple levels or layers, lossy encoding) are only supported for gray-level color models.

The native JPEG2000 library has to be installed in order to be able to use this decoder.

Since:
6.1
See Also:
  • Constructor Details

    • TLcdJPEG2000ModelEncoder

      public TLcdJPEG2000ModelEncoder()
  • Method Details

    • setImageOutputStreamFactory

      public void setImageOutputStreamFactory(ILcdOutputStreamFactory aImageOutputStreamFactory)
      Sets the factory that will create the output streams to which images can be encoded. The default is null, meaning that images are encoded in files.
    • getImageOutputStreamFactory

      public ILcdOutputStreamFactory getImageOutputStreamFactory()
      Returns the output stream factory.
      See Also:
    • setLevelCount

      public void setLevelCount(int aLevelCount)
      Sets the number of wavelet decomposition levels or stages.

      If not set by the user, the default number of levels is 0, which is interpreted differently depending on the color model of the image:

      • In case of a direct color model 0 means that the number of levels will be computed such that the smallest image tile (or the entire image if tiling is not used) will have a size of at least 64x64 pixels.
      • In case of an indexed color model 0 means that the encoded image will have a single level.
      For indexed color images you should not set more than one level unless you are encoding a gray-level image.
      Parameters:
      aLevelCount - the number of JPEG2000 DWT levels
    • getLevelCount

      public int getLevelCount()
      Returns the number of wavelet decomposition levels or stages.
      Returns:
      the number of JPEG2000 DWT layers.
    • setQualityLayerCount

      public void setQualityLayerCount(int aQualityLayerCount)
      Sets the number of quality layers. The default is 1.
      Parameters:
      aQualityLayerCount - the number of JPEG2000 quality layers.
    • getQualityLayerCount

      public int getQualityLayerCount()
      Returns the number of JPEG2000 quality layers.
      Returns:
      the number of quality layers
    • setTileWidth

      public void setTileWidth(int aTileWidth)
      Sets the width of a tile in pixels. The width should be larger than 64 pixels. The default is 0, meaning that the image is not tiled.
      Parameters:
      aTileWidth - the tile width.
    • getTileWidth

      public int getTileWidth()
      Returns the width of a tile in pixels.
      Returns:
      the width of tile.
    • setTileHeight

      public void setTileHeight(int aTileHeight)
      Sets the height of a tile in pixels. The height should be larger than 64 pixels. The default is 0, meaning that the image is not tiled.
      Parameters:
      aTileHeight - the tile height.
    • getTileHeight

      public int getTileHeight()
      Returns the height of a tile in pixels.
      Returns:
      the tile height.
    • setQuality

      public void setQuality(float aQuality)
      Sets the encoding quality as an floating value between 0 (lowest) and 8.0 (highest quality). The default value is 0.8.
      Parameters:
      aQuality - a value between 0 and 8.
      See Also:
    • getQuality

      public float getQuality()
      Returns the encoding quality. The default value is 0.8.
      Returns:
      the encoding quality (between 0 and 8.0).
      See Also:
    • setLossless

      public void setLossless(boolean aLossless)
      Enables/disables lossless (reversible) JPEG2000 encoding. If true, the value of the quality parameter is ignored. It is recommended to enable lossless compression when encoding indexed color model rasters.
      Parameters:
      aLossless - true if reversible encoding is required.
      See Also:
    • isLossless

      public boolean isLossless()
      Returns whether lossless compression is enabled.
      Returns:
      true if lossless compression is enabled, false otherwise.
      See Also:
    • getDisplayName

      public String getDisplayName()
      Description copied from interface: ILcdModelEncoder
      Returns a short, displayable name for the format this ILcdModelEncoder encodes to.
      Specified by:
      getDisplayName in interface ILcdModelEncoder
      Returns:
      the displayable name of this ILcdModelEncoder.
    • canSave

      public boolean canSave(ILcdModel aModel)
      Description copied from interface: ILcdModelEncoder
      Returns whether this model encoder can save the specified model to the location it originally came from. Often this will only be a simple test, for example checking the type of the model's model descriptor.
      Specified by:
      canSave in interface ILcdModelEncoder
      Parameters:
      aModel - the model to be verified.
      Returns:
      true if this encoder can save the model in the location where it originally came from, false otherwise.
      See Also:
    • save

      public void save(ILcdModel aModel) throws IllegalArgumentException, IOException
      Description copied from interface: ILcdModelEncoder
      Saves the model to the location where it originally came from.
      Specified by:
      save in interface ILcdModelEncoder
      Parameters:
      aModel - the model to be saved.
      Throws:
      IllegalArgumentException - if the model cannot be saved by this encoder (!canSave(aModel)).
      IOException - if an I/O error occurs during encoding.
    • canExport

      public boolean canExport(ILcdModel aModel, String string)
      Description copied from interface: ILcdModelEncoder
      Returns whether this encoder can export the specified model to the specified destination. This method will typically check whether the contents of the specified model are compatible with the format this encoder is written for.
      Specified by:
      canExport in interface ILcdModelEncoder
      Parameters:
      aModel - the model to be verified.
      string - the location where the model should be exported to.
      Returns:
      true if this encoder can export the specified model to the specified location, false otherwise.
      See Also:
    • export

      public void export(ILcdModel aModel, String aFileName) throws IllegalArgumentException, IOException
      Description copied from interface: ILcdModelEncoder
      Exports the specified model to the specified destination.
      Specified by:
      export in interface ILcdModelEncoder
      Parameters:
      aModel - the model to be exported.
      aFileName - the location where the model should be saved. Typically, this is a name for the output file, but it can also point to a file containing the required properties to create a set of data files.
      Throws:
      IllegalArgumentException - if the model cannot be saved by this encoder (!canExport(aModel, aDestinationName)).
      IOException - if an I/O error occurs during encoding.