Edge Detection:

Edge Detection is simply a case of trying to find the regions in an image where we have a sharp change in intensity or a sharp change in color, a high value indicates a steep change and a low value indicates a shallow change.

Sobel Operator:

A very common operator for doing this is a Sobel Operator, which is an approximation to a derivative of an image. It is separate in the y and x directions. If we look at the x-direction, the gradient of an image in the x-direction is equal to this operator here. We use a kernel 3 by 3 matrix, one for each x and y direction. The gradient for x-direction has minus numbers on the left hand side and positive numbers on the right hand side and we are preserving a little bit of the center pixels. Similarly, the gradient for y-direction has minus numbers on the bottom and positive numbers on top and here we are preserving a little bit on the middle row pixels.

Essentially what we are trying to do here with the Sobel Operator is trying to find out the amount of the difference by placing the gradient matrix over each pixel of our image. We get two images as output, one for X- Direction and other for Y-Direction. By using Kernel Convolution, we can see in the example image below there is an edge between the column of 100 and 200 values.

The above example shows the result of doing convolution by placing the Gradient matrix X over a red marked 100 of images. The calculation is shown on the right which sums up to 400, which is non-zero, hence there is an edge. If all the pixels of images were of the same value, then the convolution would result in a resultant sum of zero. So the gradient matrix will provide a big response when one side is brighter . Another point to note here is that the sign of the output resultant does not matter.

Lets take a look at another example :

Illustrating how the calculation is done for a pixel in the x-direction using Gx. Image source: http://www.doc.ic.ac.uk/~ts2615/contribution.html

Illustrating how the calculation is done for a pixel in the y-direction using Gy. Image source: http://www.doc.ic.ac.uk/~ts2615/contribution.html

There are many other useful deductions that can be derived after calculating the Edge using Gx and Gy.

Summary:

The Sobel Operator method can be successfully used for segmenting an image without any human intervention. The Sobel Operator is very quick to execute as well. Since it produces the same output every time you execute it over an image, makes Sobel Operator a stable edge detection technique for image segmentation.