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 zerocrossing 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:


MarrHildreth operator
The MarrHildreth 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 zerocrossing 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 zerocrossing 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
In this case we would have to detect the zerocrossings to obtain the final result.
MarrHildreth
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.