自定义过滤器

public static void CustomConvolutionFilter(IRaster raster)

{

    //The following code sample sets up a horizontal line detection filter and applies it on a raster

    //to create a convolution filter using a custom kernel.

    IRasterConvolutionFilter newFilter = new RasterConvolutionFilterClass();

    newFilter.SetSize(3, 3);

    double[] kernel = new double[9]

    {

         - 1,  - 1,  - 1, 2, 2, 2,  - 1,  - 1,  - 1

    };

    newFilter.PutCoefficients(ref kernel);



    //Apply the filter to the raster.

    IPixelOperation pixelOperation = (IPixelOperation)raster;

    pixelOperation.PixelFilter = (IPixelFilter)newFilter;



    //Save the result.

    ISaveAs saveas = (ISaveAs)raster;

    saveas.SaveAs(@"c:\temp\convolution_output.img", null, "IMAGINE Image");

}

你可能感兴趣的:(自定义)