Giter VIP home page Giter VIP logo

fingerprint-enhancement-python's Introduction

Fingerprint-Enhancement-Python

Uses oriented gabor filter bank to enhance the fingerprint image. The orientation of the gabor filters is decided by the orientation of ridges in the input image.

Installation and Running the tests

method 1 - use the library

pip install fingerprint_enhancer

Usage:

import fingerprint_enhancer								# Load the library
import cv2

img = cv2.imread('image_path', 0)						# read input image
out = fingerprint_enhancer.enhance_Fingerprint(img)		# enhance the fingerprint image
cv2.imshow('enhanced_image', out);						# display the result
cv2.waitKey(0)											# hold the display window
  • Alternatively, the script "src/example.py" can be used to run the example for this library.

method 2 - use the source codes

  1. go into the src folder
  • if on "develop" branch, run the file "example.py"
  • if on "master" branch, run the file file "main_enhancement.py"
  1. The sample images are stored in the "images" folder

  2. The enhanced image will be stored in the "enhanced" folder

Linter check:

run the command python devtool.py run to run linter checks.

important note:

The Develop Branch is what is up to date. Other branches might not be up to date.

Results

temp

Theory

  • We use oriented gabor filters to enhance a fingerprint image. The orientation of the gabor filters are based on the orientation of the ridges. the shape of the gabor filter is based on the frequency and wavelength of the ridges.

License

  • This project is licensed under the BSD 2 License - see the LICENSE.md file for details

Acknowledgements

  • This program is based on the paper: Hong, L., Wan, Y., and Jain, A. K. 'Fingerprint image enhancement: Algorithm and performance evaluation'. IEEE Transactions on Pattern Analysis and Machine Intelligence 20, 8 (1998), pp 777-789.

  • The author would like to thank Dr. Peter Kovesi (This code is a python implementation of his work)

fingerprint-enhancement-python's People

Contributors

utkarsh-deshmukh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fingerprint-enhancement-python's Issues

Update Numpy

Hi Utkarsh,
Kindly Update the numpy library
It messing up with my environment variable

How to reduce processing time

Hi,
I am building the fingerprint verification app but your enhance algorithm takes 2.5s. How can I to reduce processing time?
Thank you.

What is the equivalent method in opencv for ndimage.convolve?

Hi Utkarsh,

You did a great job. The fingerprint image after enhancement look great! I was trying to convert your python code into C#. I am using emgu.CV, the closest method to achieve the functionality of ndimage.convolve was using cv2.filter2D because this method is supported in C#.

The python code is as follow :
Gx = ndimage.convolve(Gxx,f)

and C# code is as follow

 ConvolutionKernelF GxxKernal = new ConvolutionKernelF(f);
        f= f.Flip(FlipType.Both);
        CvInvoke.Filter2D(ToMatrix(Gxx), Gx, f, new Point(-1, -1), 0, BorderType.Reflect);

image

by using this parameter for Filter2D in openCV, I can get a close result to python however there are not equal.
Maybe Filter2D in OpenCV is not capable of producing the same result as in ndimage.convolve, do you know is there any other method in opencv that can produce the same convolution result as in ndimage.convolve? Thanks in advance!

Program behaves weird

I tried to input an image, but the image is kind of buggy. In the original image, there are some white lines in the centre of the fingerprint. This feature feels as if there is some glitch when it comes to enhancing the picture. The input image is in the bmp format.
This is the input image:
input
And this is the output image:
enhanced

Ridge extraction for fingerprint patches

Hi @Utkarsh-Deshmukh,

I was trying to run your code on fingerprint patches resized to 256x256. The ridges maps aren't formed completely(might be due to pores). There is also a black border along the edges but I need the ridge map for the complete image.

I have attached the resulting ridge map below along with the original image. Could you please guide me on resolving these issues?

Original Image (96x96)
1801-019_0_1-HiScan-Live

Enhanced Ridge Map Image (256x256)
enhanced_image1801-019_0_1-HiScan-Live

Thank you

Slight different in Cos image.

Hi,

I have converted the code to pure c# however there are some discrepancy on the final image. So I try to visualize the orientation image for Sin, Cos and etc

I found out the Cos image generated from c# is as follow
cos
Generated by Python code
cos

