Hi guys,

I am currently trying to code gabor filter, and to apply it to an image. My firsts results are really strange (so they're wrong I think), because all outputs values are close to zero (around 10^(-100)). I'm using the opencv lib for c# : emgu.

here is my code :


private double[,] Gabor(Bitmap image, int h, int w, double[,] freq, double[,] resOrientation)
{
double[,] gaborVal = new double[h,w];
int filterSize = 11;
double gaborFiltre;

for (int i = filterSize / 2; i < h - filterSize / 2; i++)
{
for (int j = filterSize / 2; j < w - filterSize / 2; j++)
{
if (freq[i, j] > 0)
{
gaborFiltre = calculGabor(i, j, resOrientation[i, j], freq[i, j]);

gaborVal[i, j] = GaborSum(image, i, j, filterSize, gaborFiltre);
}

}
}
return gaborVal;
}

private double calculGabor(int x, int y, double Orientation, double Frequency)
{
double xtheta = Math.Pow(x * Math.Cos(Orientation) + y * Math.Sin(Orientation), 2);
double ytheta = Math.Pow(-x * Math.Sin(Orientation) + y * Math.Cos(Orientation), 2);
int deltax = (int)Math.Pow(2,2);
int deltay = (int)Math.Pow(2,2);

double valueGabor = (1/(deltax*deltay*2*Math.PI)) * Math.Exp(-0.5*(xtheta / deltax + ytheta / deltay)) * Math.Cos(2 * Math.PI * Frequency * Math.Pow(xtheta, 0.5));

return valueGabor;
}

private double GaborSum(Bitmap image, int x, int y, int filterSize, double filtre)
{
double resGaborSum = 0;

for (int u = -filterSize / 2; u < filterSize / 2; u++)
{
for (int v = -filterSize / 2; v < filterSize / 2; v++)
{
resGaborSum += filtre * (255 - image.GetPixel(y-u,x-u).R);
}
}
return resGaborSum;
}


freq and resOrientation arrays are arrays that contain frequency values and orientation values for each pixel of the image. they are good (I've completed lots of tests to check them).

Can anyone tells me if having this very, very little output values is normal ? and is yes, what does these values represent ??
If no, what's wrong in my code ? (im aware that it's not the nicest code ever, but maybe 'im missing something important)

thanks !!