FINGERPRINT IMAGE ORIENTATION ESTIMATION
hi i am new to image processing. i have tried to create a fingerprint image orientation using gardient based method. i have used the following c code to compute the orientation. while i try to overlay the orientation on fingerprint image its not well. can any suggest me if any changes is to be made in the code and also suggest me the best fingerprint image orientation algorithm.
// extracts the orientations
orientations = malloc(sizeof(byte*)*fgRows);
for (y = 0; y < fgRows; y++)
{
orientations[y] = malloc(fgColumns);
ZeroMemory(orientations[y],fgColumns);
for (x = 0; x < fgColumns; x++)
{
if (foreground[y][x])
{
int px = border + x * step;
int py = border + y * step;
int i,j,k,l,m,n;
double dx[step][step],dy[step][step];
double gx,gy;
double nx,ny,ne,coh;
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}};
int sumX,sumY;
// TODO: estimate local orientation at pixel (px,py)
// and store it into orientations[y][x]
if(px<imageWidth && py<imageHeight)
{
for(i=py,k=0; i<py+step; i++,k++)
{
for(j=px,l=0; j<px+step; j++,l++)
{
dx[k][l] = image[i*imageWidth+(j+1)]-image[i*imageWidth+(j-1)];
dy[k][l] = image[(i+1)*imageWidth+j]-image[(i-1)*imageWidth+j];
}
}
for(i=0; i<step; i++)
{
for(j=0; j<step; j++)
{
gx += 2*dx[i][j]*dy[i][j];
gy += dx[i][j]*dx[i][j]-dy[i][j]*dy[i][j];
}
}
orientations[y][x] = (int)(0.5*atan2(gx,gy)+(3.14159265358f*0.5));
gx = 0.0;
gy = 0.0;
}
}
}