Package org.geotools.image.io

Extensions to ImageReader for binary and ASCII files.

See:
          Description

Class Summary
IIOListeners A container of image I/O listeners.
IIOReadProgressAdapter An abstract adapter class for receiving image progress events.
PaletteFactory A factory class for IndexColorModel objects.
RawBinaryImageReader Deprecated. Use Sun's RAW decoder provided with "Java Advanced Imaging Image I/O Tools" instead.
RawBinaryImageReader.Spi Service provider interface (SPI) for RawBinaryImageReaders.
RawBinaryImageReadParam Deprecated. Use Sun's RAW decoder provided with "Java Advanced Imaging Image I/O Tools" instead.
SimpleImageReader Base class for simple image decoders.
TextImageReader Base class for text image decoders.
TextImageReader.Spi Service provider interface (SPI) for TextImageReaders.
TextMatrixImageReader An image decoder for matrix of floating-point numbers.
TextMatrixImageReader.Spi Service provider interface (SPI) for TextMatrixImageReaders.
TextRecordImageReader Image decoder for text files storing pixel values as records.
TextRecordImageReader.Spi Service provider interface (SPI) for TextRecordImageReaders.
 

Package org.geotools.image.io Description

Extensions to ImageReader for binary and ASCII files. Image I/O extensions are provided as part of Grid Coverage implementation. The gt2-coverage.jar file declares a service provider for the following image readers:

ImageReader subclass Name MIME type
RawBinaryImageReader raw image/raw
TextMatrixImageReader matrix text/matrix
TextRecordImageReader gridded records text/x-grid

SimpleImageReader is the base class for image decoders reading stream with few (if any) meta-data. Examples of such streams are matrix containing the pixels values in a binary form (RAW images), or ASCII files containing values written as decimal numbers. Such kinds of stream are not uncommon in the remote sensing field. They often contain geophysical values (e.g. temperature in Celsius degrees, elevation in metres, etc.) better represented as floating point numbers than integers. For example, a user may want to read an ASCII file containing gridded elevation on the ocean floor (left side below). TextRecordImageReader can read such file, detect automatically minimum and maximum values (in order to scale the grayscale palette) and produce the image below:

Longitude Latitude Altitude
59.9000   -30.0000   -3022
59.9333   -30.0000   -3194
59.9667   -30.0000   -3888
60.0000   -30.0000   -3888
45.0000   -29.9667   -2502
45.0333   -29.9667   -2502
45.0667   -29.9667   -2576
45.1000   -29.9667   -2576
45.1333   -29.9667   -2624
45.1667   -29.9667   -2690
45.2000   -29.9667   -2690
45.2333   -29.9667   -2692
45.2667   -29.9667   -2606
45.3000   -29.9667   -2606
45.3333   -29.9667   -2528
etc...

By default, SimpleImageReader store decoded image using data type DataBuffer.TYPE_FLOAT and a grayscale color space. This politic produce image matching closely the original data, i.e. it involves as few transformations as possible. But displaying floating-point image is usually very slow. User are strongly encourages to use Java Advanced Imaging's operations after reading in order to scale data as they see fit. The example below reformat the DataBuffer.TYPE_FLOAT data into DataBuffer.TYPE_BYTE and change the grayscale colors to an indexed color model.

 


import javax.media.jai.JAI;
import javax.media.jai.ImageLayout;
import java.awt.RenderingHints;
import java.awt.image.DataBuffer;
import java.awt.image.IndexColorModel;
import java.awt.image.renderable.ParameterBlock;

// Omitting class and method declaration...


/*
 * Prepare the indexed color model. Arrays
 * R, G and B should contains 256 RGB values.
 */
final byte[] R=...
final byte[] G=...
final byte[] B=...
final IndexColorModel colors = new IndexColorModel(8, 256, R,G,B);
final ImageLayout     layout = new ImageLayout().setColorModel(colorModel);
final RenderingHints   hints = new RenderingHints(JAI.KEY_IMAGE_LAYOUT, layout);

/*
 * Rescale the image.   First, all pixels values are transformed using
 * the equation pi=CO+C1*p. Then, type float is clamp to type byte and
 * the new index color model is set.   Displaying such an image should
 * be much faster.
 */
final double C0 = ...
final double C1 = ...
image = JAI.create("Rescale", new ParameterBlock().addSource(image).add(new double[]{C1}).add(new double[]{C0}));
image = JAI.create("Format",  new ParameterBlock().addSource(image).add(DataBuffer.TYPE_BYTE), hints);



Copyright © GeoTools. All Rights Reserved.