|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface NamedImageStore
Interface for ImageReader and ImageWriter implementations where each image
have a name. The standard Java API uses an integer for identifying the images to be read or
written, using a zero-based numbering. But some file formats like NetCDF identify the images
by name (in the case of NetCDF, "images" are actually "variables").
This class provides a mean to map image (or variable) names to image index for use with the
ImageReader or ImageWriter API.
Common usage: names for images
If the image names can not be known a priori, then the user needs to invoke
getImageNames() and inspect the returned list. But if the user know in advance
the name of the images to be read, then a more efficient approach is to declare the names
of the image of interest. This approach avoid the need to extract the list of all image names.
The example below declares that the image named "temperature" should be assigned
to the image index 0, and the image named "salinity" to image index 1:
imageReader.setImageNames("temperature", "salinity");
BufferedImage temperature = imageReader.read(0);
BufferedImage salinity = imageReader.read(1);
If no image exist for a given name, then an ImageNameNotFoundException will be thrown
at reading time.
Alternative usage: names for bands
In some cases, it is convenient to use the variable names for band indices rather than image
indices. For example when reading geostrophic current data as a vector field,
where the variable named u is the East-West component of the vectors and the
variable named v is the North-South component, we may want to read those two
components as two bands in the same image:
Named bands, if any, have precedence over named images. By default there is no named band.imageReader.setBandNames(0, "u", "v"); BufferedImage currents = imageReader.read(0); // Two-banded image.
| coverage/geotk-coverageio (download) | View source code for this class |
| Method Summary | |
|---|---|
List<String> |
getBandNames(int imageIndex)
Returns the names of the bands for the given image, or null if none. |
List<String> |
getImageNames()
Returns the names associated to all image indices. |
void |
setBandNames(int imageIndex,
String... bandNames)
Sets the names of the bands for the given image, or null for removing any naming. |
void |
setImageNames(String... imageNames)
Sets the names to associate to all image indices. |
| Method Detail |
|---|
List<String> getImageNames()
throws IOException
ImageReader.read(imageIndex)
will read the image named imageNames.get(imageIndex) where imageNames
is the list returned by this method.
This method initially returns the list of all images contained in the underlying file.
If the setImageNames(String[]) method has been invoked with a non-null array
argument, then getImageNames() returns the names which were specified to that
setImageNames method.
null if there is no
such mapping.
IOException - if the image stream can not be read.
void setImageNames(String... imageNames)
throws IOException
ImageReader or ImageWriter API.
If a supplied image name does not exist in the file to be read or written, then an
ImageNameNotFoundException will be thrown either at setImageNames(...)
invocation time, or deferred to the first invocation of an ImageReader or
ImageWriter method expecting an image index argument.
If imageNames array is set to null, then the names will be inferred
from the content of the file. This is the default behavior.
imageNames - The set of names to be assigned to image index, or
(String[]) null for the default set of names declared in the file.
IOException - If the given names can not be assigned to this image reader or
writer, or if an I/O error occurred while processing.
List<String> getBandNames(int imageIndex)
throws IOException
null if none.
By default, this method returns null for every image index.
imageIndex - Index of the image for which to get the band names.
null
if the bands for the given image are unnamed.
IOException - if the image stream can not be read.
void setBandNames(int imageIndex,
String... bandNames)
throws IOException
null for removing any naming.
See the class-javadoc for a usage example.
imageIndex - Index of the image for which to set the band names.bandNames - The variable names of the bands for the given image,
or null for removing any naming.
IOException - If the given names can not be assigned to this image reader or
writer, or if an I/O error occurred while processing.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||