Rasters and Filtering

STK Engine provides a flexible Raster framework and raster processing through filters. A raster consists of one or more bands, 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 bands (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 .NET Bitmap.

[C#] Copy Code
IAgStkGraphicsRaster raster = manager.Initializers.Raster.InitializeWithStringUri(imageFilePath);

Once a raster is loaded, the defining attributes of the raster are available from the Attributes property of Raster.

[C#] Copy Code

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

[C#] Copy Code
IAgStkGraphicsRendererTexture2D texture = manager.Textures.FromRaster(raster);

Satellite imagery before filtering. STK Engine's raster filters can be used to enhance the imagery.

The RasterFilter base class allows a user to perform many image processing tasks, such as adjusting brightness, contrast, and color levels, performing gamma correction, extracting and reordering bands, and geometric transformation. More generic filters, such as the convolution filter, can be used to achieve a large number of effects, including sharpening, edge detection and gradient detection.

The SequenceFilter filter can be used to concatenate and efficiently apply filters sequentially to a raster. Below, contrast, brightness, and gamma correction filters are initialized and applied sequentially to the above 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#] Copy Code
// Add brightness, contrast, and gamma correction filters to sequence
IAgStkGraphicsSequenceFilter sequenceFilter = manager.Initializers.SequenceFilter.Initialize();

The initial satellite imagery after applying brightness, contrast, and gamma correction filters.

STK Engine provides numerous filters for a variety of image processing tasks. By providing generic filters such as ConvolutionFilter, a much larger variety of effects can be achieved. Below, a custom convolution filter is applied to sharpen the color-corrected imagery above.

[C#] Copy Code
//Apply a convolution matrix to sharpen the Raster
Array kernel = new object[]
     0, -1, 0,
     -1, 5, -1,
     0, -1, 0
IAgStkGraphicsConvolutionFilter convolutionMatrix = manager.Initializers.ConvolutionFilter.InitializeWithKernel (ref kernel);

The initial satellite imagery after applying the color correction and convolution filters above.

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

STK Engine for UNIX 11.3.0