[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.
[latex]f”(x) \cong f'(x) – f'(x+1) \\
f”(x) \cong -f(x) + 2f(x+1) -f(x+2)[/latex]

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.

[latex size=”2″]\Delta^2g(x,y) = \frac{1}{\sigma^2}(\frac{(x^2+y^2)}{\sigma^2}-2)e^{\frac{-(x^2+y^2)}{2 \sigma^2}}[/latex]

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

mexhat

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.

sections

Results

See how a simple figure changes after Laplacian is applied.

Laplacian

dd
Original input

im

finalimim
After Laplacian

finalim

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

Marr-Hildreth

original
Original
size3
2nd derivative Gaussian: {size: 3, sigma: 0.7}
size5
2nd derivative Gaussian: {size: 5, sigma: 0.7}
size7
2nd derivative Gaussian: {size: 7, sigma: 0.7}
size9
2nd derivative Gaussian: {size: 9, sigma: 0.7}
size5sig5
2nd derivative Gaussian: {size: 5, sigma: 0.5}
size5sig6
2nd derivative Gaussian: {size: 5, sigma: 0.6}
size5sig8
2nd derivative Gaussian: {size: 5, sigma: 0.8}
size5sig9
2nd derivative Gaussian: {size: 5, sigma: 0.9}
size5sig10
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.

Juan Miguel Valverde

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

One thought to “[Second order edge detection operators] Laplacian and Marr-Hildreth operator”

Leave a Reply