Monday, March 15, 2010

New BorderExtender and Number handling classes

Two new BorderExtender classes have been added to jai-tools 1.1-SNAPSHOT:

RandomBorderExtender generates an image border with uniform random pixel values sampled from a user-specified range.

SamplingBorderExtender generates pixel values by randomly sampling the source image within a threshold distance of each border pixel.

You'll find these classes in the utils module, jaitools.imageutils package and you can use them in any JAI operation that accepts a BorderExtender in the RenderingHints. They're brand new so I'd welcome your comments, suggestions, bug reports etc.

Also in that module is the jaitools.numeric.NumberOperations class. This used by the new BorderExtenders but is also available for general use. It provides a number of static helper methods for working with Number objects without having to type-narrow them. For instance:

// Add two Number objects. The return value will be an instance of the
// highest ranking class of the two arguments (e.g. Byte + Integer will
// give an Integer result)
Number n1 = ...
Number n2 = ...
Number sum = NumberOperations.add(n1, n2);

You can checkout the source code for jai-tools 1.1-SNAPSHOT with your favourite subversion client from

See the jai-tools project site for details on how to use the 1.1-SNAPSHOT jars in your project, either using Maven or manual download.

No comments:

Post a Comment