Applying directional filters to detect edges

The first recipe of this chapter introduced the idea of linear filtering using kernel matrices. The filters used had the effect of blurring an image by removing or attenuating its high-frequency components. In this recipe, we will perform the opposite transformation that is amplifying the high-frequency content of an image. As a result, the high-pass filters introduced here will perform edge detection.

How to do it...

The filter we will use here is called the Sobel filter. It is said to be a directional filter because it only affects the vertical or the horizontal image frequencies depending on which kernel of the filter is used. OpenCV has a function that applies the Sobel operator on an image. The ...

Get OpenCV 2 Computer Vision Application Programming Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.