AGI STK Graphics 11 Send comments on this topic.
IAgStkGraphicsConvolutionFilter Interface





Description

Applies convolution to the source raster. Convolution is the modification of a pixel's value based on the values of its surrounding pixels. The Kernel is the numerical matrix that is applied to each pixel in this process. The convolution operation is discussed in more detail in numerous texts on image processing and useful convolution kernels are widely available from various sources.

Public Properties

Public Property Divisor Gets or sets the divisor for the result of the convolution kernel operation.
Public Property Kernel Gets or sets the convolution kernel of the filter. The array contains the 9 elements of the Kernel of the convolution matrix. The elements are provided as the entire first row, followed by the entire second row, followed by the entire third row, each from left to right.
Public Property Offset Gets or sets the offset for the result of the convolution kernel operation. The value is added to the result of the operation.

Example

Blur an image with a convolution matrix
[C#] Copy Code
IAgStkGraphicsSceneManager manager = ((IAgScenario)root.CurrentScenario).SceneManager; 
IAgStkGraphicsScreenOverlayCollectionBase overlayManager = (IAgStkGraphicsScreenOverlayCollectionBase)manager.ScreenOverlays.Overlays; 
// 
// The URI can be a file path, http, https, or ftp location 
// 
IAgStkGraphicsRaster image = manager.Initializers.Raster.InitializeWithStringUri( 
    imageFile); 
 
// 
// Set convolution matrix to blur 
// 
Array kernel = new object[] 
    { 
        111
        111
        111 
    }; 
IAgStkGraphicsConvolutionFilter convolutionMatrix = manager.Initializers.ConvolutionFilter.InitializeWithKernelAndDivisor(ref kernel, 9.0); 
image.ApplyInPlace((IAgStkGraphicsRasterFilter)convolutionMatrix); 
 
IAgStkGraphicsRendererTexture2D texture = manager.Textures.FromRaster(image); 
 
// 
// Display the image using a screen overlay 
// 
IAgStkGraphicsTextureScreenOverlay overlay = manager.Initializers.TextureScreenOverlay.Initialize(); 
((IAgStkGraphicsOverlay)overlay).Width = 0.2
((IAgStkGraphicsOverlay)overlay).WidthUnit = AgEStkGraphicsScreenOverlayUnit.eStkGraphicsScreenOverlayUnitFraction; 
((IAgStkGraphicsOverlay)overlay).Height = 0.2
((IAgStkGraphicsOverlay)overlay).HeightUnit = AgEStkGraphicsScreenOverlayUnit.eStkGraphicsScreenOverlayUnitFraction; 
((IAgStkGraphicsOverlay)overlay).Origin = AgEStkGraphicsScreenOverlayOrigin.eStkGraphicsScreenOverlayOriginBottomLeft; 
overlay.Texture = texture; 
 
overlayManager.Add((IAgStkGraphicsScreenOverlay)overlay); 
 

Blur an image with a convolution matrix
[Visual Basic .NET] Copy Code
Dim manager As IAgStkGraphicsSceneManager = DirectCast(root.CurrentScenario, IAgScenario).SceneManager
Dim overlayManager As IAgStkGraphicsScreenOverlayCollectionBase = DirectCast(manager.ScreenOverlays.Overlays, IAgStkGraphicsScreenOverlayCollectionBase)
'
' The URI can be a file path, http, https, or ftp location
'
Dim image As IAgStkGraphicsRaster = manager.Initializers.Raster.InitializeWithStringUri( _
    imageFile)

'
' Set convolution matrix to blur
'
Dim kernel As Array = New Object() {1, 1, 1, 1, 1, 1, _
 1, 1, 1}
Dim convolutionMatrix As IAgStkGraphicsConvolutionFilter = manager.Initializers.ConvolutionFilter.InitializeWithKernelAndDivisor(kernel, 9.0)
image.ApplyInPlace(DirectCast(convolutionMatrix, IAgStkGraphicsRasterFilter))

Dim texture As IAgStkGraphicsRendererTexture2D = manager.Textures.FromRaster(image)

Dim overlay As IAgStkGraphicsTextureScreenOverlay = manager.Initializers.TextureScreenOverlay.Initialize()
DirectCast(overlay, IAgStkGraphicsOverlay).Width = 0.2
DirectCast(overlay, IAgStkGraphicsOverlay).WidthUnit = AgEStkGraphicsScreenOverlayUnit.eStkGraphicsScreenOverlayUnitFraction
DirectCast(overlay, IAgStkGraphicsOverlay).Height = 0.2
DirectCast(overlay, IAgStkGraphicsOverlay).HeightUnit = AgEStkGraphicsScreenOverlayUnit.eStkGraphicsScreenOverlayUnitFraction
overlay.Texture = texture
DirectCast(overlay, IAgStkGraphicsOverlay).Origin = AgEStkGraphicsScreenOverlayOrigin.eStkGraphicsScreenOverlayOriginBottomLeft

overlayManager.Add(DirectCast(overlay, IAgStkGraphicsScreenOverlay))

CoClasses that Implement IAgStkGraphicsConvolutionFilter

© 2016 All Rights Reserved.

STK Programming Interface 11.0.1