How it works...

OpenCV's cv2.Sobel function computes image gradient approximation using a linear filter of a specified size. Through function parameters, you can specify exactly what derivative needs to be computed, what kernel should be used, and the datatype for the output image.

The following output is expected for the preceding code: