#sobel edge detection import cv2 import numpy as np image_path = "corners.jpg" image = cv2.imread(image_path, cv2.IMREAD_GRAYSCALE) SobelX = np.array([[-1, 0, 1], [-2, 0, 2], [-1, 0, 1]]) SobelY = np.array([[-1, -2, -1], [ 0, 0, 0], [ 1, 2, 1]]) gradient_x = cv2.filter2D(image, -1, SobelX) gradient_y = cv2.filter2D(image, -1, SobelY) gradient_x = np.float32(gradient_x) gradient_y = np.float32(gradient_y) edges = cv2.magnitude(gradient_x, gradient_y) cv2.imshow("Original Image", image) cv2.imshow("Sobel Edge Detection", edges.astype(np.uint8)) cv2.waitKey(0) cv2.destroyAllWindows()