Creating a custom convolution filter
Use the following code example in your application:
[Java]
static void customConvolutionFilter(IRaster raster)throws Exception{
//The following code sample sets up a horizontal line detection filter and apply it on a raster
//create a convolution filter using a custom kernel
IRasterConvolutionFilter newFilter = new RasterConvolutionFilter();
double[][] kernel = new double[][]{
{
- 1, - 1, - 1, 2, 2, 2, - 1, - 1, - 1
}
};
newFilter.putCoefficients(kernel);
newFilter.setSize(3, 3);
//apply the filter to the raster
IPixelOperation pixelOperation = (IPixelOperation)raster;
pixelOperation.setPixelFilterByRef((IPixelFilter)newFilter);
//save the result
ISaveAs saveas = new ISaveAsProxy(raster);
saveas.saveAs("c:\\temp\\convolution_output.img", null, "IMAGINE Image");
}
Development licensing | Deployment licensing |
---|---|
ArcGIS for Desktop Advanced | ArcGIS for Desktop Advanced |
ArcGIS for Desktop Standard | ArcGIS for Desktop Standard |
ArcGIS for Desktop Basic | ArcGIS for Desktop Basic |
Engine Developer Kit | Engine |