What is wrong with using an element of diagonal structure and just convolution of the image
More details
Please read here , and it should become clear how to build the structuring element. If you are familiar with convolution, you can build a simple structural matrix that reinforces diagonals without theory
{ 0, 1, 2}, {-1, 0, 1}, {-2, -1, 0}
The idea is this: you want to reinforce a pixel in the image, where the 45deg below it is something different from the 45deg above it. This is the case when you are on the verge of 45 degrees.
Example. Next image

minimized by the matrix above gives a graylevel image where the highest pixel values are those lines that are 45deg.

Now the approach is to simply binarize the image. Et voila

source share