Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

implementation of an orientation map for fingerprint enhancement

I'm implementing a function to get an orientation map of a fingerprint image using opencv and python but something is wrong I don't know what this is my code

def compute_real_orientation(array_I, w=17, h=17, 
    row, col = array_I.shape
    array_I = array_I.astype(np.float)
    Ox = array_I[0:row-h+1:h,0:col-w+1:w].copy()
    Ox[:] = 0.0
    Vx = Ox.copy()
    Vy = Vx.copy()
    Oy = Ox.copy()
    angle = Vx.copy()#array to contain all the 17*17 blocks's orientatons
    c = r = -1
    for i in xrange(0, row-h+1, h):
        for j in xrange(0, col-w+1, w):
            Dx = cv2.Sobel(array_I[i:i+h,j:j+w],-1,1,0)#gradient component x for a 17*17block
            Dy = cv2.Sobel(array_I[i:i+h,j:j+w],-1,0,1)#gradient component y for 17*17 block
            for k in range(0,h):
                for l in range(0,w):
                    Vy[r][c] += 2*(Dx[k][l])*(Dy[k][l])
                    Vx[r][c] += ((Dx[k][l])**2 - (Dy[k][l])**2)
        #get the orientation angle for the given 16*16 block
        angle[r][c] = 0.5*(math.atan(Vy[r][c]/Vx[r][c]))
    c = -1
    #smoothing process of the whole array angle
    row, col = angle.shape
    for i in range(0, row):
        for j in range(0, col):
            Ox[i][j] = math.cos(2*angle[i][j])
            Oy[i][j] = math.sin(2*angle[i][j])
    Ox = low_pass_filter(Ox, blur_size)
    Oy = low_pass_filter(Oy, blur_size)
    for i in range(0, row):
        for j in range(0, col):
            #take the final orientation of all 17*17 blocks
            angle[i][j] = 0.5*math.atan(Oy[i][j]/Ox[i][j])
    return angle

I'm implementing the following algorithm algorithm at 2.4 Orientation Image section but my code is not working properly, I don't get the right orientation map. Can any one help me troubleshooting this?