|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
ObjectImageReader
MosaicImageReader
public class MosaicImageReader
An image reader built from a mosaic of other image readers. The mosaic is specified as a
collection of Tile objects, organized in a TileManager. Images are read
using the read(int,ImageReadParam) method. The ImageReadParam argument
is optional by strongly recommended, since the whole purpose of MosaicImageReader
is to read efficiently only subsets of big tiled images.
| coverage/geotk-coverageio (download) | View source code for this class |
| Nested Class Summary | |
|---|---|
static class |
MosaicImageReader.Spi
Service provider for MosaicImageReader. |
| Field Summary |
|---|
| Fields inherited from class ImageReader |
|---|
availableLocales, ignoreMetadata, input, locale, minIndex, originatingProvider, progressListeners, seekForwardOnly, updateListeners, warningListeners, warningLocales |
| Constructor Summary | |
|---|---|
MosaicImageReader()
Constructs an image reader with the default provider. |
|
MosaicImageReader(ImageReaderSpi spi)
Constructs an image reader with the specified provider. |
|
| Method Summary | |
|---|---|
void |
abort()
Requests that any current read operation be aborted. |
void |
close()
Closes any image input streams that may be held by tiles. |
void |
dispose()
Allows any resources held by this reader to be released. |
float |
getAspectRatio(int imageIndex)
Returns the aspect ratio. |
Locale[] |
getAvailableLocales()
Returns an array of locales that may be used to localize warning listeners. |
ImageTypePolicy |
getDefaultImageTypePolicy()
Returns the policy for computing image types. |
MosaicImageReadParam |
getDefaultReadParam()
Returns default parameters appropriate for this format. |
int |
getHeight(int imageIndex)
Returns the height in pixels of the given image within the input source. |
IIOMetadata |
getImageMetadata(int imageIndex)
Returns the metadata associated with the given image, or null if none. |
Iterator<ImageTypeSpecifier> |
getImageTypes(int imageIndex)
Returns possible image types to which the given image may be decoded. |
TileManager[] |
getInput()
Returns the input, which is a an array of tile managers. |
Level |
getLogLevel()
Returns the logging level for tile information during read operations. |
int |
getNumImages(boolean allowSearch)
Returns the number of images, not including thumbnails. |
ImageTypeSpecifier |
getRawImageType(int imageIndex)
Returns an image type which most closely represents the "raw" internal format of the image. |
IIOMetadata |
getStreamMetadata()
Returns the metadata associated with the input source as a whole, or null. |
int |
getTileHeight(int imageIndex)
Returns the height of a tile in the given image. |
Set<ImageReaderSpi> |
getTileReaderSpis()
Returns the Service Provider Interfaces (SPI) of every image readers to be used for reading tiles. |
int |
getTileWidth(int imageIndex)
Returns the width of a tile in the given image. |
int |
getWidth(int imageIndex)
Returns the width in pixels of the given image within the input source. |
boolean |
isImageTiled(int imageIndex)
Returns true if there is more than one tile for the given image index. |
boolean |
isRandomAccessEasy(int imageIndex)
Returns true if the storage format of the given image places no inherent impediment
on random access to pixels. |
BufferedImage |
read(int imageIndex,
ImageReadParam param)
Reads the image indexed by imageIndex using a supplied parameters. |
BufferedImage |
readTile(int imageIndex,
int tileX,
int tileY)
Reads the tile indicated by the tileX and tileY arguments. |
void |
setInput(Object input,
boolean seekForwardOnly,
boolean ignoreMetadata)
Sets the input source, which is expected to be an array of tile managers. |
void |
setLocale(Locale locale)
Sets the current locale of this image reader and every tile readers. |
void |
setLogLevel(Level level)
Sets the logging level for tile information during read operations. |
| Methods inherited from class Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public MosaicImageReader()
public MosaicImageReader(ImageReaderSpi spi)
spi - The image reader provider, or null for the default one.| Method Detail |
|---|
public Level getLogLevel()
PerformanceLevel constants,
determined according the duration of the read operation.
getLogLevel in interface LogProducerpublic void setLogLevel(Level level)
null
value restores the default level documented in the getLogLevel() method.
setLogLevel in interface LogProducerlevel - The new logging level, or null for the default.public TileManager[] getInput()
getInput in class ImageReader
public void setInput(Object input,
boolean seekForwardOnly,
boolean ignoreMetadata)
throws IllegalArgumentException
Tile objects, then it will be wrapped in an
array of TileManagers.
setInput in class ImageReaderinput - The input.seekForwardOnly - if true, images and metadata may only be read in ascending
order from this input source.ignoreMetadata - if true, metadata may be ignored during reads.
IllegalArgumentException - if input is not an instance of one of the
expected classes, or if the input can not be used because of an I/O error
(in which case the exception has a IOException as its
cause).public Set<ImageReaderSpi> getTileReaderSpis()
TileManager.getImageReaderSpis()public Locale[] getAvailableLocales()
getAvailableLocales in class ImageReadernull.
public void setLocale(Locale locale)
throws IllegalArgumentException
setLocale in class ImageReaderlocale - The desired locale, or null.
IllegalArgumentException - if locale is non-null but is not
one of the available locales.
public int getNumImages(boolean allowSearch)
throws IOException
getNumImages in class ImageReaderIOException - If an error occurs reading the information from the input source.
public boolean isImageTiled(int imageIndex)
throws IOException
true if there is more than one tile for the given image index.
isImageTiled in class ImageReaderimageIndex - The index of the image to be queried.
true If there is at least two tiles.
IOException - If an error occurs reading the information from the input source.
public int getWidth(int imageIndex)
throws IOException
getWidth in class ImageReaderimageIndex - The index of the image to be queried.
IOException - If an error occurs reading the information from the input source.
public int getHeight(int imageIndex)
throws IOException
getHeight in class ImageReaderimageIndex - The index of the image to be queried.
IOException - If an error occurs reading the information from the input source.
public int getTileWidth(int imageIndex)
throws IOException
getTileWidth in class ImageReaderimageIndex - The index of the image to be queried.
IOException - If an error occurs reading the information from the input source.
public int getTileHeight(int imageIndex)
throws IOException
getTileHeight in class ImageReaderimageIndex - The index of the image to be queried.
IOException - If an error occurs reading the information from the input source.
public boolean isRandomAccessEasy(int imageIndex)
throws IOException
true if the storage format of the given image places no inherent impediment
on random access to pixels. The default implementation returns true if the input of
every tiles is a File and isRandomAccessEasy returned true for all
tile readers.
isRandomAccessEasy in class ImageReaderIOException - If an error occurs reading the information from the input source.
public float getAspectRatio(int imageIndex)
throws IOException
getAspectRatio in class ImageReaderimageIndex - The index of the image to be queried.
IOException - If an error occurs reading the information from the input source.public ImageTypePolicy getDefaultImageTypePolicy()
computing image types. This is also
the policy used by read method when none has been explicitly
set in read parameters.
The default implementation makes the following choice based on the number of reader providers:
SUPPORTED_BY_ALL if two or moreSUPPORTED_BY_FIRST if exactly oneALWAYS_ARGB if none.
Note that SUPPORTED_BY_FIRST is not
a really safe choice even if there is only one provider, because the image type can also
depends on tile input. However the safest choice in all cases
(SUPPORTED_BY_ALL) is costly and often not
necessary. The current implementation is a compromise between safety and performance.
If Java assertions are enabled, this reader will verify that SUPPORTED_BY_ONE
and SUPPORTED_BY_FIRST produce the same result than SUPPORTED_BY_ALL.
Subclasses can override this method if they want a different policy.
public ImageTypeSpecifier getRawImageType(int imageIndex)
throws IOException
SUPPORTED_BY_ONE, this method delegates
directly to the reader of an arbitrary tile (typically the first one).SUPPORTED_BY_ALL, this method invokes
getRawImageType for every tile readers, omits the types that are not declared
in getImageTypes(imageIndex) for
every tile readers, and returns the most common remaining value. If none is found,
then some default specifier is returned.
getRawImageType in class ImageReaderimageIndex - The image index, from 0 inclusive to getNumImages(boolean) exclusive.
IOException - If an error occurs reading the information from the input source.
public Iterator<ImageTypeSpecifier> getImageTypes(int imageIndex)
throws IOException
SUPPORTED_BY_ONE, this method delegates
directly to the reader of an arbitrary tile (typically the first one).SUPPORTED_BY_ALL, this method invokes
getImageTypes(imageIndex) on
every tile readers and returns the intersection of all sets (i.e. only the types
that are supported by every readers).
getImageTypes in class ImageReaderimageIndex - The image index, from 0 inclusive to getNumImages(boolean) exclusive.
IOException - If an error occurs reading the information from the input source.public MosaicImageReadParam getDefaultReadParam()
getDefaultReadParam in class ImageReader
public IIOMetadata getStreamMetadata()
throws IOException
null.
The default implementation returns null in all cases.
Note:
A previous implementation was iterating over every tiles and attempted to merge
the metadata using the IIOMetadata.mergeTree(String, Node) method. However
this was extremely slow on large mosaics, and the result was usually not the expected
one since the merge operation is hard to implement correctly.
getStreamMetadata in class ImageReaderIOException - if an error occurs during reading.
public IIOMetadata getImageMetadata(int imageIndex)
throws IOException
null if none.
The default implementation returns an instance of SpatialMetadata
with a "RectifiedGridDomain" node inferred from the information
returned by TileManager.getGridGeometry().
getImageMetadata in class ImageReaderimageIndex - the index of the image whose metadata is to be retrieved.
null.
IllegalStateException - if the input source has not been set.
IndexOutOfBoundsException - if the supplied index is out of bounds.
IOException - if an error occurs during reading.
public BufferedImage read(int imageIndex,
ImageReadParam param)
throws IOException
imageIndex using a supplied parameters. While optional,
it is strongly recommended to supply parameters as an instance of MosaicImageReadParam
on which param.setSubsamplingChangeAllowed(true) has been invoked.
If the above recommendation has been followed, then the supplied param object will
be modified by call to this method since the subsampling effectively used will be written
back in the given parameters.
read in class ImageReaderimageIndex - The index of the image to be retrieved.param - The parameters used to control the reading process, or null.
An instance of MosaicImageReadParam is expected but not required.
IOException - if an error occurs during reading.MosaicImageReadParam
public BufferedImage readTile(int imageIndex,
int tileX,
int tileY)
throws IOException
tileX and tileY arguments.
readTile in class ImageReaderimageIndex - The index of the image to be retrieved.tileX - The column index (starting with 0) of the tile to be retrieved.tileY - The row index (starting with 0) of the tile to be retrieved.
IOException - if an error occurs during reading.public void abort()
abort in class ImageReader
public void close()
throws IOException
close in interface CloseableIOException - if error occurred while closing a stream.public void dispose()
dispose in interface Disposabledispose in class ImageReader
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||