As you may know there are several edge detection algorithms available. An overview is given at wikipedia: http://en.wikipedia.org/wiki/Edge_detection
I think the most popular ones are Canny, Sobel and Prewitt but know that there are a lot more algorithms out there. Many of those algorithms utilize in one way or another the (approximated) gradient direction and magnitude at each image point. Commonly those are computed by convolving the image with a kernel (filter mask) yielding the image derivatives in x and y direction. The magnitude and direction of the gradients can then be computed using those derivatives. Since it is kind of awkward to write formulas here at RG I would advise you to look e.g. at the explanation of the Sobel operator here: http://en.wikipedia.org/wiki/Sobel_operator.
It is a good excercise to implement an edge detection by yourself in a language of your choice. Note however, that implementations of many algorithms do exists in all of the commonly used image processing tools. Just to name a few:
In Matlab you could use the edge function if you have the Image Processing Toolbox
You could use simple convolution filters, like Sobel or Prewitt.
Or compute the horizontal derivative by subtracting each pixelvalue from the one on the right to it, then compute the vertical derivative by subtracting each pixelvalue from the one below it. If you then apply Pythagoras on the two resulting images, you get the first derivative. This method is more sensitive to noise than the Sobel and the Prewitt operators, because they do some averaging as well. Beware that the first derivative is shifted half a pixel to the right and to the bottom!
Do the same on the first derivative, and you get the second order derivative.
As you may know there are several edge detection algorithms available. An overview is given at wikipedia: http://en.wikipedia.org/wiki/Edge_detection
I think the most popular ones are Canny, Sobel and Prewitt but know that there are a lot more algorithms out there. Many of those algorithms utilize in one way or another the (approximated) gradient direction and magnitude at each image point. Commonly those are computed by convolving the image with a kernel (filter mask) yielding the image derivatives in x and y direction. The magnitude and direction of the gradients can then be computed using those derivatives. Since it is kind of awkward to write formulas here at RG I would advise you to look e.g. at the explanation of the Sobel operator here: http://en.wikipedia.org/wiki/Sobel_operator.
It is a good excercise to implement an edge detection by yourself in a language of your choice. Note however, that implementations of many algorithms do exists in all of the commonly used image processing tools. Just to name a few:
In Matlab you could use the edge function if you have the Image Processing Toolbox