---
# System prepended metadata

title: Fingerprint Classification Project

---

# Fingerprint Classification Project

## Link and Resource
[Paper](https://drive.google.com/drive/folders/1H_qoHfMX6QfzkDPLcxkztGE_KhVTIICH?usp=sharing)

[Medium: Fingerprint Gender Classification(CNN)](https://medium.com/swlh/fingerprint-gender-classification-cnn-8b052a162a93)

https://www.kaggle.com/ruizgara/socofing


[final report](https://docs.google.com/document/d/1UmDySsI0IdVQiKbdSjZ5CfW6_4JFDywUf4M8fpcIZA4/edit?usp=sharing)

[github](https://github.com/redchicken75/2021AI_final-project)


## Prof feedback

Fingerprint recognition is valuable for different applications, and it has been deployed in various use cases.

CNN has been a dominant method for visual recognition. We would expect the performance of CNN is better than hand-crafted methods based on recent evidence. My suggestion is to conduct experiments like 
* when CNN fails? When hand-crafted methods outperform CNN methods? 

- 1. For instance, you can change the number of training data while training CNN and hand-crafted methods.

- 2. What if you introduce white noises into your test images? How do white noises influence the performance of the two methods?

In short, it will be great to suggest other experimental settings that make your final project more fun to work on. Please let me know if you have any questions.

- 3. Moreover, if possible, it will be great to identify the difference among methods listed on the Kaggle website (https://www.kaggle.com/ruizgara/socofing/code).


## 6/10 Meeting 
- Change handcrated feature to either adaboost or XGboost
- Add white noise (gaussian, 3 type provided by google)

CNN model: https://www.kaggle.com/brianzz/subjectid-finger-cnnrecognizer


## 6/16 Meeting
### Training with 3 type of noise but with limited dataset
* 5000 for training
* 1000 for testing
* Yield a testing accuracy of 0.54++
### Problem in the kaggle implementation
* There are 2 types of images in the sokoto dataset, with and without noise
* The code provided uses the dataset with noise as training dataset and without noise for testing dataset
* This is counter intuitive as train and test basically have the same dataset just without the noise

**After separating the dataset into two no overlaping groups (subject id will only be in one of the two dataset but not both)**
![](https://i.imgur.com/CJdT8Ni.png) 
![](https://i.imgur.com/m8kQXUd.png)


|          | Training | Testing  |
| -------- | -------- | -------- |
| Accuracy | 1        | 0.549    |
| Loss     | 0.0001.6 | 3.704    |

After separating the dataset, the training result seems promising but not the testing result. Testing only yield an accuracy of **0.549**


## 6/19 Meeting

### Summary
XGBoost and CNN to predict fingerprint ID 

### Tony
1. 改成label是subjectID

2. real_data + white noise
train: real_data+easy_data+hard_data
test: real_data + white noise, medium_CR, medium_Z-cut, medium_obl

| Noise         | Accuracy in prediction |
| ------        | --------               |
| No Noise      | 98.76%                 |
| Gausian       | 4.37%                  |
| S&P           | 97.80%                      |
| poisson       | 97.67%                 |
| speckle       | 0.55%                  |
| CR(Medium)    | 89.14%                 |
| Z-cut(Medium) | 95.96%                 |
| Obl(Medium)   | 96.11%                 |
  
> 4種white noise
>     1. 'gauss':     Gaussian-distributed additive noise.
>     2. 'poisson':   Poisson-distributed noise generated from the data.
>     3. 's&p':       Replaces random pixels with 0 or 1.
>     4. 'speckle':   Multiplicative noise using out = image + n*image,where
>                 n is uniform noise with specified mean & variance.
    
    
    
## Hand crafted feature
### Step of hardcrafted feature:

1. **Image preprocessing**

    **Thresholding**
    * Thresholding used to make features more prominent in data for extraction to be more accurate.
    * Method: Thresholding feature by cv2
    * Thresholding Explanation
        * The fingerprint has has a almost binary distribution
        * Thresholding is a process where if a pixel intensitiy >= mean intesity of the whole image, set it to 255, else set it to 0
        * It will return a image which have a color intensity of either 0 or 255
        * ![](https://i.imgur.com/wswk3g3.png)

    ![](https://i.imgur.com/CqWVSPh.png) -> ![](https://i.imgur.com/vXa6npq.png)
    
    **Skeletonize**
    * Skeletonize is a process of turning a binary image to a single pixel wide skeleton
    * Ridges from the fingerprint are transform to a image that are easier to process 
    * Method:  skimage.morphology.skeletonize
    ![](https://i.imgur.com/96ywOUr.png)

3. Feature Extraction
    * There 2 feature that we want to extract specsifically 
        * Termination: Termination of a ridge
        * Bifurcation: A ridge seperating into 2 branch / Converging into a single ridge
        
        ![](https://i.imgur.com/tHO0Rk1.png)
    * Feature extraction is done by scanning the whole image with a 3x3 window
    * Let i,j be the location of center cube
    ![](https://i.imgur.com/kVodz5d.png)
    
    * If i, j = 1
        * Termination if sum of window = 2
        ![](https://i.imgur.com/g48qlCs.png)
        * Bifurcation if sum of window = 4
        ![](https://i.imgur.com/W68h18i.png)
    * A 94*94 numpy is used to represent the location of the termination and bifurcation

5. Predicting Data
* All 6000 finger's termination and bifurcation are stored
* Mean square error between the  test image and all the 6000 finger is calculated
* Id with lowest mean square error is chosen

### Result

| Noise         | Accuracy in prediction |
| ------        | --------               |
| No Noise      | 99.9%                  |
| Gausian       | 99.3%                  |
| S&P           | 99.86%                 |
| poisson       | 94.059%                |
| speckle       | 32.0%                  |
| CR(Medium)    | 85.149                 |
| Z-cut(Medium) | 97.02%                 |
| Obl(Medium)   | 80.198                 |

    
    
    
    