You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

333 lines
9.9 KiB

# About this Project
This project is being developed as a practical part of bachelor's thesis at Brno University of Technology - Faculty of Information Technology.
It is as of now a work in progress.
The topic of this thesis is Generating a 3D Fingerprint Model from input fingerprint image.
This application can be used to apply series of image processing filters to a fingerprint image to make it more suitable for conversion to 3D stl model and printing.
The second part of the project includes the functionality to use generated image as a height map for generating 3D model in stl format.
This model can either be planar, curved or mapped.
# Prerequisites
For now this is only viable for ubuntu gnu/linux machines.
It should however be possible to run it in WSL and virtual machines of most linux distributions.
Before cloning repository, you need these to succesfully use the application.
* python version 3.10 is a requirement might work on earlier python 3 versions
```sh
2 years ago
sudo apt install python3.10
```
* virtualenv package for virtual enviroment creation, other packages are installed automatically later
```sh
2 years ago
pip install virtualenv
```
# Installation
1. Go to a suitable installation folder, for example Documents:
```sh
2 years ago
cd /home/username/Documents
```
2. Clone the repository to a suitable directory, for example:
```sh
2 years ago
git clone ssh://git@strade.fit.vutbr.cz:3022/xlanro00/BP_DP-xlanro00.git
```
3. Go inside cloned directory:
```sh
2 years ago
cd BP_DP-xlanro00
```
2 years ago
4. Create and enter the virtual enviroment:
```sh
2 years ago
virtualenv .venv && source .venv/bin/activate
```
5. Install required python modules from requirements.txt:
```sh
2 years ago
pip install -r requirements.txt
```
6. Now, you can run the application, as an example there is a file in res/examples called Palec_P4.tif. This is shown in the section below.
# Filtering images
Once all the requirements are installed, the application is ready to use.
* You will need to enter the virtual enviroment every time you want to use the application.
2 years ago
```sh
source .venv/bin/activate
```
* The application requires input and output filenames including path from the root project directory, dpi and filter list.
```sh
python3 src/main.py input_file output_file dpi filters
```
There are two ways to enter the filters:
1. manually list all filter names and their parameters on the command line:
```sh
python3 src/main.py res/examples/Palec_P4.tif res/examples/Palec_P4_from_cline.png 600 total_variation weight=0.15 median ksize=5
```
2. load them from preset in a JSON configuration file, that can be used to tune and modify existing presets, or create new ones:
```sh
python3 src/main.py res/examples/Palec_P4.tif res/examples/Palec_P4_from_preset.png 600 --config conf/conf.json git_example
```
# Configuration and presets
There is an option to input the filter series as a preset from JSON configuration file.
To avoid accidental loss of information caused by modifying presets that have been used to generate stl files,
these presets are stored inside a JSON file db.json.
This file serves as a simple database for storing presets, stored presets are modified by adding generated hash of all the filters in that preset.
<table style="width:100%;">
<thead>
<tr>
<th>General format</th>
<th>Woking example</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<pre><code class="language-json">
{
"preset": [
{
"name": "filter_name",
"parameter": value,
"parameter": value
},
{
"name": "filter_name",
"parameter": value
}
],
"preset": [
...
]
...
}
</code></pre>
</td>
<td>
<pre><code class="language-json">
{
"git_example": [
2 years ago
{
2 years ago
"name": "denoise_tv_chambolle",
"weight": 0.01,
"iterations": 1
2 years ago
},
{
2 years ago
"name": "median",
"ksize": 3
}
]
}
</code></pre>
</td>
</tr>
</tbody>
</table>
There is also an option to save current command line setting as a preset using -d switch and it's new name:
* Working example
```sh
python3 src/main.py res/examples/Palec_P4.tif res/examples/Palec_P4_from_cline.png 600 -d preset_gaussian gaussian sigma=1
```
List of all implemented filters and their parameters is described below.
## Available filters with parameters
2 years ago
- median blur
2 years ago
- ksize - Kernel size (int)
2 years ago
- gaussian blur
2 years ago
- sigma - Gaussian kernel standart deviation (int)
2 years ago
- bilateral blur
2 years ago
- diameter - Diameter of pixel neighborhood used for filtering (int)
- sigmaColor - Standard deviation for grayvalue/color distance (int)
- sigmaSpace - Standard deviation for range distance in pixels (int)
2 years ago
- bilateral_scikit
2 years ago
- sigmaColor - Standard deviation for grayvalue/color distance (float)
- sigmaSpace - Standard deviation for range distance in pixels (float)
- nlmeans (non-local means)
- patch_size - Size of patches used for denoising (int)
- patch_distance - Distance in pixels where to search for patches (int)
- h - Cut-off distance, higher means more smoothed image (float)
- total_variation
- weight - Denoising weight. (float)
- block_match
- sigma - ? (?)
- unsharp mask scikit
- radius - Radius of the gaussian filter (int)
- amount - Strength of the unsharp mask (float)
2 years ago
- farid
- meijering
- sato
- hessian
- sigmas - ? (float)
- invert
2 years ago
- scale_values
2 years ago
- binarize
2 years ago
- threshold - value to cut differentiate pixels (int)
- maxval - maximal value (int) ??
- type - ? (str)
2 years ago
- binarize_otsu
2 years ago
- add_margin
2 years ago
- margin - number of pixels to add to the sides of the image (int)
- color - color value of newly added pixels (int)
2 years ago
- erode
2 years ago
- kernel - kernel shape (numpy.matrix)
2 years ago
- dilate
2 years ago
- kernel - kernel shape (numpy.matrix)
2 years ago
# Comparison
Image before processing the fingerprint and after applying a presets.
<table>
<thead>
<th>Before</th>
<th>After</th>
</thead>
<tbody>
<td><img src="res/examples_git/example-before.png?raw=true" width="400" /></td>
<td><img src="res/examples_git/example-after.png?raw=true" width="400" /></td>
</tbody>
</table>
# Generating curved finger model
It is possible to generate stl model using the `--stl` switch. This requires more parameters, first of which is the type of generated fingerprint.
If the mode is set to `c`, the output model will be a curved finger model, with optional parameters following the filename controlling its shape.
First optional parameter is papilar line height `height_line`, second is thickness of the model `height_base`,
third the rate of curvature along x axis `curv_rate_x` and the third is the rate of curvature along y axis `curv_rate_y`.
2 years ago
* General form for curved stl generation
2 years ago
```sh
python3 src/main.py input_file output_file dpi --config config_file preset --stl c height_line height_base curvature_x curvature_y
2 years ago
```
* Working example curved stl generation
2 years ago
```sh
python3 src/main.py res/examples/Palec_P4.tif res/examples/Palec_P4_from_preset.png 600 --config config/config.json git_example --stl c 2 10 2 2
2 years ago
```
2 years ago
# Generating planar finger model
2 years ago
Using `p` mode makes the generated fingerprint model flat.
Optional parameters are height of the papilar lines and base thickness.
2 years ago
* General command form for planar stl generation
2 years ago
```sh
python3 src/main.py input_file output_file dpi --config config_file preset --stl p height_line height_base
2 years ago
```
* Working example of planar stl generation
2 years ago
```sh
python3 src/main.py res/examples/Palec_P4.tif res/examples/Palec_P4_from_preset.png 600 --config config/config.json git_example --stl p 2 10
2 years ago
```
2 years ago
2 years ago
# Mapping to existing finger model
2 years ago
This section will be added later, (if implemented) mapping of fingerprint to a given finger model.
* General command form for mapped stl generation
```sh
python3 src/main.py input_file output_file dpi --config config_file preset --stl m height_line height_base finger_file
```
# Usage
usage: main.py [-h] [-m | --mirror | --no-mirror] input_file output_file dpi ([-c | --config config_file preset] | [filters ...]) [-s | --stl_file p height_line height_base | --stl_file c height_line height_base curv_rate_x curv_rate_y | --stl_file m height_line height_base finger_file]
Program for processing a 2D image into 3D fingerprint.
positional arguments:
input_file input file path
output_file output file path
dpi dpi of used scanner
filters list of filter names and their parameters in form [filter_name1 param1=value
param2=value filter_name2 param1=value...]
options:
-h, --help show this help message and exit
-m, --mirror, --no-mirror
switch to mirror input image
-s [STL_FILE ...], --stl_file [STL_FILE ...]
create stl model from processed image
-c CONFIG CONFIG, --config CONFIG CONFIG
pair: name of the config file with presets, name of the preset
# Roadmap
- [x] Load and store image
- [x] Apply basic image processing filters
2 years ago
- [X] Scale the image using given dpi
- [X] Create filter library with more filters
2 years ago
- [X] Add more suitable filters to the library
- [x] Use presets from config files
- [X] Add the option to save current filter preset to config file
2 years ago
- [X] Add the option to modify filter parameters
- [X] Convert the processed image to flat stl lithophane
- [X] Add the option to curve the lithophane into the shape of a finger
- [X] Export final model ready for 3D print
- [ ] Add the option to map the fingerprint onto a given finger model
#
### Author
Rostislav Lán - xlanro00@stud.fit.vutbr.cz
### Supervisor
Ing. Petr Malaník
### Links
Project Link: [https://strade.fit.vutbr.cz/git/xlanro00/BP_DP-xlanro00](https://strade.fit.vutbr.cz/git/xlanro00/BP_DP-xlanro00)