i have to implement Robert's operator for edge detection. I'm using Python + OpenCV.
This is the code I have come up with, I'm not sure if this is correct.
img = cv2.imread('image_path/image.jpg', 0)
kernelx = np.array([[1, 0], [0, -1]])
kernely = np.array([[0, 1], [-1, 0]])
img_robertx = cv2.filter2D(img, -1, kernelx)
img_roberty = cv2.filter2D(img, -1, kernely)
prewitt = cv2.add(img_robertx, img_roberty)
cv2.imshow(prewitt)
As suggested by DrYuanShenghai:
kernelx = np.array([[1, 0], [0, -1]])
kernely = np.array([[0, 1], [-1, 0]])
img_robertx = cv2.filter2D(blured_img, -1, kernelx)
img_roberty = cv2.filter2D(blured_img, -1, kernely)
grad = cv2.addWeighted(img_robertx, 0.5, img_roberty, 0.5, 0)