Emboss Filters
Emboss Kernel Filter
In this example, we manipulate pixel values based on their surrounding counterparts. The resulting pixel values are proportionally diminished relative to the values of the top-left surrounding pixels and increased in correspondence to the bottom-right corner surroundings. Essentially, brighter top-left pixels lead to a greater decrease in value, while a brighter bottom-right pixel results in an increase in value. The maximum value of 255 represents white, and 0 corresponds to black color. If the result exceeds 255, it is capped at 255, and values below 0 are adjusted to 0. The sum of all matrix coefficients remains equal to 1, ensuring that the overall brightness of the image stays constant.
// emboss3x3 kernel
double[,] customKernel = new double[,]
{
{ -2, -1, 0, },
{ -1, 1, 1, },
{ 0, 1, 2, },
};
Hence, the image edges and contours are visually enhanced, acquiring more shadow from the top-left side and increased light from the bottom-right side. This image effect, known as the "Emboss" filter, relates the appearance of the image being embossed or elevated from the background. The result is a visual illusion of depth and texture.
C# code example
The following C# code example demonstrates the usage of the Aspose.Imaging .NET API. You can employ the `ConvolutionFilter` class, which offers predefined kernel filters "Emboss3x3" and "Emboss5x5" with different kernel matrix sizes. Additionally, you have the flexibility to create your custom kernel matrix. In this code example, image templates in PNG and SVG formats are loaded from the "templates" folder, and filters are applied from a predefined list.