0
$\begingroup$

I find both of these 3x3 Laplacian kernels to be commonly used:

 0 -1  0
-1  4 -1
 0 -1  0

and:

-1 -1 -1
-1  8 -1
-1 -1 -1

Is there a reason to choose one or the other? What's the difference between them?

(My math is not good enough to understand the Wikipedia article, so I can't figure it out myself from reading that. Googling is failing me for this one.)

$\endgroup$
1
$\begingroup$

On a regular 2D grid of pixels, there are essentially two possibilities to look at the neighborhood of a given pixel (in black below), or pixel connectivity: the 8-pixel connectivity (left, or Moore neighborhood), and the 4-pixel connectivity (right, von Neumann neighborhood). Four- and eight-adjacencies are other common terms.

4-pixel and 8-pixel connectivity

The first one gives the same weight to all eight surrounding pixels, the second considers that the North, East, South, West gray pixels are closer (distance 1) than the ones in the corners (distance $\sqrt{2}$). Indeed, there are topological reasons. One is based on the $\ell_\infty$, $\max$ or Chebyshef distance, the other on the $\ell_1$, Taxicab or Manhattan distance.

Which regions are connected, how to design filters, are question with a different answer, and different results (see for instance 4-Neighbour vs. 8-Neighbour Graph Models of an Image).

The two $3\times 3$ Laplacian kernels are two possibilities in discretizing the continuous Laplacian along the two above options, while keeping integer values, useful with integer valued-pixels.

$\endgroup$
2
$\begingroup$

The Laplacian kernel is used for edge detection, that is a high pass filter. The 2D convolution of an image with it will "detect" or highlight big differences between pixel intensities (that is why it has negative values around a bigger positive one).

The basic difference between the kernels you wrote is that the first one will only highlight horizontal and vertical intensity differences in the image, while the second one will also detect diagonal differences.

Another important characteristic is that all its values should add to zero, so that portions of an image which had uniform values should stay uniform after the filtering.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.