loading...

Introduction to Aspose.Imaging, Part 4.

nnevod profile image Dmitry Matuzko ・2 min read

Part 1

Part 2

Part 3

In this article I will describe one of the most important features of Aspose.Imaging, filtering images, and what filters are availible.

Filtering images

Applying a filter to image is very simple, just create a descendant of FilterOptionsBase and pass it to RasterImage's Filter method:

// Load the image
using (Image image = Image.Load(dataDir + "asposelogo.gif"))
{
    // Convert the image into RasterImage, Pass Bounds[rectangle] 
    // of image and GaussianBlurFilterOptions instance to Filter method and Save the results
    RasterImage rasterImage = (RasterImage)image;
    rasterImage.Filter(rasterImage.Bounds, new GaussianBlurFilterOptions(5, 5));
    rasterImage.Save(dataDir + "BlurAnImage_out.gif");
}

So you can perform filtering of only a part of image if you need to.

Filter types

There are several supported filters. First, there are MedianFilterOptions which specify median filter, BigRectangularFilterOptions and SmallRectangularFilterOptions - different kinds of box filter, BilateralSmoothingFilterOptions, which, namely, does bilateral smoothing, two kinds of convolutional filters - GaussianBlurFilterOptions and SharpenFilterOptions, again with descriptive names, and the most interesting ones are deconvolutional filters that perform Wiener deconvolution - GaussWienerFilterOptions, that removes Gaussian blur, and MotionWienerFilterOptions, that removes motion blur.
BigRectangularFilterOptions and SmallRectangularFilterOptions are parameterless.
MedianFilterOptions requires filter box size to create.
BilateralSmoothingFilterOptions can be created without parameters or with kernel size as parameter.
GaussianBlurFilterOptions can be created without parameters with default values, or you can provide filter radius and sigma.
Same applies to SharpenFilterOptions.
GaussWienerFilterOptions also can be created default, or with filter radius and sigma - if you know the parameters with which the blur was applied.
MotionWienerFilterOptions is created with length, angle, that are defining the blur vector and smoothing factor of the blur, so you can tune optimum parameters for removing motion blur from image.

That's all for now, stay tuned!

For more examples please visit the Aspose.Imaging GitHub page. There's also Twitter and Facebook pages for news on Aspose.Imaging.

Posted on by:

Discussion

pic
Editor guide