Explore how to perform image kernel processing with Aspose.Imaging for .NET. These samples demonstrate using convolution filters, custom kernels, and built‑in blur filters in C#. Learn to apply a convolution filter dotnet style, validate kernel dimensions, and integrate kernel filter C# code into your projects.
- Apply a predefined 5×5 blur (box) filter to a PNG image.
- Create and use a custom 3×3 convolution matrix on a JPEG file.
- Validate that a custom 7×7 kernel has odd dimensions before processing a PNG.
- Work with
GaussianBlurFilterOptionsfor smooth blur effects. - Inspect and modify
ConvolutionFilterOptionsfor advanced image kernel processing.
using Aspose.Imaging;
using Aspose.Imaging.ImageOptions;
using Aspose.Imaging.Filters;
// Load a PNG from the Templates folder
using (RasterImage image = (RasterImage)Image.Load("Templates/sample.png"))
{
// Apply the built‑in 5×5 blur box filter
var blurOptions = new GaussianBlurFilterOptions
{
Radius = 2.5f, // radius defines the blur strength
KernelSize = 5 // 5×5 kernel
};
image.ApplyFilter(blurOptions);
image.Save("output/blurred.png");
}The snippet loads an image, applies a predefined blur kernel, and saves the result— the most common kernel filter operation.
Examples and tasks in this folder:
- Aspose.Imaging for .NET – install via NuGet:
Install-Package Aspose.Imaging - .NET 9.0 or later