# Some common convolutions for image processing: sharpening

This is the next post in our series of convolution filter examples. We examine one method of image sharpening using the unsharp sharpening mask (unsharp filter). You can think of sharpening as the opposite of blurring. The previous post showed how blurring was like taking an average.  The process reduces the size of the differences between neighbours, causing a blurring effect.

Sharpening on the other hand, emphasises differences between neighbouring pixel values, increasing the contrast between pixels.

The unsharp filter works in 2 steps.  It identifies areas of high contrast in the image – essentially the edges.  Then, it exaggerates these contrasts, and adds them back to the original image. This gives you the intended sharpening effect.

Now the details.

# Step 1

Let S be a smoothing filter on our picture P.  Calculate a gradient image G with: $\displaystyle{G(P) := P - S(P)}$

i.e., smooth the image, and subtract it from the original image. You can use any smoothing filter, including the Box or Gaussian filters.

This gradient image G emphasises the parts where the pixel values differ a lot from the average at a particular point, i.e., where there are sharp contrasts (like where edges occur).

Original G(P), where S is the Box blur with a 3×3 kernel. G(P), where S is the Gaussian blur with a 3×3 kernel, and standard deviation of 2. # Step 2

Add a multiple of the G(P) calculated in Step 1 back to the original image P to obtain the sharpened image H. $\displaystyle{ H(P, k) := G(P) + k * G(P) }$

where $k>=1$ is the “exaggeration” factor.

This increases the contrast in parts of the image where there were lots of contrasts, with the effect of exaggerating the contrasts, hence giving a “sharper” look.

Original Sharpened image H, with a Box filter using a 3×3 kernel Sharpened image H, with a Gaussian filter using a 3×3 kernel and a standard deviation of 2 You will notice that there are sometimes artifacts in the sharpened image (like above).  In general, the more you exaggerate sharpening, the more noise you can potentially introduce.

In the next post, we will look at other examples of edge detection using convolution filters.