The gradient of the image is calculated for each pixel position in the image.
The procedure and the MATLAB code for sobel edge detection without using MATLAB built-in function:
The Image obtained from computing X-direction derivative:
The Image obtained from computing Y-direction derivative: