The Sobel operator (http://en.wikipedia.org/wiki/Sobel_operator) can be used for edge detection in images. The edge detection is based on performing a discrete differentiation on the image intensity. Since an image is two-dimensional, the gradient also has two components, unless we limit ourselves to one dimension, of course. We will apply the Sobel filter to the picture of Lena Söderberg.
In this section, you will learn how to apply the Sobel filter to detect edges in the Lena image:
sobelx = scipy.ndimage.sobel(lena, axis=0, mode='constant')