简体   繁体   English

指纹图像增强的 Gabor 滤波器参数?

[英]Gabor filter parametrs for fingerprint image enhancement?

i am biggner in image processing and in gabor filter and i want to use this filter to enhance fingerprint image我在图像处理和 gabor 过滤器方面比较厉害,我想用这个过滤器来增强指纹图像

i read many articles about fingerprint image enhancement and i know that the steps for that is我读了很多关于指纹图像增强的文章,我知道这样做的步骤是

read image -> noramalize -> get orientation map -> gabor filter -> binarize -> skeleton读取图像 -> 标准化 -> 获取方向 map -> gabor 滤波器 -> 二值化 -> 骨架

now i am in step 4, my question is how to get the right values for ( lambds and gamma ) for gabor现在我在第 4 步,我的问题是如何为 gabor 获得(lambds 和 gamma)的正确值

filter筛选

my image:我的形象:

在此处输入图像描述

my code:我的代码:

1- read image and get the orientation map using HOG features 1- 使用 HOG 特征读取图像并获取方向 map

imgc = imread(r'C:\Users\iP\Desktop\printe.jpg',as_gray=True)
imgc = resize(imgc, (64*3,128*3))
rows,cols=imgc.shape
offset=24
ori=9    # to get angels (0,45,90,135) only

fd, hog_image = hog(imgc, orientations=ori, pixels_per_cell=(offset, offset),
                cells_per_block=(1, 1), visualize=True, multichannel=None,feature_vector=False
              )

orientation map:方向 map:

在此处输入图像描述

2- reshape the orientation map from (8, 16, 1, 1, 9) to (8, 16, 9),,, 8 ->rows, 16 -> cols, 9 orientation 2- 将方向 map 从 (8, 16, 1, 1, 9) 重塑为 (8, 16, 9),,, 8 ->rows, 16 -> cols, 9 方向

fd=np.array(fd)
fd=np.reshape(fd,(fd.shape[0],fd.shape[1],ori))

# from (8, 16, 9) to (8, 16, 1)
# Choose the angle that has the most potential ( biggest magntude )
angels=np.zeros((fd.shape[0],fd.shape[1],1))
for r in range(fd.shape[0]):
    for c in range(fd.shape[1]):
       bloc_prop = fd[r,c]
       angelss=bloc_prop.reshape((1,ori))
       angel=np.argmax(angelss)
       angels[r,c]=angel
angels=angels.astype(np.int32)

3- the convolve function 3-卷积 function

def conv_gabor(img,orient_map,gabor_kernel_shape):
    #
    # loop on all pixels in the image and convolve it with it's angel in the orientation map
    #
    roo,coo=img.shape

    #to get the padding value for immage before convolving it with kernels
    pad=(gabor_kernel_shape-1)


    padded=np.zeros((img.shape[0]+pad,img.shape[1]+pad)) # adding the cols and rows 
    padded[int(pad/2):-int(pad/2),int(pad/2):-int(pad/2)]=img # copy image to inside the padded 
    image

    #result image
    dst=padded.copy()

    # start from the image that inside the padded
    for r in range(int(pad/2),int(pad/2)+roo): 
    
        for c in range(int(pad/2),int(pad/2)+coo):
        
            # get the angel from the orientation map
            ro=(r-int(pad/2))//offset
            co=(c-int(pad/2))//offset
            ang=angels[ro,co]
            real_angel=(((180/ori)*ang))
        
            # bloack around the pixe to convolve it 
            block=padded[r-int(pad/2):r+int(pad/2)+1,c-int(pad/2):c+int(pad/2)+1]
            # get Gabor kernel 
            # here is my question ->> what to get the parametres values for ( lambda and gamma 
            and phi)
            ker= cv2.getGaborKernel( (gabor_kernel_shape,gabor_kernel_shape), 3, 
            np.deg2rad(real_angel),np.pi/4,0.001,0 )
                                
            dst[r,c]=np.sum((ker*block))
    return dst

dst=conv_gabor(imgc,angels,11)

dst:夏令时:

在此处输入图像描述

you see the image is too bad i dont know why this, i think because the lambda and gamma or what?你看到的图像太糟糕了我不知道为什么会这样,我想是因为 lambda 和 gamma 还是什么?

but when i filter with one angel only 45:但是当我用一个天使过滤时,只有 45:

ker= cv2.getGaborKernel( (11,11), 2, np.deg2rad(45),np.pi/4,0.5,0 )
filt = cv2.filter2D(imgc,cv2.CV_64F,ker)
plt.imshow(filt,'gray')

reslut:结果:

在此处输入图像描述

you see the edges that has 45 on the left is good quality你看到左边有 45 的边缘质量很好

can anyone help me please, and tell me what should i do in this probelm?谁能帮助我,并告诉我在这个问题中我应该做什么?

thanks all:)谢谢大家:)

EDIT:编辑:

i searched for another way and i found that i can use gabor fiter bank with many orientation and get best score in filtred images, so how can i find best score for pixels from filtred images我搜索了另一种方法,我发现我可以使用具有多种方向的 gabor fiter bank 并在过滤图像中获得最佳分数,那么我如何从过滤图像中找到像素的最佳分数

this is the output when i use gabor fiter bank with 45,60,65,90,135 angels and divide the filtered images to 16*16 and find the highest standard deviation (best score -> i use standard deviation as the score) for each block and get the best filtred image这是 output 当我使用具有 45,60,65,90,135 个角度的 gabor fiter bank 并将过滤后的图像划分为 16*16 并找到每个块的最高标准偏差(最佳分数 -> 我使用标准偏差作为分数)并获得最佳过滤图像

在此处输入图像描述

so as you can see there are good and bad parts in the image,i think using standard deviation alone is ineffective in some parts of the image, so my new question is what is best score function that gives me good output parts in the image所以你可以看到图像中有好的和坏的部分,我认为单独使用标准偏差在图像的某些部分是无效的,所以我的新问题是最好的分数 function 给我很好的 output 部分

original image:原图: 在此处输入图像描述

In my opinion, weighting the filtered images might be enough for your task.在我看来,对过滤后的图像进行加权可能足以完成您的任务。 Considering your filter orientations, the filters with angle 45 and 135 respond quite well at different regions of the image.考虑到您的滤镜方向,角度为 45 和 135 的滤镜在图像的不同区域响应非常好。 So, you can calculate the weighted sum to get the best filter result.因此,您可以计算加权和以获得最佳过滤结果。

img = cv2.imread('fingerprint.jpg',0)

w_45 =  0.5
w_135 = 0.5

img_45 = cv2.filter2D(img,cv2.CV_64F,cv2.getGaborKernel( (11,11), 2, np.deg2rad(45),np.pi/4,0.5,0 ))
img_135 = cv2.filter2D(img,cv2.CV_64F,cv2.getGaborKernel( (11,11), 2, np.deg2rad(135),np.pi/4,0.5,0 ))

result = img_45*w_45+img_135*w_135
result = result/np.amax(result)*255

plt.imshow(result,cmap='gray')
plt.show()

加权结果

Feel free to play with the weights.随意玩重量。 The result totally depends on what your next step is.结果完全取决于你的下一步是什么。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM