Emboss Filters

Emboss Kernel Filter in Java

         In this instance, we manipulate pixel values based on their adjacent counterparts. The resultant pixel values are proportionally reduced concerning the values of the left neighboring pixels and elevated by the surroundings on the right side. Substantially, brighter left pixels lead to a more significant decrease in value, while a brighter right pixel results in an increase in value. The maximum value of 255 denotes white, and 0 corresponds to black. If the outcome surpasses 255, it is capped at 255, and values below 0 are adjusted to 0. The total sum of all matrix coefficients remains constant at 1, ensuring that the overall brightness of the image remains consistent.

// emboss3x3 custom kernel
{
    { -1,  0,  1, },
    { -2,  1,  2, },
    { -1,  0,  1, },
};

         As a result, the visual enhancement of image edges and contours occurs, with excessive shadow from the dark side and increased light on the bright side. This particular image effect, recognized as the "Emboss" filter, imparts the impression of the image being embossed or raised from the background. The outcome creates a visual illusion of depth and texture.

Original image
Emboss filter
Original photo before emboss filter
Emboss 3x3 custom kernel filter in Java
Emboss 3x3 kernel filter

Java code example

         The provided Java code example showcases the utilization of the Aspose.Imaging for Java API. Utilize the `ConvolutionFilter` class, which provides pre-defined kernel filters such as "Emboss3x3" and "Emboss5x5," each with distinct kernel matrix sizes. Moreover, you retain the flexibility to craft your personalized kernel matrix. Within this code snippet, image templates in PNG and SVG formats are loaded from the "templates" folder, and a set of filters are applied from a predefined list.