Fingerprint enhancement in Python
Asked Answered
A

2

16

I'm doing fingerprints recognition as a project for computer vision classes in Python.

For preprocessing of the images I used Gabor filter, then Gaussian blur, then Otsu binarization and I got something like this (original image on the left, processed on the right):

First photo - original, second - after preprocessing

Then I'm doing skeletonization and I think that the image is too detailed. I would like to get something like this (the first image is the one I have now, second - the one I would like to get):

First image is the one I have now, second - the one I would like to get

When I did thining on the second picture, it looked much better than on the image I have now. Do you have any ideas what I can do using OpenCV and Python to achieve that (to get an image similar to the one on the right)?

I would like to especially get rid of those little thorns and to smooth the edges.

Angelinaangeline answered 18/10, 2016 at 22:33 Comment(3)
It looks like your preprocessing (before skeletonization) outputs the lighter regions of input image as black. An inversion will help as a quick check.Nerva
I would think thresholding followed by some morphology would get you most of the way there. The "thorns" are actually white gaps in the original picture. And the gaps mostly occur in the left-right direction. So you could do morphology with a kernel that is wide, but not much height.Metaprotein
can you please post the original source and target images, uncompressed?Uprush
B
1

It seems you got inverted binary image after Otsu, ridges became valleys.

Those small lines you want to remove, are actually gaps along ridge lines, which should be removed by gabor. You can apply Gabor filter again or adjust the parameter.

Ballance answered 2/3, 2022 at 6:12 Comment(0)
T
0

You get pretty far with morphological operators here

img = cv.dilate(img, kernel, iterations)
img = cv.erode(img, kernel, iterations)

, or in general filtering and smoothing. All keywords that might help in a future more detailed search.

I would like to especially get rid of those little thorns and to smooth the edges.

In the following I will focus on your "especially pressing points" by translating them into technical terms and sort of requirements.

Little thorns The little thorns are usually directed vertically, while the characteristic fingerprint lines mostly are horizontally aligned. Thus a Sobel filter will do the trick by putting the emphasize on horizontal lines while thinning out the vertical ones.

img = cv.Sobel(src=img, ddepth=cv.CV_64F, dx=0, dy=1, ksize=5)

Smooth Edges Smoothing is basically done by blurring and then making sure to get sharp lines in a second step. This is done by

img = cv.medianBlur(img, 7)

and

ret, img = cv.threshold(img, 50, 255, cv.THRESH_BINARY)

My inverted result looks like this (there is definitely more to be gained by additional hyperparameter tuning).

Fingerprint after operations

Taboo answered 16/12, 2022 at 9:30 Comment(4)
Can you please provide the code that created this (amazing) result? the lines you provided are supposed to complete anything else?Twentyfour
Exactly the provided lines do the trick.Taboo
With or without the dilate and erode? I've tried without and it resulted a black image. If it's with, what's the recommend kernel sizes?Twentyfour
With - kernele = np.ones((3, 3), np.uint8), kerneld = np.ones((3, 3), np.uint8) however this should be a hyperparameter optimization problem and not based on a single sample.Taboo

© 2022 - 2024 — McMap. All rights reserved.