Creating a Rotating DoG Filter Using a 2D Filter

I have an assignment for a ComputerVision course that I'm having trouble with. I need to filter out the yellow lines of the image below with a rotated DoG filter.

Image we will work with

As a first step, I want to create my own 2D Gaussian kernel (with two different sigma, because they ask for it in the assignment, I don't understand the reason for it yet). Basically I think the blur in some directions will be different.

Gkernel = cv2.getGaussianKernel(5, 0.5)
Gkernel2 = cv2.getGaussianKernel(5, 0.35)
TGkernel2 = cv2.transpose(Gkernel2)
twoDG = Gkernel * TGkernel2

      

I now use a sobel filter to create a Gaussian filter differential (DoG);

DoG = cv2.Sobel(twoDG, cv2.CV_64F, 0, 1, ksize = 5) #derive in the y direction(first order)

      

Now I create a rotation matrix so that the yellow lines are vertical in the image;

rot = cv2.getRotationMatrix2D((2,2), 15, 0.8)
rotDoG = cv2.warpAffine(DoG, rot, (DoG.shape[1], DoG.shape[0]))
img = cv2.imread('./images/'+sys.argv[1])#I pass the name of the file as a CLI argument
gray = cv2.cvtColor( img, cv2.COLOR_BGR2GRAY )
filtered = cv2.filter2D(gray, cv2.CV_64F, rotDoG)

      

If I had to solve this problem without the directives from the teacher, I would first rotate the image so that the yellow lines are vertical and then apply the DoG filter. From wikipedia DoG is a bandpass filter that discards everything but a few spatial frequencies that are present in the original grayscale image. So I would only like to keep the vertical yellow lines.

What am I doing wrong and why, how would you handle this problem? Any help is appreciated for the aspiring CV enthusiast.

+3


source to share





All Articles