# fingerprint enhancement by gabor filtering using orientation

Status
Not open for further replies.

#### R@vinder

##### Newbie level 2
hi every one,

iam implementing paper "fingerprint enhancement and minutiae extraction " by raymond Thai. i done the coding, but iam not getting the results correctly. i verified it, but iam unable to find the fault.

Actually, is the orientation should be in radians or degrees?
what's it's range -90 to 90 or 0 to 180?

Actually, i should complete my project by 15th june. i don't have enough time. if any one has done similar work, could u please send me the code, even it's in the any language (c,vc++ , matalb etc ), i will refer it.

Here iam sending the code, could anyone who done similar project, please check it.i attached my output image.

my id: ravinderreddy_o@yahoo.co.in

#define W2 16
#define pi (22.0/7.0)
float Dx[512][512],Dy[512][512],Vx[512][512],Vy[512][512];
float theta[512][512],grdori[512][512];
int Sx[3][3]= { {-1, 0, 1},
{-2, 0, 2},
{-1, 0, 1}
};
int Sy[3][3]={ {-1,-2,-1},
{0, 0, 0},
{1, 2, 1}
};
for(i=0;i<512;i++)
{
for(j=0;j<512;j++)
{

if((i<1) || (i>=511) || (j<1) ||(j>=511))
{
Dx[j]=img[j];
Dy[j]=img[j];
}
else
{
sumx=0.0;
sumy=0.0;
for(u=-1;u<=1;u++)
{
for(v=-1;v<=1;v++)
{
sumx=sumx+Sx[u+1][v+1]*img[i+u][j+v];
sumy=sumy+Sy[u+1][v+1]*img[i+u][j+v];
}
}
Dx[j]=sumx;
Dy[j]=sumy;

}
}
}

//orientation calculation

for(i=0;i<512;i++)
{
for(j=0;j<512;j++)
{
Vx[j]=0.0;
Vy[j]=0.0;
for(u=i-W2/2;u<i+W2/2;u++)
{
for(v=j-W2/2;v<j+W2/2;v++)
{

if((u>=0) && (u<=511) && (v>=0) && (v<=511))
{
Vx[j]=Vx[j]+2*Dx[v]*Dy[v];
Vy[j]=Vy[j]+(Dx[v]*Dx[v]-Dy[v]*Dy[v]);

}
}

}

theta[j]=1/2.0*atan2(Vy[j],Vx[j]);
orimg[j]=theta[j]*(180.0/pi);
// directly finding ridge orientation .atan2 gives output in radians, iam converting to degrees. it's in the range -pi/2 to pi/2

(or) we can write as

theta[j]=pi/2+1/2.0*atan2(Vx[j],Vy[j]);
// first gradiant angle calculated, then adding pi/2 gives ridge orientation here it's in the range 0 to pi

orimg[j]=theta[j]*(180.0/pi); // converting to degrees
}
}

//gabor filtering

void filter(Image<BYTE> &img,Image<FLOAT> &orimg, Image<FLOAT> &filtimg)
{
printf("start filtering\n");
float gabor[11][11];
float x_theta,y_theta,temp1,temp2,theta;
int i,j,u,v,w,k,val=0,temp3;
float sigmax,sigmay;

for(i=0;i<512;i++)
{
for(j=0;j<512;j++)
{
theta=orimg[j];
w=11;
sigmax=4.0;
sigmay=4.0;

if((i<w/2)||(i>=512-w/2)||(j<w/2)||(j>=512-w/2))
{
filtimg[j]=255;
}
else
{
for(u=-w/2;u<=w/2;u++)
{
for(v=-w/2;v<=w/2;v++)
{
x_theta=u*cos(theta)+v*sin(theta);
y_theta=(-u)*sin(theta)+v*cos(theta);

temp1=(-0.5)*(((x_theta*x_theta)/(sigmax*sigmax))+((y_theta*y_theta)/(sigmay*sigmay)));

gabor[u+w/2][v+w/2]=exp(temp1)*cos(2.0*pi*0.1*x_theta);

}
}

val=0;
temp2=0.0;
for(u=-w/2;u<=w/2;u++)
{
for(v=-w/2;v<=w/2;v++)
{

if(gabor[u+w/2][v+w/2]>0.05 || gabor[u+w/2][v+w/2]<-0.05 )
{
temp2=temp2+gabor[u+w/2][v+w/2]*img[i+u][j+v];
val=val+gabor[u+w/2][v+w/2];
}

}
}

temp2=temp2/val;
if(temp2>255)
temp2=255;
else if(temp2<0)
temp2=0;

filtimg[j]=temp2;

}

}
}

printf("end filtering\n");
}