15

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.

Shayan Shafiq
  • 1,447
  • 5
  • 18
  • 25
Natalia
  • 375
  • 3
  • 11
  • 1
    It looks like your preprocessing (before skeletonization) outputs the lighter regions of input image as black. An inversion will help as a quick check. – dhanushka Oct 19 '16 at 09:38
  • 1
    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. – bfris Sep 04 '20 at 00:51
  • 2
    can you please post the original source and target images, uncompressed? – Mercury Mar 16 '21 at 16:11

2 Answers2

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.

Ziming Song
  • 1,176
  • 1
  • 9
  • 22
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

mrk
  • 8,059
  • 3
  • 56
  • 78
  • 1
    Can you please provide the code that created this (amazing) result? the lines you provided are supposed to complete anything else? – RedYoel Feb 02 '23 at 16:33
  • Exactly the provided lines do the trick. – mrk Feb 03 '23 at 08:15
  • 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? – RedYoel Feb 04 '23 at 09:07