@LcdService(service=ILcdModelDecoder.class, priority=20000) public class TLcdJPEG2000ModelDecoder extends Object implements ILcdModelDecoder
File | Required | Entry point | Description |
---|---|---|---|
*.jp2 *.j2k |
x | x | JPEG2000 file containing the raster data and possibly specifying a model reference and raster bounds using embedded GeoTIFF tags (geoJP2) or via embedded GML (GMLJP2 versions 1.0, 2.0 & 2.1). |
*.tab | TAB file specifying a model reference and raster bounds | ||
*.jpw | JPW file specifying raster bounds | ||
*.j2w | J2W file specifying raster bounds |
If none of the files specify a model reference, the model reference is obtained from an ILcdModelReferenceDecoder
. The default reference decoder set on this
model decoder is based on all model reference decoders annotated with the LcdService
annotation, and can handle
<filename>.epsg
): see TLcdEPSGModelReferenceDecoder
for more info.<filename>.prj
): see TLcdWKTModelReferenceDecoder
for more info.<filename>.ref
): see TLcdModelReferenceDecoder
for more info.
If none of the files specify raster bounds, it is retrieved from the
bounds
property of this decoder.
You can find all details about reference decoding on decodeRasterReference(TLcdJPEG2000ModelDescriptor)
.
InputStream
, from a http connection or from an image file inside
a jar file.
ILcd2DBoundsIndexedModel
.TLcdJPEG2000ModelDescriptor
.default reference
for files from which the reference information is mssing.custom reference decoder
can also be installed.ALcdImage
(and ILcdMultilevelRaster
) instance.defaultValue
allows the specify the
default value that is assigned to decoded rasters.decodeRasterReference(com.luciad.format.jpeg2000.TLcdJPEG2000ModelDescriptor)
method can be
overridden to customize the decoding of the georeferencing information of the raster. This is
for example necessary if this information is embedded as application-specific XML.
ILcdModelDecoder decoder =
new TLcdJPEG2000ModelDecoder();
ILcdModel model = decoder.decode("raster.jp2");
threshold
.The number of native decoders allowed to work in parallel can be controlled by setting the jpeg2000.pool.size system property (for example: java -Djpeg2000.pool.size=2 MyApplication).
ALcdImage
API it is possible to decode monochrome, RGB and multi band images. Each band of the image may contain
<= 16
bits, which will not be scaled. Further, it is assumed that all data is unsigned.
ILcdRaster
API some image components may be converted
to lower precision. You can obtain the precision in the image from the model descriptor
and the precision in the ILcdRaster
from its ILcdRaster.getColorModel() color model
. The raster component
is either 8 or 16 bits and the total number of bits per raster pixel is at most 32bits. Image components
is obtained by scaling the image components. For example, an RGB JPEG2000 image with
11 bits per component will be converted to an RGB raster with 8 bits per component where each component is scaled by (2^11 - 1) / (2^8 - 1)
.
Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_DISPLAY_NAME |
static double |
EPSILON |
Constructor and Description |
---|
TLcdJPEG2000ModelDecoder()
Creates a new TLcdJPEG2000ModelDecoder, with a globally shared buffer for
caching pixel data.
|
TLcdJPEG2000ModelDecoder(ILcdBuffer aBuffer)
Creates a new TLcdJPEG2000ModelDecoder with the given buffer.
|
TLcdJPEG2000ModelDecoder(ILcdBuffer aBuffer,
ILcdModelReference aDefaultModelReference)
Creates a new TLcdJPEG2000ModelDecoder with the given buffer and default
model reference.
|
TLcdJPEG2000ModelDecoder(ILcdBuffer aBuffer,
ILcdModelReferenceDecoder aModelReferenceDecoder)
Creates a new TLcdJPEG2000ModelDecoder with the given buffer and model
reference decoder.
|
TLcdJPEG2000ModelDecoder(ILcdBuffer aBuffer,
ILcdModelReferenceDecoder aModelReferenceDecoder,
ILcdModelReference aDefaultModelReference,
int aDefaultValue)
Creates a new TLcdJPEG2000ModelDecoder with the given properties.
|
TLcdJPEG2000ModelDecoder(ILcdBuffer aBuffer,
ILcdModelReferenceDecoder aModelReferenceDecoder,
int aDefaultValue)
Creates a new TLcdJPEG2000ModelDecoder with the given buffer, model
reference decoder, and default value.
|
TLcdJPEG2000ModelDecoder(ILcdBuffer aBuffer,
ILcdModelReference aDefaultModelReference,
int aDefaultValue)
Creates a new TLcdJPEG2000ModelDecoder with the given buffer, default
model reference, and default value.
|
Modifier and Type | Method and Description |
---|---|
boolean |
canDecodeSource(String aSourceName)
Checks whether
TLcdJPEG2000ModelDecoder can decode the given data. |
ILcdModel |
decode(String aSourceName)
Creates a new model from the given data source.
|
protected ILcdRasterReference |
decodeRasterReference(TLcdJPEG2000ModelDescriptor aModelDescriptor)
Decodes the raster reference based on the metadata.
|
ILcdBounds |
getBounds()
Sets the default model bounds that is assigned to rasters of the
decoded models whose image files don't specify bounds.
|
ILcdModelReference |
getDefaultModelReference()
Returns the default model reference that is assigned to decoded models
whose image files don't specify model references.
|
int |
getDefaultValue()
Returns the default pixel value that is assigned to the rasters of the
decoded models.
|
String |
getDisplayName()
Returns a short, displayable name for the format that is decoded by this
ILcdModelDecoder . |
double |
getMaximumResidualTiePointError()
Returns the maximum acceptable average residual error for tie points.
|
int |
getMinimumTiePointCount()
Returns the minimum number of tie points required for positioning image
files that provide tie points.
|
ILcdModelReferenceDecoder |
getModelReferenceDecoder()
Returns the model reference decoder that is used for decoded models
whose image files don't specify model references.
|
ILcdRasterReferencer |
getRasterReferencer()
Returns the raster referencer that is used when positioning image files
based on tie points.
|
boolean |
isAllowOrthographicReferencing()
Returns whether images that are positioned in geodetic references
using tie points may be put in approximating orthographic grid
references that are centered around the images.
|
void |
setAllowOrthographicReferencing(boolean aAllowOrthographicReferencing)
Specifies whether images that are positioned in geodetic references
using tie points may be put in approximating orthographic grid
references that are centered around the images.
|
void |
setBounds(ILcdBounds aBounds)
Sets the default model bounds that will be assigned to rasters of the
decoded models whose image files don't specify bounds.
|
void |
setDefaultModelReference(ILcdModelReference aDefaultModelReference)
Sets the default model reference that will be assigned to decoded models
whose image files don't specify model references.
|
void |
setDefaultValue(int aDefaultValue)
Sets the default pixel value that will be assigned to the rasters of the
decoded models.
|
void |
setMaximumResidualTiePointError(double aMaximumResidualTiePointError)
Sets the maximum acceptable average residual error for tie points, when
positioning image files that provide tie points instead of scaling
information or transformation matrices.
|
void |
setMinimumTiePointCount(int aMinimumTiePointCount)
Sets the minimum number of tie points required for positioning image
files that provide tie points instead of scaling information or
transformation matrices.
|
void |
setModelReferenceDecoder(ILcdModelReferenceDecoder aModelReferenceDecoder)
Sets the model reference decoder that will be used for decoded models
whose image files don't specify model references.
|
void |
setRasterReferencer(ILcdRasterReferencer aRasterReferencer)
Sets the raster referencer that will be used when positioning image files
based on tie points.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
canDecodeSource, decodeModelMetadata, decodeModelMetadata, decodeSource, discoverDataSources
public static final String DEFAULT_DISPLAY_NAME
public static final double EPSILON
public TLcdJPEG2000ModelDecoder()
TLcdSharedBuffer.getBufferInstance()
public TLcdJPEG2000ModelDecoder(ILcdBuffer aBuffer)
aBuffer
- the buffer in which pixel data can be decoded and cached.public TLcdJPEG2000ModelDecoder(ILcdBuffer aBuffer, ILcdModelReferenceDecoder aModelReferenceDecoder)
aBuffer
- the buffer in which pixel data can be decoded and cached.aModelReferenceDecoder
- the model reference decoder.public TLcdJPEG2000ModelDecoder(ILcdBuffer aBuffer, ILcdModelReferenceDecoder aModelReferenceDecoder, int aDefaultValue)
aBuffer
- the buffer in which pixel data can be decoded and cached.aModelReferenceDecoder
- the model reference decoder.aDefaultValue
- the default pixel value.public TLcdJPEG2000ModelDecoder(ILcdBuffer aBuffer, ILcdModelReference aDefaultModelReference)
aBuffer
- the buffer in which pixel data can be decoded and cached.aDefaultModelReference
- the default model reference.public TLcdJPEG2000ModelDecoder(ILcdBuffer aBuffer, ILcdModelReference aDefaultModelReference, int aDefaultValue)
aBuffer
- the buffer in which pixel data can be decoded and cached.aDefaultModelReference
- the default model reference.aDefaultValue
- the default pixel value.public TLcdJPEG2000ModelDecoder(ILcdBuffer aBuffer, ILcdModelReferenceDecoder aModelReferenceDecoder, ILcdModelReference aDefaultModelReference, int aDefaultValue)
aBuffer
- the buffer in which pixel data can be decoded and cached.aModelReferenceDecoder
- the model reference decoder.aDefaultModelReference
- the default model reference.aDefaultValue
- the default pixel value.public void setModelReferenceDecoder(ILcdModelReferenceDecoder aModelReferenceDecoder)
aModelReferenceDecoder
- the model reference decoder.public ILcdModelReferenceDecoder getModelReferenceDecoder()
setModelReferenceDecoder(com.luciad.model.ILcdModelReferenceDecoder)
public void setDefaultModelReference(ILcdModelReference aDefaultModelReference)
aDefaultModelReference
- the default model reference.public ILcdModelReference getDefaultModelReference()
public void setBounds(ILcdBounds aBounds)
aBounds
- the default model bounds.public ILcdBounds getBounds()
public void setMinimumTiePointCount(int aMinimumTiePointCount)
A value of 3 can be used, if the assumption is made that 3 tie points always define an affine transformation (which is not strictly guaranteed by the GeoTIFF specifications).
A value of 2 can be used, if the assumption is made that 2 tie points always define an affine transformation without rotation.
aMinimumTiePointCount
- the minimum number of tie points.setMaximumResidualTiePointError(double)
public int getMinimumTiePointCount()
public void setAllowOrthographicReferencing(boolean aAllowOrthographicReferencing)
true
.public boolean isAllowOrthographicReferencing()
public void setMaximumResidualTiePointError(double aMaximumResidualTiePointError)
A raster is always positioned by means of an affine transformation in its coordinate system. For tie points that define an affine transformation, the residual error should therefore be 0. For tie points that define more complex, non-linear warping of the image, it will be larger than 0.
The residual error is computed in image coordinates and expressed in
pixels. The default is EPSILON
.
aMaximumResidualTiePointError
- the maximum residual error, expressed
in pixels.setMinimumTiePointCount(int)
public double getMaximumResidualTiePointError()
public void setRasterReferencer(ILcdRasterReferencer aRasterReferencer)
minimumTiePointCount
, allowOrthographicReferencing
,
and maximumResidualTiePointError
, which are used by default.aRasterReferencer
- the raster referencer, which will create model
references and raster bounds based on tie points.public ILcdRasterReferencer getRasterReferencer()
public void setDefaultValue(int aDefaultValue)
aDefaultValue
- the default pixel value.ILcdRaster.setDefaultValue(int)
public int getDefaultValue()
public String getDisplayName()
ILcdModelDecoder
ILcdModelDecoder
.getDisplayName
in interface ILcdModelDecoder
ILcdModelDecoder
.public boolean canDecodeSource(String aSourceName)
TLcdJPEG2000ModelDecoder
can decode the given data.
The extension of the file name should be "jp2" or "j2k".canDecodeSource
in interface ILcdModelDecoder
aSourceName
- the name of the file that is to be decoded.true
if TLcdJPEG2000ModelDecoder
can decode
the data specified by the source name, false
otherwise.ILcdModelDecoder.decode(String)
,
ILcdModelDecoder.decodeModelMetadata(String)
public ILcdModel decode(String aSourceName) throws IOException
ILcdModelDecoder
decode
in interface ILcdModelDecoder
aSourceName
- the data source to be decoded; typically a file name or a URL.null
is allowed, implementors are advised to throw an error instead.IOException
- for any exceptions caused by IO problems or invalid data. Since decoding invalid data almost
always results in RunTimeExceptions (NullPointerException, IndexOutOfBoundsException,
IllegalArgumentException, ...) on unexpected places, implementations are advised to catch
RuntimeExceptions in their decode() method, and wrap them into an IOException, as illustrated
in the code snippet below.
public ILcdModel decode( String aSourceName ) throws IOException {
try (InputStream input = fInputStreamFactory.createInputStream(aSourceName)) {
// Perform decoding ...
} catch (RuntimeException e) {
throw new IOException(e);
}
}
InterruptedIOException
- When the thread on which this method is called is interrupted: it is recommended to stop the decoding
and throw an InterruptedIOException
.
This same exception can also be used if the decoder shows UI to the user, and the user cancels the decoding
through the UI.ILcdModelDecoder.canDecodeSource(String)
protected ILcdRasterReference decodeRasterReference(TLcdJPEG2000ModelDescriptor aModelDescriptor) throws IOException
aModelDescriptor
- the model descriptorIOException
- if the raster reference could not be decoded