Filters for edge detection

Filters for edge detection

In image processing, edge detection filters stand as indispensable tools, particularly for tasks requiring precise measurements and structural analysis. Filters can be used for identifying boundaries in medical images, identifying vessels and ridges or even networks in dermoscopic images.

Canny and Sobel filters are widely used as edge detection techniques. They allow to identify boundaries by analyzing areas of significant intensity change. The Sobel filter is a discrete differentiation operator, computing an approximation of the gradient of the image intensity function. It consists of two 3x3 convolution kernels, one for detecting vertical changes and the other for horizontal changes, resulting in two separate gradient images. The Sobel filter is simple to implement and computationally efficient but can be sensitive to noise.

The Canny filter is a more sophisticated algorithm for edge detection, developed by John F. Canny in 1986. The algorithm includes:

  • Gaussian blurring for noise reduction.
  • Gradient calculation : Sobel filters are applied to compute the gradient magnitude and direction.
  • Non-maximum suppression to thin out the edges by preserving only the local maxima in the gradient magnitude image :

On this figure, Point A is along the vertical edge, with the gradient direction perpendicular to this edge. Points B and C are along the gradient directions. Point A is compared with points B and C to determine if it constitutes a local maximum. If it does, it is retained for further processing; otherwise, it is set to zero.

  • Edge tracking by hysteresis to finalize the detection by suppressing weak edges that are not connected to strong edges

Another popular edge detection technique is the Laplacian of Gaussian (LoG) filter. This filter first applies Gaussian smoothing to the image to reduce noise and then computes the Laplacian to highlight regions of rapid intensity change. By changing the standard deviation of the Gaussian kernel, the LoG filter can detect edges at different levels of detail.

Difference of Gaussian (DoG) is another edge detection technique that works similarly to the Laplacian of Gaussian filter but uses the difference between two Gaussian-blurred images at different scales. By subtracting one blurred image from another, the DoG filter enhances edges while suppressing noise. The larger the difference between the two sigma values, the more elements will be highlighted. In order to highlight really small details, the difference must be low.

Finally, Meijering's vesselness filter has a slightly different and more specific purpose. It was specifically designed for enhancing linear structures, such as blood vessels in medical images or any continuous ridges (neurites, wrinkles, rivers,…). It measures the probability of a structure being vessel-like based on its eigenvalues. The filter enhances elongated structures with high contrast, making it suitable for extracting networks from images.

Each of these filters is different,having strengths and weaknesses. The choixe of filter depends on each purpose and its specific requirements. Experimentation and understanding the underlying principles of each filter are crucial for achieving optimal results in edge detection applications.


Meijering, E., Jacob, M., Sarria, J.-.-C.F., Steiner, P., Hirling, H.  and Unser, M. (2004), Design and validation of a tool for neurite  tracing and analysis in fluorescence microscopy images. Cytometry, 58A:  167-176.

OpenCV documentation.