我在图像处理和 gabor 过滤器方面比较厉害,我想用这个过滤器来增强指纹图像
我读了很多关于指纹图像增强的文章,我知道这样做的步骤是
读取图像 -> 标准化 -> 获取方向图 -> gabor 滤波器 -> 二值化 -> 骨架
现在我在第 4 步,我的问题是如何为 gabor 获得正确的值(lambds 和 gamma)
筛选
我的形象:
我的代码:
1- 使用 HOG 特征读取图像并获取方向图
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
)
方向图:
2-将方向图从 (8, 16, 1, 1, 9) 重塑为 (8, 16, 9),,, 8 ->rows , 16 -> cols , 9orientation
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-卷积函数
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:
你看到图像太糟糕了我不知道为什么会这样,我想是因为 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 并在过滤图像中获得最佳分数,那么我怎样才能从过滤图像中找到像素的最佳分数
这是当我使用具有 45、60、65、90、135 天使的 gabor fiter bank 并将过滤后的图像划分为 16*16 并找到每个块的最高标准差(最佳分数 -> 我使用标准差作为分数)时的输出并获得最佳过滤图像
所以你可以看到图像中有好的部分和坏的部分,我认为单独使用标准偏差在图像的某些部分是无效的,所以我的新问题是什么是最好的分数函数,它可以在图像中给我好的输出部分