How it works...

OpenCV's cv2.filter2d function takes an input image, output result datatype, OpenCV ID (-1, if you want to keep the input image datatype), and filter kernel; then, image is filtered linearly.

In this recipe, we constructed a sharpening kernel that should emphasize high frequencies in the source image. The following output is expected:

Get OpenCV 3 Computer Vision with Python Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.