First when you just have 1D and want to find edges such as just a vertical or horizontal scanning, it’s easy to take the second derivative times the kernel and times the image: ∂²/∂x² * h(kernel) *f(image) for horizontal or ∂²/∂y² * h(kernel) * f(image) for vertical.
Then just find a zero crossing at the maximum slope , and that’s the edge.
But when you have 2D it’s hard the second derivative because the scanning is in both directions simultaneously (x,y), therefore it is hard to find the zero crossing and to assume that it is the edge.
So, what do you do?
You take the Laplacian operator, which is: ∇² = √(∂²f/∂x²+∂²f/∂y²) and then you’ll see the correct zero crossings.