Sharpen Filters

Sharpen Kernel Filter in Python

         You can achieve a Sharpen image effect by establishing a kernel matrix that amplifies pixel values in comparison to their surroundings. In this instance, the central element is allocated a value five times greater than its adjacent pixels, accompanied by a subtraction for the four surrounding pixels. This configuration ensures that the cumulative sum of coefficients remains at 1, conserving the original brightness. The impact is more noticeable when neighboring pixels exhibit variations, accentuating the contrast between pixels and elevating the sharpness of the image.

## sharpen 3x3 kernel
[
    [  0, -1,  0 ],
    [ -1,  5, -1 ],
    [  0, -1,  0 ],
]

         The Sharpen effect improves an image by accentuating pixel contrasts, leading to enhanced image detail and better overall visual clarity.

Original image
Sharpen image
Original vector image
Sharpen 3x3 kernel filter in Python
Sharpen kernel filter

Python code example

         The provided Python code example showcases how to utilize the Aspose.Imaging Python API. Utilize the `ConvolutionFilter` class, which provides pre-defined kernel filters like get_sharpen_3x3() and get_sharpen_5x5() methods. Moreover, you retain the freedom to craft your custom kernel matrix. In this case, image templates in raster PNG and as well as vector SVG formats are loaded from the "templates" directory, and a set of filters is applied from the `kernel_filters` list.