[英]Gabor filter parametrs for fingerprint image enhancement?
我在图像处理和 gabor 过滤器方面比较厉害,我想用这个过滤器来增强指纹图像
我读了很多关于指纹图像增强的文章,我知道这样做的步骤是
读取图像 -> 标准化 -> 获取方向 map -> gabor 滤波器 -> 二值化 -> 骨架
现在我在第 4 步,我的问题是如何为 gabor 获得(lambds 和 gamma)的正确值
筛选
我的形象:
我的代码:
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
)
方向 map:
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-卷积 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)
夏令时:
你看到的图像太糟糕了我不知道为什么会这样,我想是因为 lambda 和 gamma 还是什么?
但是当我用一个天使过滤时,只有 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')
结果:
你看到左边有 45 的边缘质量很好
谁能帮助我,并告诉我在这个问题中我应该做什么?
谢谢大家:)
编辑:
我搜索了另一种方法,我发现我可以使用具有多种方向的 gabor fiter bank 并在过滤图像中获得最佳分数,那么我如何从过滤图像中找到像素的最佳分数
这是 output 当我使用具有 45,60,65,90,135 个角度的 gabor fiter bank 并将过滤后的图像划分为 16*16 并找到每个块的最高标准偏差(最佳分数 -> 我使用标准偏差作为分数)并获得最佳过滤图像
所以你可以看到图像中有好的和坏的部分,我认为单独使用标准偏差在图像的某些部分是无效的,所以我的新问题是最好的分数 function 给我很好的 output 部分
在我看来,对过滤后的图像进行加权可能足以完成您的任务。 考虑到您的滤镜方向,角度为 45 和 135 的滤镜在图像的不同区域响应非常好。 因此,您可以计算加权和以获得最佳过滤结果。
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()
随意玩重量。 结果完全取决于你的下一步是什么。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.