3

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

Image we will be working with

As a first step I want to make a custom 2D gaussian kernel(with 2 different sigma's, because they ask for it in the assignment, I don't understand the reason for it yet). Basicly I think the amount of 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

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

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 would be 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 tackle this problem without directives from the teacher, I would first rotate the image so that the yellow lines are in a vertical position, then apply a DoG filter. From wikipedia a DoG is a band-pass filter that discards all but a handful of spatial frequencies that are present in the original grayscale image. So I would only want to keep the now vertical yellow lines.

What are the things I'm doing wrong and why, how would you tackle this problem? Any help is appreciated for a novice CV enthusiast.

Xilef
  • 81
  • 11
  • 2
    First, DoG means Difference of Gaussian. Meaning the difference between to images filtered with two gaussian filters (therefore two different sigmas). Ina certain case this can result in (approximately) a Laplacian of Gaussian([Lindeberg 1994](http://link.springer.com/book/10.1007%2F978-1-4757-6465-9)). Also read this [wikipedia link](https://en.wikipedia.org/wiki/Difference_of_Gaussians?wprov=sfsi1) for more information. – PSchn Apr 19 '17 at 16:39
  • 1
    Can you mark the yellow line? I'm kind of color-blind :D – PSchn Apr 20 '17 at 11:00
  • @PSchn The two bands that go from bottom to top (finish in x after the start: `x_end-x_start > 0, start=bottom, end=top`). – Catree Apr 20 '17 at 12:07

0 Answers0