My favorites | Sign in
Project Logo
Project hosting will be READ-ONLY Wednesday at 8am PST due to brief network maintenance.
                
Search
for
Updated Jul 14, 2009 by michael.bedward
RangeLookup  
A lookup transformation based on source image value ranges

RangeLookup operator

module: rangelookup
package: jaitools.media.jai.rangelookup

Description

This is a variation on the JAI Lookup operation. It works with a RangeLookupTable object in which each entry maps a source image value range to a destination image value.

The lower and upper bounds of the range may be open or closed. If closed they may include their defining value or exclude it.

The RangeLookupTable has two constructors. The first takes no arguments: a table created with this constructor will throw an IllegalStateException if it encounters a source image value that is not contained within any of the ranges in the table. The second constructor takes an argument for default value: if set to a non-null value, this value will be written to the destination image whenever a source image value is not contained within any of the ranges in the table. If set to null, the table will behave as if created with the no-argument constructor.

RangeLookup vs Lookup

The per-band offset values that can be defined for Lookup do not exist for RangeLookup.

The Range class used by the RangeLookup operator allows you to define a point range, ie. one where the lower and upper bounds are the same. With this, you can peform Lookup-style single value lookups with float and double source image data.

Limitations

RangeLookup doesn't handle TYPE_USHORT: an UnsupportedOperationException will be thrown.

Presently, RangeLookup simply performs the same source-range -> destination value lookups on all bands of the source image. It also doesn't support the transformation between single and multi-band images that can be done with Lookup.

Example of use

/*
 * Perform a lookup as follows:
 *   Src Value     Dest Value
 *     x < 5            1
 *   5 <= x < 10        2
 *  10 <= x <= 20       3
 *  any other value    99
 */
RenderedImage myIntImg = ...

RangeLookupTable<Integer> table = new RangeLookupTable<Integer>(99);

Range<Integer> r = new Range<Integer>(null, true, 5, false);  // x < 5
table.add(r, 1);

r = new Range<Integer>(5, true, 10, false);  // 5 <= x < 10
table.add(r, 2);

r = new Range<Integer>(10, true, 20, true);  // 10 <= x <= 20
table.add(r, 2);

ParameterBlockJAI pb = new ParameterBlockJAI("rangelookup");
pb.setSource("source0", myIntImg);
pb.setParameter("table", table);
RenderedImage luImg = JAI.create("rangelookup", pb);

Sign in to add a comment
Hosted by Google Code