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 Bitmap.

Loading Rasters

The following code sample loads a raster from a URI:

C#
Raster raster = new Raster(new Uri(baseUri, "Terrain and Imagery/colors.jp2"));

Once a raster is loaded, the defining RasterAttributes of the raster is available from the Attributes.

C#
Console.WriteLine(raster.Attributes.Format);
Console.WriteLine(raster.Attributes.Type);
Console.WriteLine(raster.Attributes.Width);
Console.WriteLine(raster.Attributes.Height);
Console.WriteLine(raster.Attributes.RowStride);

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

C#
Texture2D texture = SceneManager.Textures.FromRaster(raster);
Filtering

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.

C#
// 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.ApplyInPlace(filter);
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.

C#
// Apply a convolution matrix to sharpen the Raster
ConvolutionFilter convolutionFilter = new ConvolutionFilter
{
    Kernel = new Matrix3By3(0.0, -1.0, 0.0,
                            -1.0, 5.0, -1.0,
                            0.0, -1.0, 0.0)
};

raster.ApplyInPlace(convolutionFilter);
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.