Gabor filter implementation

Status
Not open for further replies.

kentril

Newbie level 1
Joined
Jun 27, 2011
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,287
Welcome everyone. I'm having a big trouble with implementing gabor filter to image enhancement. The Gabor filter is

f(x,y:θ,f) = exp (-0.5 [ x_theta^2/ + y_theta^2/]) * cos(2*π*f*x_theta)

where x_theta and y_theta are

x_theta = x*sinθ + y*cosθ
y_theta = -x*cosθ + y*sinθ


Here is my code:

Code:
/*-----------------------------------
                Gabor Filter
     -----------------------------------*/
    for(row=5; row<=height-5; row++) {
        for(col=5; col<=width-5; col++) {
            
            for (i=-5; i<=5; i++) {
                for (j=-5; j<=5; j++) {

                    x_theta = i*sin(thetaArray[row*width + col]) + j*cos(thetaArray[row*width + col]);
                    y_theta = -i*cos(thetaArray[row*width + col]) + (j*sin(thetaArray[row*width + col]));

                    exp_temp = -0.5*((pow(x_theta, 2)/pow(sigmaX, 2))+(pow(y_theta, 2)/pow(sigmaY, 2)));

                    gaborArray[i+5][j+5] = exp(exp_temp) * cos(2.0*M_PI*(1/ridgeFrequency)*x_theta);
                    
                }
            }
            
            // convolution filter with image
            gaborTemp = 0;
            for (i=-5; i<=5; i++) {
                for (j=-5; j<=5; j++) {
                    gaborTemp += (float)pixels[(row+i)*width + (col+j)] * gaborArray[i+5][j+5];
                }
            }
            imageAfterGabor[row*width + col] = gaborTemp;

        }
    }

But my image is not enhanced after convolution. Instead I receive image looking like white noise... Could someone help me with this?
 
Last edited:

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…