Package org.geotools.image.io

Extensions to ImageReader for binary and ASCII files.

See:
          Description

Class Summary
FileImageReader Base class for image readers that require File input source.
GeographicImageReader Base class for readers of geographic images.
GeographicImageReadParam Default parameters for GeographicImageReader.
GeographicImageWriter Base class for writers of geographic images.
IIOListeners A container of image I/O listeners.
IIOReadProgressAdapter An abstract adapter class for receiving image progress events.
Palette A set of RGB colors created by a palette factory from a Palette.name.
PaletteFactory A factory for index color models created from RGB values listed in files.
RawBinaryImageReadParam A class describing how a raw binary stream is to be decoded.
SampleConverter Converts samples from the values stored in the image file to the values stored in the raster.
StreamImageReader Base class for simple image decoders.
StreamImageReader.Spi Service provider interface (SPI) for StreamImageReaders.
StreamImageWriter Base class for simple image encoders.
StreamImageWriter.Spi Service provider interface (SPI) for StreamImageWriters.
 

Package org.geotools.image.io Description

Extensions to ImageReader for binary and ASCII files.

StreamImageReader 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 files contain often geophysical values (e.g. temperature in Celsius degrees, elevation in metres, etc.) better represented as floating point numbers than integers.

By default, StreamImageReader stores decoded image using data type DataBuffer.TYPE_FLOAT and a grayscale color space. This politic produce images matching closely the original data, i.e. it involves as few transformations as possible. But displaying floating-point images is usually very slow. Users are strongly encouraged to use Java Advanced Imaging's operations after reading in order to scale data as they see fit. The example below reformats the DataBuffer.TYPE_FLOAT data into DataBuffer.TYPE_BYTE and changes 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 © 1996-2010 Geotools. All Rights Reserved.