implementation of an orientation map for fingerprint enhancement

asked 2016-04-19 13:31:54 -0500

nar6du14 gravatar image

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?


edit retag flag offensive close merge delete



You don't provide a sample image with expected output, so I can't check, but I expect that you want to use atan2 instead of atan.

Also, just for performance sake, you should probably calculate the Sobel derivatives once and just look at each block independently.

Tetragramm gravatar imageTetragramm ( 2016-04-19 15:30:06 -0500 )edit

Take a look here, which supplies full code!

StevenPuttemans gravatar imageStevenPuttemans ( 2016-04-20 05:05:17 -0500 )edit