Why does Gabor filter thinning when i change angle

56 views Asked by At

I have this code in GO

func gaborFilter(kernelSize int, sigma float64, theta float64, lambda float64, psi float64, gamma float64) GaborFilter {
   kernel := make([][]float64, kernelSize)
   for i := range kernel {
      kernel[i] = make([]float64, kernelSize)
   }

   for y := 0; y < kernelSize; y++ {
      for x := 0; x < kernelSize; x++ {
         mathX := float64(x) - float64(kernelSize-1)/2
         mathY := float64(y) - float64(kernelSize-1)/2
         xTheta := mathX*math.Cos(theta) + mathY*math.Sin(theta)
         yTheta := -mathX*math.Sin(theta) + mathY*math.Cos(theta)

         kernel[y][x] = math.Exp(-(xTheta*xTheta+gamma*gamma*yTheta*yTheta)/(2*sigma*sigma)) * math.Cos(2*math.Pi*xTheta/lambda+psi)
      }
   }
   filter.Kernel = kernel

   return filter
}

Here is call:

filter := gaborFilter(15, 3.0, avgDirection, math.Pi/4, 0.0, 1.0)

Here is mathematical function:

Gabor filter function

But it works nice only with certain angles, for example 45 degrees. And when I increment angle, lines of the filter start thinning. In other web-resources I didn't see this behavior of gabor filters. In articles they've just rotated, as I want in my case.

Here is an example of my filters (i need smth like 1nd and 2nd, but not 3rd and 4th)

my filters

I'm new to image processing and it's hard to me to understand my mistake. Help me please.

0

There are 0 answers