I want to detect lines in an image which is at 45 degrees only with respect to the origin. I have to do it with 3x3 convolution only. I have solved it such that all lines at 45 degrees are removed and everything else stays(inverse of what I want). Any help in reaching from here to my final goal will be highly appreciated, thanks.
import cv2
import numpy as np
import matplotlib.pyplot as plt
img = cv2.imread('Lines.png')
plt.imshow(img, cmap='gray')
plt.show()
kernel = np.array([[0, -1, 0],
[1, 0, 1],
[0, -1, 0]])
dst = cv2.filter2D(img, -1, kernel)
cv2.imwrite("filtered.png", dst)
This is the image before convolution:
This is the image after convolution: