|
Java Advanced Imaging API
Contents
Feedback
This release of the JAI specification contains no API
changes from the 1.0 release. The reference implementation, called Java
Advanced Imaging 1.0.2, contains bug fixes and performance
improvements.
The Java Advanced Imaging API home page is located at
http://java.sun.com/products/java-media/jai/. There you will find
binaries, documentation, answers to freqeuently asked questions, and
other information.
Two small API additions were made to the unofficial classes in the
com.sun.media.jai.codec package.
The changes are described in the "What's New" section of this
document.
This version of Java Advanced Imaging requires the following:
- For Solaris operating environment:
- Solaris operating environment 2.5.1 or subsequent compatible
version
- Java 2 platform, Standard Edition
- Java 2 SDK Reference Implementation, v. 1.2 or later
- Java 2 SDK Solaris Production Release, v. 1.2.1_04 or later
- At least 8 Mbytes of free disk space for the SPARC platform, or
at least 5 Mbytes of free disk space for the X86 platform.
- Optionally, an additional 5 Mbytes of free disk space for the
sample code and images.
- An additional 10 Mbytes may be needed temporarily during the installation
process.
- For Microsoft Windows:
- Windows NT 4.0 or Windows 95
- Java 2 platform, FCS version (JDK 1.2 FCS) or later
- At least 5 Mbytes of free disk space.
- Optionally, an additional 5 Mbytes of free disk space for the
sample code and images.
- An additional 10 Mbytes may be needed temporarily during the installation
process.
All areas of the core JAI specification have been implemented for
this release. The com.sun.media.jai.codec package
(formerly named javax.media.jai.codec) continues not to
be a committed part of JAI. These classes should continue to be
considered provisional and exist only as helper classes for the JAI
implementation.
Sun has submitted a JSR (Java Specification Request) for image I/O
and will be developing a specification and a reference implementation
under the Java Community Process. The results of this process will
replace the temporary I/O helper classes shipped as part of this
release in the com.sun.media.jai.codec package. The JSR
may be found at http://java.sun.com/aboutJava/communityprocess/jsr/jsr_015_iio.html.
All operators outlined in the Java Advanced Imaging API
specification are implemented in the 1.0.2 implementation.
Some known bugs exist - see the BUGS
file for details.
The major areas of JAI functionality are described below:
- Tiling
Images are made up of tiles. Different images may have different tile
sizes. Each tile can be processed and stored in memory separately. Tiles
may be stored in a centrally-maintained cache for performance. The
use of tiling also facilitates the use of multiple threads for computation.
- Deferred execution
Image operations performed on an image do not take place immediately
when they are applied. Calculation of pixels happens only when a
portion of the resultant image is requested, and only tiles that are
needed are processed. However, operations always appear to be
completed immediately.
- Threaded Computation
Requests for tiles are given to several running threads, allowing
potential speedups on multi-processor systems or when requesting
data over the network.
- Object-Oriented Extensibility
Users can add their own image operators or override existing operators
by registering the new operators with the operation registry. Please
see the "The Java Advanced Imaging API White Paper," the API
documentation, the JAI tuorial, and the sample code for more
information.
Additionally, users may extend a number of non-image classes in
order to add functionality to JAI:
- Border Extension
Operators may obtain an extended view of their sources using an extensible
mechanism for generating pixel values outside of the source image bounds.
New subclasses of BorderExtender may be used to obtain
customized functionality.
- Image Warping
Subclasses of Warp may be written to perform customized
image warping.
- Pixel Interpolation
Subclasses of Interpolation may be written to perform customized
pixel interpolation.
Graphics2D-Style Drawing
The TiledImageGraphics class provides the drawing
functionality of the Graphics2D class for images that are
instances of the TiledImage class. The
RenderableGraphics class provides a way to store a
sequence of drawing commands and to "replay" them at an arbitrary
output resolution.
- Regions of interest (ROIs)
Non-rectangular portions of an
image may be specified using a ROI or
ROIShape object. These ROIs may be used as parameters to
the Extrema, Mean or Histogram
operations and the TiledImage.set and
TiledImage.setData methods. Operations produce an
appropriate ROI property on their output when one exists
on their input.
Due to a bug in the FCS version of Java 1.2 (Java 2),
initialization of a ROIShape from an Area is
not performed correctly. This prevents methods such as
add(), subtract(), intersect(),
and exclusiveOr() from functioning correctly.
- Image file handling
This release of Java Advanced Imaging supports BMP, FlashPIX, GIF,
JPEG, PNG, PNM, and TIFF images as defined in the TIFF 6.0
specification. TIFF G3, G4, PackBits and LZW compression types are
understood.
The classes dealing with image file handling (the
com.sun.media.jai.codec package and private implementation
packages that provide support for it) have been separated into a new
jar file, jai_codec.jar. This jar file may be used
separately from the jai_core.jar file containing the
javax.media.jai, javax.media.jai.iterator,
javax.media.jai.operator, and
javax.media.jai.widget packages as well as their
supporting packages.
As described in the Core
Functionality section of this document, the image codec classes
should be considered as temporary helper functions. They will be
replaced by a new API for image I/O that is to be defined under the
Java Community Process.
- Image Layouts
Images with arbitrary pixel layouts may be processed in a uniform
manner using the RasterAccessor class.
Source images with ComponentColorModels and
IndexColorModels are supported.
DirectColorModel images are not yet supported.
Source images with SampleModel types other
than ComponentSampleModel have not been extensively tested.
ComponentSampleModel/ComponentColorModel sources
are processed most efficiently by RasterAccessor.
- Image Collections
The output of a standard image operator on an instance of
java.util.Collection is a collection of the same type.
Nested collections are supported. Operators may also emit collections
of their choice, or take collections as sources and emit a single
image.
- Remote Imaging
Image operator chains may be evaluated on remote hosts, with the
final pixels being transferred to the local host over the network. A
local image may be served to remote hosts tile-by-tile.
Note that the "fileload" operation may not be used to load images
remotely if the image file is not visible to the client file system even
if the file is visible to the server file system. Use the "URL" operation
instead for this purpose. The "filestore" operation may however be used to
store an image on a server to a file not visible from the client file system.
The "filestore" and other "immediate" operations are rendered upon
deserialization of the associated RenderedOp and should not
be created using JAI.create() if they are to be processed
remotely.
See section below for instructions on how to use remote imaging in
JAI.
- Iterators
Optimized Rect and Random iterators exist as well as a
non-optimized version of the Rook iterator.
- Snapshotting of External Sources
SnapshotImage provides an arbitrary number of synchronous
views of a possibly changing WritableRenderedImage.
The following image operators are implemented in this release. Only a
brief description of each operator is provided here. For detailed
information on these operators, refer to their full documentation,
available at http://java.sun.com/products/java-media/jai/docs/index.html.
All operations are performed on a per-band basis, unless specified
otherwise.
| Point and Arithmetic Operators |
| |
| absolute |
Computes the absolute value of the pixels of an image.
|
| add |
Adds the pixel values of two source images.
|
| addcollection |
Adds a collection of images to one another. |
| addconst |
Adds a set of constant values to the pixel values of a
source image. |
| addconsttocollection |
Adds a set of constant values to the pixel values of a Collection of
source images. |
| and |
And's the pixel values of two source images. |
| andconst |
And's the pixel values of a source image with a set of constants. |
| bandcombine |
Computes a linear combination of the bands of an image. |
| bandselect |
Selects a subset of the bands of an image, possibly reordering
them. |
| clamp |
Set all pixel values below the low value to that low value, set
all the pixel values above the high value to that high value. |
| colorconvert |
Converts an image to a given ColorSpace. |
| composite |
Combines two images based on their alpha values at each
pixel. |
| constant |
Creates an image with constant pixel values. |
| divide |
Divides the pixel values of the first source image by the pixel
values of the second source image. |
| dividebyconst |
Divides the pixel values of a source image by a set of constants. |
| divideintoconst |
Divides a set of constants by the pixel values of a source
image. |
| exp |
Computes the exponential of the pixel values of an image. |
| format |
Performs reformatting on an image, including data type casting,
replacing the SampleModel and ColorModel, and
restructuring the tile grid. |
| invert |
Inverts the pixel values of an image. |
| log |
Computes the natural logarithm of the pixel values of an image. |
| lookup |
Performs general table lookup on an image. |
| matchcdf |
Performs a piecewise linear remapping of pixel values to match a
given cumulative distribution function. |
| max |
Chooses the maximum pixel values between two images. |
| min |
Chooses the minimum pixel values between two images. |
| multiply |
Multiplies the pixel values of two source images. |
| multiplyconst |
Multiplies the pixel values of a source image by a set of constants. |
| not |
Inverts the pixel values of a source image. |
| or |
Or's the pixel values of two source images. |
| orconst |
Or's the pixel values of a source image with a set of constants. |
| overlay |
Overlays one image on top of another image. |
| piecewise |
Performs piecewise linear remapping of the pixel values of an image. |
| rescale |
Performs a linear remapping of the pixel values of an image. |
| subtract |
Subtracts the pixel values of one image from those of another. |
| subtractconst |
Subtracts a set of constant values from the pixel values of an
image. |
| subtractfromconst |
Subtracts a set of constant values from the pixel values of an
image. |
| threshold |
Maps the pixel values that fall between a low and high
value to a set of constants.
|
| xor |
Xor's the pixel values of two source images.
|
| xorconst |
Xor's a source image with a set of constants.
|
| |
| Area and Geometric operators |
|---|
| |
| affine |
Performs affine image mapping. |
| border |
Adds a border around an image. |
| boxfilter |
Convolves an image using a two-dimensional box filter. |
| convolve |
Performs an MxN image convolution. |
| crop |
Extracts a subarea of an image. |
| gradientmagnitude |
Performs edge detection using orthogonal gradient masks. |
| medianfilter |
Computes the median value of a pixel neighborhood. |
| rotate |
Rotates an image about an arbitrary point. |
| scale |
Scales and translates an image. |
| shear |
Shears an image. |
| translate |
Translates an image by an integral or fractional amount. |
| transpose |
Reflects an image in a specified direction or rotates
an image in multiples of 90 degrees. |
| warp |
Performs geometric warping on an image. |
| |
| Frequency-domain, Transform, and Complex Operators |
|---|
| |
| conjugate |
Computes the complex conjugate of an image. |
| dct |
Computes the Discrete Cosine Transform of an image. |
| dft |
Computes the Discrete Fourier Transform of an image, possibly resulting in
a complex image. |
| dividecomplex |
Computes the quotient of two complex images. |
| idct |
Computes the inverse Discrete Cosine Transform of an image. |
| idft |
Computes the inverse Discrete Fourier Transform of an image. |
| magnitude |
Computes the magnitude of a complex image. |
| magnitudesquared |
Computes the squared magnitude of a complex image. |
| multiplycomplex |
Computes the product of two complex images. |
| periodicshift |
Shifts an image periodically. |
| phase |
Computes the phase angle of a complex image. |
| polartocomplex |
Creates a complex image from two images representing magnitude
and phase. |
| |
| Sourceless operators |
|---|
| |
| imagefunction |
Creates an image by evaluating a function. |
| pattern |
Creates an image consisting of a repeated pattern. |
| |
| File and Stream Operators |
|---|
| |
| awtimage |
Converts a java.awt.Image into a PlanarImage. |
| bmp |
Loads an image in BMP format. |
| encode |
Writes an image to an OutputStream. |
|
| fileload |
Loads an image from a file. |
| filestore |
Writes an image to a file in a given format. |
|
| fpx |
Loads an image in FlashPIX format. |
| gif |
Loads an image in GIF format. |
| iip |
Reads an image from a remote IIP server, performing IIP view transforms (affine, colortwist, filter, crop). |
| iipresolution |
Reads a single resolution of an image from a remote IIP server.
|
| jpeg |
Loads an image in JPEG format. |
| png |
Loads an image in PNG 1.0 or 1.1 format. |
| pnm |
Loads an image in PBM, PGM, or PPM format. |
| stream |
Loads an image from a stream. |
| tiff |
Loads an image in TIFF 6.0 format. |
| url |
Loads an image from a URL. |
| |
| Statistical operators |
|---|
| |
| extrema |
Computes the maximum and minimum pixel values of an image. |
| histogram |
Computes the histogram of an image. |
| mean |
Computes the mean pixel value of a region of an image. |
| |
| Other Operators |
|---|
| |
| errordiffusion |
Performs error diffusion color quantization using a
specified color map and error filter. |
| ordereddither |
Performs color quantization using a specified color map
and a fixed dither mask. |
| renderable |
Constructs a RenderableImage from a
RenderedImage source. |
Java Advanced Imaging extends the imaging functionality provided in
the Java 2D API, by providing a more flexible and scalable
architecture, targeted for complex, high performance imaging
requirements. The focus of this release is on providing a
working implementation of the general framework for adding
image-processing operators. We encourage you to play with the
operators we have provided, to add your own operators, and to provide
feedback to us on any problems or shortcomings with the general
framework.
Java Advanced Imaging addresses imaging performance by providing
C-based native code for some image operators, as well as the pure Java
implementations. On Sun UltraSPARC-based platforms, additional
performance is gained with hardware acceleration for those operators.
The following operators have native acceleration for at least some
cases:
- arithmetic operators (add, subtract, multiply, divide)
- logical operators (and, not, or, xor)
- absolute
- affine
- bandcombine
- bandselect
- composite
- convolve (general and separable cases)
- dct/idct
- dft/idft
- exp
- extrema
- gradientmagnitude
- invert
- log
- lookup
- max/min
- mean
- medianfilter
- rescale
- rotate
- scale
- shear
- threshold
- translate
- transpose
- warp (polynomial and grid)
For more information on RMI (remote method invocation) please
refer to:
http://java.sun.com/products/jdk/rmi/index.html
1. Create a Security Policy File
If $JAI is the base directory where Java Advanced
Imaging is installed, create a text file named
$JAI/policy containing the following:
grant {
// Allow everything for now
permission java.security.AllPermission;
};
Note that this policy file is for testing purposes only.
For more information on policy files and permissions please see:
http://java.sun.com/products/jdk/1.2/docs/guide/security/PolicyFiles.html
http://java.sun.com/products/jdk/1.2/docs/guide/security/permissions.html
2. Start the RMI Registry
Log in to the remote machine where the image server will be
running and start the RMI registry. For example, in the Solaris
operating environment using a Bourne-compatible shell (e.g.,
/bin/sh):
$ unset CLASSPATH
$ rmiregistry &
Note that the CLASSPATH environment variable is deliberately not set.
3. Start the JAI Remote Image Server
While still logged in to the remote server machine, set the
CLASSPATH and LD_LIBRARY_PATH environment
variables as required for JAI (see the INSTALL file) and start the
remote imaging server:
$ CLASSPATH=$JAI/lib/jai_core.jar:$JAI/lib/jai_codec.jar:\
$JAI/lib/mlibwrapper_jai.jar
$ export CLASSPATH
$ LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$JAI/lib
$ export LD_LIBRARY_PATH
$ java \
-Djava.rmi.server.codebase=\
"file:$JAI/lib/jai_core.jar file:$JAI/lib/jai_codec.jar" \
-Djava.rmi.server.useCodebaseOnly=false \
-Djava.security.policy=file:$JAI/policy \
com.sun.media.jai.rmi.RMIImageImpl
|
For example, when the above steps are executed on a machine with IP
address 123.456.78.90 the following is printed:
Server: using host 123.456.78.90 port 1099
Registering image server as
"rmi://123.456.78.90:1099/RemoteImageServer".
Server: Bound RemoteImageServer into
the registry.
|
4. Run the Local Application
Run the local application making sure that the
serverName parameter of any RemoteImage
constructors corresponds to the machine on which the remote image
server is running. For example, if the machine with IP address
123.456.78.90 above is named myserver the
serverName parameter of any RemoteImage()
constructors should be "myserver".
The Java Advanced Imaging API White Paper, the HTML document of
the API, and a programmer's guide "Programming in Java Advanced
Imaging" as well as a quick-reference guide can be found at
http://java.sun.com/products/java-media/jai/docs/
This section describes the significant changes and improvements to the
Java Advanced Imaging API and its reference implementation since the
previous release.
Changes from 1.0.1 to 1.0.2 implementation
|