Emboss Filter

The emboss filter creates a 3D like effect on an image which provides some useful features such as enhanced depth and edge outlining. There are several ways of constructing the emboss kernel. Below is one example:

$$ \begin{pmatrix} -2 & -1 & 0 \\ -1 & 1 & 1 \\ 0 & 1 & 1 \end{pmatrix} $$

Let's see the kernel in action against the image of the status of liberty.

import cv2
import numpy as np
import matplotlib.pyplot as plt

%matplotlib inline
%config InlineBackend.figure_format = 'retina'
img = cv2.imread('statue_of_liberty.jpg')
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)

# plot the image
plt.imshow(img)
plt.axis('off')
Emboss filter for 3D Effect
emboss_kernel = np.array([ 
    [-2, -1, 0],
    [-1,  1, 1],
    [ 0,  1, 1]])
#emboss the image
emboss_statue = cv2.filter2D(img, -1, emboss_kernel)

#plot the image 
plt.figure(figsize=(5,4))
plt.imshow(emboss_statue)
plt.axis('off')
Emboss filter for 3D Effect