Monday, 23 July 2007

Basic JAI API Classes

JAI consists of several classes grouped into four packages:
* javax.media.jai - contains the "core" JAI interfaces and classes
* javax.media.jai.iterator - contains special iterator interfaces and classes, which are useful for writing extension operations
* javax.media.jai.operator - contains classes that describe all of the image operators
* javax.media.jai.widget - contains interfaces and classes for creating simple image canvases and scrolling windows for image display

The PlanarImage class is the main class for describing two-dimensional images in JAI. PlanarImage implements the RenderedImage interface from the Java 2D API. TiledImage and OpImage, described later, are subclasses of PlanarImage.

The RenderedImage interface describes a tiled, read-only image with a pixel layout described by a SampleModel and a DataBuffer. Each tile is a rectangle of identical dimensions, laid out on a regular grid pattern. All tiles share a common SampleModel.

In addition to the capabilities offered by RenderedImage, PlanarImage maintains source and sink connections between the nodes of rendered graphs. Since graph nodes are connected bidirectionally, the garbage collector requires assistance to detect when a portion of a graph is no longer referenced from user code and may be discarded. PlanarImage takes care of this by using the Weak References API of Java 2.

Any RenderedImages from outside the API are "wrapped" to produce an instance of PlanarImage. This allows the API to make use of the extra functionality of PlanarImage for all images.

CollectionImage is the abstract superclass for four classes representing collections of PlanarImages:
* ImageStack - represents a set of two-dimensional images lying in a common three-dimensional space, such as CT scans or seismic volumes. The images need not lie parallel to one another.
* ImageSequence - represents a sequence of images with associated time stamps and camera positions. This class can be used to represent video or time-lapse photography.
* ImagePyramid - represents a series of images of progressively lesser resolution, each derived from the last by means of an imaging operator.
* ImageMIPMap - represents a stack of images with a fixed operational relationship between adjacent slices.

The TiledImage class represents images containing multiple tiles arranged into a grid.
TiledImage implements the WritableRenderedImage interface from the Java 2D API, as well as extending PlanarImage. A TiledImage allows its tiles to be checked out for writing, after which their pixel data may be accessed directly. TiledImage also has a createGraphics method that allows its contents to be altered using Java 2D API drawing calls.

The OpImage class is the parent class for all imaging operations, such as:
* AreaOpImage - for image operators that require only a fixed rectangular source region around a source pixel to compute each destination pixel
* PointOpImage - for image operators that require only a single source pixel to compute each destination pixel
* SourcelessOpImage - for image operators that have no image sources
* StatisticsOpImage - for image operators that compute statistics on a given region of an image, and with a given sampling rate
* UntiledOpimage - for single-source operations in which the values of all pixels in the source image contribute to the value of each pixel in the destination image
* WarpOpImage - for image operators that perform an image warp
* ScaleOpImage - for extension operators that perform image scaling requiring rectilinear backwards mapping and padding by the resampling filter dimensions
The OpImage is able to determine what source areas are sufficient for the computation of a given area of the destination by means of a user-supplied mapDestRect method. For most operations, this method as well as a suitable implementation of getTile is supplied by a standard subclass of OpImage, such as PointOpImage or AreaOpImage.
An OpImage is effectively a PlanarImage that is defined computationally. In PlanarImage, the getTile method of RenderedImage is left abstract, and OpImage subclasses override it to perform their operation. Since it may be awkward to produce a tile of output at a time, due to the fact that source tile boundaries may need to be crossed, the OpImage class defines a getTile method to cobble (copy) source data as needed and to call a user-supplied computeRect method. This method then receives contiguous source Rasters that are guaranteed to contain sufficient data to produce the desired results. By calling computeRect on subareas of the desired tile, OpImage is able to minimize the amount of data that must be cobbled.

The RenderableOp class provides a lightweight representation of an operation in the Renderable space. RenderableOps are typically created using the createRenderable method of the JAI class, and may be edited at will. RenderableOp implements the RenderableImage interface, and so may be queried for its rendering-independent dimensions.

The RenderedOp is a lightweight object similar to RenderableOp that stores an operation name, ParameterBlock, and RenderingHints, and can be joined into a Rendered graph

No comments: