Loading...
Apply the Sobel operator in the X direction to a 2D grayscale image (matrix).
The Sobel Gx kernel is: Gx=−1−2−1000121
Perform valid convolution (no padding) by sliding the kernel over the image. For each position, compute the sum of element-wise products between the kernel and the overlapping image region. Return the absolute value of each result, rounded to 4 decimal places.
The output matrix will have dimensions (H−2)×(W−2) where H and W are the input dimensions.
image = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
[[8]]
[[1, 2, 3], [4, 5, 6], [7, 8, 9]].[[8]].