Emboss Filters

Emboss Kernel Filter in Python

         In this particular case, we manipulate the values of pixels based on their proximity to neighboring pixels. The outcome involves a proportional increase in pixel values about the upper surrounding pixels and a decrease corresponding to the bottom surroundings. In essence, pixels at the top with a brighter presence lead to a more pronounced increase, while those at the bottom, with a higher brightness, result in a decrease. The numerical scale has a range from 0 to 255, where 255 represents pure white and 0 corresponds to black color. Should the outcome exceed 255, it sets to the cap at 255, and values dipping below 0 meet the threshold of 0. The cumulative sum of all matrix coefficients maintains equality to 1, ensuring a constant image brightness.

# emboss3x3 horizontal custom kernel
[
    [  2,  3,  2, ],
    [  0,  1,  0, ],
    [ -2, -3, -2, ],
]

         Consequently, the edges and contours of the image undergo a visual enhancement, gaining additional shadowing from the bottom side and heightened illumination from the upper side. This particular image effect, recognized as the "Emboss" filter, imparts an appearance alike to the image being raised from the background. The outcome yields a captivating visual illusion with a sense of depth and texture.

Original image
Emboss filter
Original photo before emboss filter
Emboss 3x3 kernel filter
Emboss 3x3 kernel filter

Python code example

         The presented Python code exemplifies the utilization of the Aspose.Imaging Python API. Use the `ConvolutionFilter` class, which provides pre-defined kernel filters like get_emboss_3x3() and get_emboss_5x5() methods with different matrix sizes. Moreover, you retain the flexibility to craft your custom kernel matrix. Within this code snippet, image templates in raster PNG and as well as vector SVG formats are loaded from the "templates" folder, and a set of filters are applied from a predefined list.