# [Second order edge detection operators] Laplacian and Marr-Hildreth operator

## Laplacian

First order detection is based on the differentiation of intensity within the same region to detect changes whereas the second order gets zero when the rate of change is constant. Therefore, when a zero-crossing is found, the algorithm would have found an edge.

Laplacian operator is a template which implements this. By differentiating between two adjacent pixels (first order), the second order is approximated.

Which can be translated into an horizontal (or vertical if transposed) as:

 -1 2 1

And:

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

## Marr-Hildreth operator

The Marr-Hildreth operator combines Gaussian filtering to smooth the image with Laplacian (LoG operator, Laplacian of Gauss). After the second differentiation of Gauss we have the corresponding formula to find the coefficients to the template to convolve the image with.

This function, which can be approximated by a difference of Gaussians, is called Mexican hat wavelet because of its shape:

After the image is convolved with the generated template, we have do determine the zero-crossing points. There are many techniques to achieve this goal, but a much simpler solution is shown: first we divide a 3×3 window in 4 sections as in the following picture, all of them containing the pixel in the center. The average of each section is computed, and if the maximum value is positive and the minimum is negative, a zero-crossing is found and therefore the pixel in the center will be set as white (otherwise is marked as black). This has to be applied to the whole image.

## Results

See how a simple figure changes after Laplacian is applied.

#### Laplacian

Original input

After Laplacian

In this case we would have to detect the zero-crossings to obtain the final result.

#### Marr-Hildreth

 Original
 2nd derivative Gaussian: {size: 3, sigma: 0.7}
 2nd derivative Gaussian: {size: 5, sigma: 0.7}
 2nd derivative Gaussian: {size: 7, sigma: 0.7}
 2nd derivative Gaussian: {size: 9, sigma: 0.7}
 2nd derivative Gaussian: {size: 5, sigma: 0.5}
 2nd derivative Gaussian: {size: 5, sigma: 0.6}
 2nd derivative Gaussian: {size: 5, sigma: 0.8}
 2nd derivative Gaussian: {size: 5, sigma: 0.9}
 2nd derivative Gaussian: {size: 5, sigma: 1}

The code is provided in the Source code section.

## References

1. M. Nixon and A. Aguado. 2008. “First order edge detection operators”, Feature Extraction & Image Processing.

#### lipman

"The only way to proof that you understand something is by programming it"