An OpImage implementing the "Lookup" operation.
This OpImage performs the general table lookup on
a source image by passing it through a lookup table. The source
image may be single- or multi-banded and of any integral data types.
The lookup table may be single- or multi-banded of any JAI supported
data types. The destination image must have the same data type as
the lookup table, and its number of bands is determined based on
the number of bands of the source and the table.
If both the source and the lookup table are multi-banded, they
should have the same number of bands. In case their band numbers
are different, if the source's number of bands is less than the
table's number of bands, the first n bands of the table
data is used, where n is the source's number of bands;
otherwise, the first band (band 0) of the table data is applied to
all the bands of the source.
The application programs may specify the layout of the
destination image via the ImageLayout parameter. If
a SampleModel is supplied, it should be created in
accordance with the source image and the actual lookup table
used in a specific case. It is strongly recommended that a
ComponentSampleModel is be used whenever possible
for better performance.
If the supplied SampleModel is unsuitable for
the source image and the lookup table type, or if no
SampleModel is specified, a default suitable
SampleModel is chosen for this operation based on
the type of source image and lookup table. In this case, a new
ColorModel is chosen based on the SampleModel .
Special case lookup operators should extend this class.
The destination pixel values are determined as:
if (srcNumBands == 1) {
// dst[y][x] has the same number of bands as the lookup table.
for (b = 0; b < dstNumBands; b++) {
dst[y][x][b] = tableData[b][src[y][x][0] + offsets[b]];
}
} else {
// src[y][x] is multi-banded, dst[y][x] has the same
// number of bands as src[y][x].
if (tableNumBands == 1) {
for (b = 0; b < dstNumBands; b++) {
dst[y][x][b] = tableData[0][src[y][x][b] + offsets[0]];
}
} else {
for (b = 0; b < dstNumBands; b++) {
dst[y][x][b] = tableData[b][src[y][x][b] + offsets[b]];
}
}
}
See Also: javax.media.jai.operator.LookupDescriptor See Also: javax.media.jai.LookupTableJAI See Also: LookupCRIF |