Orientation (c#)
orientation
Orientation (Python)
1

Here is the original fingerprint
1

Enhance result from c#

testout

Enhance result from Python

1

Could it be the different in the Cos orientation image as generated by both C# and Python that cause the subsequence failure in the final enhance image?

No image

im a novice at python, installed the enhancer and after getting the script to show the enhance image its just a a grey screen wait for over an hour and retried multiple times not sure whats going wrong

Execute problem

Hello Utkarsh, maybe the problem is so silly and the solution is so simple but i'cant execute main_enhancement.py in anaconda. The error is: AttributeError: module 'scipy.ndimage' has no attribute 'imread'. I try to change the ndimage to misc and imageio but it doesn't help, error is the same. While i've been search for the solution (especially on stackoverflow) i saw that someone else's problem solved with importing pillow, so i tried it too but nothing changed. Is this problem occurs because of the version differences? What do you think?

Issue in ridge_filter function in some of the images

Hii Utkarsh,
I am running it for my palm images and for some of the images it works perfectly well but for some of the images there is an error.
Error is: index 0 is out of bounds for axis 0 with size 0
in function: __ridge_filter
In line : sigmax = 1 / unfreq[0] * self.kx
When i try to debug it i found that variable unfreq has shape as (0,).
I don't know why for some of the images it is working but for other it is not.
I am also attaching image for your reference.
One more thing i have resized my current image and after resizing it is not working and if I pass the image without resizing it is working fine. But again i did'nt get the reason can you explain and tell me how to solve it.
The following is without resizing
047_l_940_06
The following is after resizing.
047_l_940_06

Thanks
Kapil singla

More problems

I tried converting some more images, and some images still behave buggy. I know it is very hard to solve, but are there any approaches to solve it? Also, I found out the later version of the code still somehow can't work as intended and even makes it worse.
Original:
6
pip:
6 (2)
Raw code:
6 (1)

TypeError showing

Hi!
I was just trying to run this code. I got an error that there's no attribute "int" for module numPy. I converted that to normal int() function. Now I'm getting a new error "TypeError: only size-1 arrays can be converted to Python scalars" on the line "cropsze = int(np.fix(rows // np.sqrt(2)))". Can you tell me what I'm doing wrong? Should i change my python version or opencv version?

Issue with ridge_filter

Hi, I am using this library on my fingerprint dataset and i get this error:

`in ridge_filter(im, orient, freq, kx, ky)
75 # orientations in 'angleInc' increments.
76
---> 77 sigmax = 1/unfreq[0]*kx;
78 sigmay = 1/unfreq[0]*ky;
79

IndexError: index 0 is out of bounds for axis 0 with size 0`

Can you help me?

a problem

Hello author, I had a problem why I ran according to your method 1, a problem appeared - this dll could not be found.

Traceback (most recent call last):
File "example.py", line 9, in
from src.FingerprintImageEnhancer import FingerprintImageEnhancer
File "C:\Users\wrx\Desktop\SR\image-enhance\Fingerprint-Enhancement-Python-develop\src\FingerprintImageEnhancer.py", line 10, in
from scipy import signal
File "D:\Wangluohuanjing\Anaconda3\lib\site-packages\scipy\signal_init_.py", line 322, in
from .filter_design import *
File "D:\Wangluohuanjing\Anaconda3\lib\site-packages\scipy\signal\filter_design.py", line 18, in
from scipy import special, optimize, fftpack
File "D:\Wangluohuanjing\Anaconda3\lib\site-packages\scipy\optimize_init_.py", line 387, in
from .minimize import *
File "D:\Wangluohuanjing\Anaconda3\lib\site-packages\scipy\optimize_minimize.py", line 30, in
from .trustregion_constr import minimize_trustregion_constr
File "D:\Wangluohuanjing\Anaconda3\lib\site-packages\scipy\optimize_trustregion_constr_init
.py", line 4, in
from .minimize_trustregion_constr import minimize_trustregion_constr
File "D:\Wangluohuanjing\Anaconda3\lib\site-packages\scipy\optimize_trustregion_constr\minimize_trustregion_constr.py", line 4, in
from scipy.sparse.linalg import LinearOperator
File "D:\Wangluohuanjing\Anaconda3\lib\site-packages\scipy\sparse\linalg_init
.py", line 117, in
from .eigen import *
File "D:\Wangluohuanjing\Anaconda3\lib\site-packages\scipy\sparse\linalg\eigen_init
.py", line 11, in
from .arpack import *
File "D:\Wangluohuanjing\Anaconda3\lib\site-packages\scipy\sparse\linalg\eigen\arpack_init.py", line 22, in
from .arpack import *
File "D:\Wangluohuanjing\Anaconda3\lib\site-packages\scipy\sparse\linalg\eigen\arpack\arpack.py", line 45, in
from . import _arpack
ImportError: DLL load failed: 找不到指定的程序。

some problem about ridge_orient

Hi, Utkarsh
When I saw the code "orientim = np.pi/2 + np.arctan2(sin2theta,cos2theta)/2;" in ridge_orient.py,
I was confused about why need to add pi/2. Then, I drew a directional field on a img,but it looked irregular.
Looking forward to your reply.

Gabor_Filter Float Error

Hi Utkarsh,
When I run your code,
I get the following error

Macintosh:src saikiranoruganti$ python main_enhancement.py


gabor_filter = np.array(np.zeros((180/angleInc,filt_rows,filt_cols)));

TypeError: 'float' object cannot be interpreted as an integer
Macintosh:src saikiranoruganti$ 180/angleInc,filt_rows,filt_cols

It seems the floats are unable to pass through np.zeros. Any directions on how to fix this?

Discrepancy between the enhance images generated from python and c# code

Here is the result generated from
C#
testout

Python
Untitled

The ridges generated from original image are more thicker and connected while the one using openCV replacement function are thinner and disconnected.

There are a lot of useful library found in python but didn't provided by C# so I have to make some changes on certain function call, mainly using opencv to replace sciPy's function.

In the ridge_orient() function
I replace

        gauss = cv2.getGaussianKernel(np.int(sze),self.gradient_sigma)
        f = gauss * gauss.T

        fy,fx = np.gradient(f)    

        Gx = signal.convolve2d(self._normim, fx, mode='same')
        Gy = signal.convolve2d(self._normim, fy, mode='same')

        Gxx = ndimage.convolve(Gxx,f)
        Gyy = ndimage.convolve(Gyy,f)
        Gxy = 2*ndimage.convolve(Gxy,f)

with

        gauss = cv2.getGaussianKernel(np.int(sze),self.gradient_sigma)
        f = gauss * gauss.T

        fx=cv2.Sobel(f,cv2.CV_64F,1,0,3)
        fy=cv2.Sobel(f,cv2.CV_64F,0,1,3)

       Gx = cv2.filter2D(self._normim,-1,cv2.flip(fx,-1),borderType=cv2.BORDER_REFLECT)
        Gy = cv2.filter2D(self._normim,-1,cv2.flip(fy,-1),borderType=cv2.BORDER_REFLECT)

        Gxx = cv2.filter2D(Gxx,-1,cv2.flip(f,-1),borderType=cv2.BORDER_REFLECT)
        Gyy = cv2.filter2D(Gyy,-1,cv2.flip(f,-1),borderType=cv2.BORDER_REFLECT)
        Gxy = 2*cv2.filter2D(Gxy,-1,cv2.flip(f,-1),borderType=cv2.BORDER_REFLECT)

__frequest()

I replace

rotim = scipy.ndimage.rotate(blkim, orient / np.pi * 180 + 90, axes=(1, 0), reshape=False, order=3,
                                    mode='nearest')

with

       ROT_mat = cv2.getRotationMatrix2D((cols/2,rows/2),orient/np.pi*180 + 90,1)
        rotim = cv2.warpAffine(blkim,ROT_mat,(cols,rows))

What is the reason that cause such discrepancy? Any Idea to make the ridge thicker and connected? Thanks in advance

Problem about running

Hi there!
I'm trying to run this project, but there are some errors. I have tried to fix them but anyway can't run. I attach the 1st screenshot of the first error. This error I've fixed placing '//' instead of '/'. Then was similar error and after was error like on 2nd screenshot.
I'm on windows 10 and using Anaconda 2 spyder (Python 3.7)
image
image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.