Sharpen Filters
Sharpen Kernel Filter in Java
To achieve a Sharpen image effect, formulate a kernel matrix that amplifies pixel values in relation to their surroundings. In this instance, the central element is attributed a value nine times higher than its surroundings, with a subtraction applied for the eight adjacent pixels. This setup ensures that the total sum of coefficients remains at 1, thereby preserving the original brightness. The impact is more noticeable when neighboring pixels exhibit variations, accentuating the contrast between pixels and augmenting the sharpness of the image.
// sharpen 3x3 custom kernel
{
{ -1, -1, -1,},
{ -1, 9, -1,},
{ -1, -1, -1,},
};
The Sharpen effect enhances an image by highlighting pixel contrasts, leading to improved image detail and overall visual clarity.
Java code example
The provided Java code example demonstrates the utilization of the Aspose.Imaging for Java API. Utilize the `ConvolutionFilter` class, which provides pre-defined kernel filters, including "Sharpen3x3" and "Sharpen5x5," each with different kernel matrix sizes. Moreover, you retain the flexibility to craft your custom kernel matrix. Within this example, image templates in PNG and SVG formats are loaded from the "templates" folder, and a set of filters are applied from a predefined list.