Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Register Log in

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.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top