2

I need to compute Gabor filter of a given image using Halcon library. Unfortunately, I get different results when manally compute FFT of Gabor kernel or use the function gen_gabor() that is claimed to compute the Gabor and Hilbert filters in frequency domains. Originally I used code from the link that describes the Gabor filter in frequency domain as a Gaussian function. Similar results (two symmetric gaussians) is obtained by using Matlab code and corresponding demo when Output image is set to "Gabor function (power spectrum") - see figure below as an example Sample power spectrum of Gabor filter

The output of gen_gabor contains two crescents and does not have much in common with the Gaussian functions. Please take a look at the sample output of the command

gen_gabor(Filter,1.4,0.4,1.0,1.5,'n','dc_center',512,512)

First channel of Filter

Does anyone know how to use Gabor filter from Halcon and obtain the same result as a product of image Fourier transform and conventional FFT of Gabor filter? In fact, I even cannot map the parameter Angle of gen_gabor to the arguments of conventional Gabor filter, e.g., wavelength, sigma, phase and spatial aspect ratio, or to the closest definition in Eq. 31 of tutorial.

Andrey
  • 21
  • 2
  • 1
    Neither of those look like a Gabor filter in the frequency domain. There should be only one Gaussian, shifted away from the origin according to wavelength and angle parameters. This leads to a complex-valued kernel in the spatial domain. Note that the Gabor filter doesn’t have a “phase” parameter: the complex filter encodes all possible phases. You can obtain a real-valued kernel for a specific phase by projecting the complex values, but the result is no longer a Gabor filter, since it doesn’t encode all phases any more. [cont.] – Cris Luengo Sep 12 '20 at 14:35
  • [cont.] There’s a lot of confusion around this, and the Gabor filter is very often taught wrong. Still, assuming these programs compute a real-valued projection of the Gabor filter, then the power spectrum would look like what you show. – Cris Luengo Sep 12 '20 at 14:37
  • 1
    The Halcon output doesn’t look like a Gabor filter no matter how you put it. They likely define their filter using a frequency-band decomposition, and an angular decomposition. Their filter is probably easier to use to decompose the image into separate frequency and angular components, with the Gabor filter it’s not possible to do this perfectly, and decompositions tend to be a bit hacky (you cannot tile a Gaussian). – Cris Luengo Sep 12 '20 at 14:47
  • Thank you so much! According to Matlab code, my first image displays the absolute value of a complex FFT transform of Gabor 47x47 kernel. Do you know if it is possible to understand concrete algorithms used for frequency/angular decompositions in the Halcon? My customer insists on using Halcon, but cannot understand exact equation of surface in the generated crescents (my second figure)... – Andrey Sep 12 '20 at 16:14
  • MATLAB’s Gabor function also creates a real-valued projection of the Gabor filter for a specific phase. Hence you see the two lobes in the FFT. The tutorial you linked shows the actual Gabor filter in the frequency domain, with only one Gaussian. – Cris Luengo Sep 12 '20 at 16:43
  • 1
    I don’t know anything about this Halcon software, so can’t help you with that. I suggest you generate filters with different center frequency, then add up their magnitudes in the frequency domain. The output should be relatively flat. Vary the interval for the sequence of frequencies until your output is sufficiently flat, but doesn’t have too many components. This is an optimization game, with an infinite number of components you have a perfectly flat output, but you obviously don’t want that many. I don’t know if you need to use logarithmic or linear sampling, depends on the implementation. – Cris Luengo Sep 12 '20 at 16:44
  • Then repeat the experiment with the angular component. Again, the more components, and the wider the angle, the flatter the output. Find your optimum. – Cris Luengo Sep 12 '20 at 16:45

0 Answers0