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;
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);
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);
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);
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)
and now visited this forum.
i have removed gaussian noise, contrast streched the image, created its histogram and generated a histogram equalized image yet.now my next step is to apply Gabor filter.
i m not getting the concept that how to create a 2D array of pixels' orientations and pixels' frequency.In your post you have claimed that you have successfully tested the orientation and frequency.Kindly guide me how and if there is some code available it will be preferable..u can catch me at firstname.lastname@example.org
i am confused about this that angle is 1 value for the x and y coordinates of pixel i.e one orientation for one pixel. why is this 2D array needed for frequency and orientation and how to calculate these two parameters in C#.its urgent.. i 'll wait for the response.