Wednesday 27 July 2016

local features - difference between Gabor and log-Gabor function


I am reading a paper using log-gabor filters for feature detection. I was thinking about the difference between Gabor filters and log-gabor filters. Can anyone tell me the difference(s), and a way to implement them? Thanks in advance.



Answer



The 1D gabor filter has the following form in the frequency domain:


$$G_{b(\sigma,\omega_0)}(\omega) = \text{exp}\left(-\frac{\sigma^2}{2}(\omega - \omega_0)^2\right)$$


The 1D log-gabor filter is:


$$G_{l(\sigma,\omega_0)}(\omega) = \text{exp}\left(-\frac{\ln^2(\omega/\omega_0)}{2\ln^2(\sigma)}\right)$$


Log-gabor filters are used because they have 0 DC component for arbitrary large bandwidth, and size distribution of features in an image is often logarithmic.


The excellent paper On the Choice of Band-Pass Quadrature Filters by Djamal Boukerroui, J. Alison Noble and Michael Brady explains further differences for these two filters as well as others.


Here is some MATLAB code for the 2D version:



[rows, cols] = size(I);

% FFT mesh
[ux, uy] = meshgrid(([1:cols]-(fix(cols/2)+1))/(cols-mod(cols,2)), ...
([1:rows]-(fix(rows/2)+1))/(rows-mod(rows,2)));
ux = ifftshift(ux); % Quadrant shift to put 0 frequency at the corners
uy = ifftshift(uy);

% Convert to polar coordinates
th = atan2(uy,ux);

r = sqrt(ux.^2 + uy.^2);

% Create spectrum
filterFFT = 1.0/wavelength;
filterFFT = exp((-(log(r/filterFFT)).^2) / (2 * log(sigma)^2));
filterFFT(1,1) = 0;

% Filter image
I_filtered = real(ifft2(fft2(I) .* filterFFT));


Advantage of 0 DC


The advantage of having 0 DC component is that the response of the filter doesn't depend on the mean value of the signal. It also means you don't have an infinite impulse response. The Gabor filter has a small non-zero component around DC that is usually removed.


For feature detection, say you designed a filter kernel to match a step (1D) or edge (2D). If the filter had a DC component then the response would vary with the mean image level. e.g. consider the sobel edge detector, and the same kernel with increased values.


I = double(imread('the_image.jpg'));
I = I(:,:,1);
f1 = [[-1 0 1];...
[-2 0 2];...
[-1 0 1]];
f2 = [[0 3 4];...
[1 3 5];...

[0 3 4]];
I1 = conv2(I,f1,'same'); images(I1); colorbar; pause;
I2 = conv2(I,f2,'same'); images(I2); colorbar; pause;
I3 = conv2(I+100,f1,'same'); images(I3); colorbar; pause;
I4 = conv2(I+100,f2,'same'); images(I4); colorbar; pause;

In this code f2 = f1 + 3. Only convolving with f1, which has 0 DC, gives the same result when the mean value of I is changed. The image responses 'look' the same, but only the 0 DC one is useful for feature detection.


No comments:

Post a Comment

readings - Appending 内 to a company name is read ない or うち?

For example, if I say マイクロソフト内のパートナーシップは強いです, is the 内 here read as うち or ない? Answer 「内」 in the form: 「Proper Noun + 内」 is always read 「ない...