Click or drag to resize

Rasters and Filtering

Insight3D provides a flexible Raster framework and raster processing through RasterFilters. A raster consists of one or more RasterBands, or sets of values, which are most commonly associated with colors when the raster represents an image. For instance, a typical color image contains three RasterBands (red, green, and blue) which define the color of pixels within the image. The following raster image formats can be read by the Raster class: BMP, ECW, IMG, JP2, NTF, NITF, PNG, SID, TIF, TIFF, JPG, JPEG, PPM, PGM, CLDS, and TGA. A raster can be loaded from a file, HTTP, HTTPS, or FTP source, can also be loaded from memory, or constructed from a BufferedImage.

Loading Rasters

The following code sample loads a raster from a URI:

Raster raster = new Raster(baseUri.resolve("Terrain%20and%20Imagery/colors.jp2"));

Once a raster is loaded, the defining RasterAttributes of the raster is available from the Attributes (get / set).


To create a texture from a raster, pass it to the fromRaster method.

Texture2D texture = SceneManager.getTextures().fromRaster(raster);

The RasterFilter base class allows a user to perform many image processing tasks. The following filters are provided:

In the following code sample, contrast, brightness, and gamma correction filters are initialized and applied sequentially to a satellite image to improve its visibility. The applyInPlace method will apply a filter to a raster directly. Alternatively, the apply method will leave the original raster intact and return a new raster with the results of the filtering.

// Add brightness, contrast, and gamma correction filters to sequence
SequenceFilter filter = new SequenceFilter();
filter.add(new BrightnessFilter(0.3));
filter.add(new ContrastFilter(0.5));
filter.add(new GammaCorrectionFilter(0.9));

Raster Before Filtering
Satellite imagery before filtering.
Raster After Filtering
Satellite imagery after applying brightness, contrast, and gamma correction filters.

ConvolutionFilter is a very generic filter which can be used for a much larger variety of effects. In the following code sample, a custom convolution filter is applied to sharpen the color-corrected imagery above.

// Apply a convolution matrix to sharpen the Raster
ConvolutionFilter convolutionFilter = new ConvolutionFilter();
convolutionFilter.setKernel(new Matrix3By3(0.0, -1.0, 0.0,
                                           -1.0, 5.0, -1.0, 
                                           0.0, -1.0, 0.0));

Raster After Filtering and Convolution
Satellite imagery after applying the color correction and convolution filters above.

See the HowTo for a variety of additional raster and filtering examples.