Added user manual and a makefile for it.

master
Rostislav Lán 2 years ago
parent ee481a11cb
commit bb272a4539

@ -0,0 +1,342 @@
<h1 id="user-manual-for-fingerprint-image-filtering-and-model-generating-application">User Manual for fingerprint image filtering and model generating application</h1>
<h2 id="introduction">Introduction</h2>
<p>This project has been developed as a part of bachelors thesis at Brno University of Technology - Faculty of Information Technology. The topic of this thesis was Generating a 3D Fingerprint Model from input fingerprint image.</p>
<p>This application consists of two main parts.The first part of the application uses image filters to enhance fingerprint images. Application also implements a custom filter library, which consists of several filters imported from image processing modules.</p>
<p>The second part uses the processed image to make a 3D model of the fingerprint. The model can then be used to print an accurate representation of human fingerprint using a 3D printer.</p>
<h2 id="getting-started">Getting started</h2>
<p>The application has only been tested on Ubuntu gnu/linux machines. It should however be possible to use it in on most linux distributions, WSLs and also virtual machines of most linux distributions.</p>
<p>To start off, you need these to succesfully use the application.</p>
<ul>
<li><p><strong>python</strong> version 3.10 is a requirement might work on earlier python 3 versions:</p>
<pre><code>sudo apt install python3.10</code></pre></li>
<li><p><strong>virtualenv</strong> package for virtual enviroment creation, other packages are installed automatically later:</p>
<pre><code>pip install virtualenv</code></pre></li>
</ul>
<h2 id="installation">Installation</h2>
<p>This will install the application and its components into the Documents directory. It will also install several required python packages, including venv, which is used to create a virtual enviroment.</p>
<ol type="1">
<li><p>Go to a suitable installation folder, for example <strong>Documents</strong>:</p>
<pre><code>cd /home/username/Documents</code></pre></li>
<li><p>Clone the repository to a suitable directory, for example:</p>
<pre><code>git clone ssh://git@strade.fit.vutbr.cz:3022/xlanro00/BP_DP-xlanro00.git</code></pre></li>
<li><p>Go inside cloned directory:</p>
<pre><code>cd BP_DP-xlanro00</code></pre></li>
<li><p>Create and enter the virtual enviroment:</p>
<pre><code>virtualenv .venv &amp;&amp; source .venv/bin/activate</code></pre></li>
<li><p>Install required python modules from <strong>requirements.txt</strong>:</p>
<pre><code>pip install -r requirements.txt</code></pre></li>
<li><p>Now, you are all set to run the application. Examples of how to do this are listedin the section bellow.</p></li>
</ol>
<h1 id="filtering-images">Filtering images</h1>
<p>Once all the requirements are installed, the application is ready to use. Fingerprint sample is located in res/examples, its name is Palec_P4.tif.</p>
<ul>
<li><p>You will need to enter the virtual enviroment every time you want to use the application.</p>
<pre><code>source .venv/bin/activate</code></pre></li>
<li><p>The application requires <strong>input</strong> and <strong>output filenames</strong> including path from the root project directory, <strong>dpi</strong> and <strong>filter list</strong> as shown bellow.</p>
<pre><code>python3 src/main.py input_file output_file dpi filters</code></pre></li>
</ul>
<p>There are two ways to enter the filters:</p>
<ol type="1">
<li><p>manually list all filter names and their parameters on the <strong>command line</strong>:</p>
<pre><code>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</code></pre></li>
<li><p>load them from preset in a JSON <strong>configuration file</strong>, that can be used to tune and modify existing presets, or create new ones:</p>
<pre><code>python3 src/main.py res/examples/Palec_P4.tif res/examples/Palec_P4_from_preset.png 600 --config conf/conf.json git_example</code></pre></li>
</ol>
<h2 id="configuration-and-presets">Configuration and presets</h2>
<h1 id="section"></h1>
<p>There is an option to input the filter series as a preset from JSON configuration file. Here the presets are stored and are ready to be used whenever needed. You can usehow many filters you need as long as you like the output. It is therefore highly recommended to check the output after every preset change.</p>
<p>Filter used in the example above is listed bellow, along with the general form of configuration file.</p>
<style>
table {
border-collapse: collapse;
width: 100%;
}
th, td {
padding: 8px;
text-align: left;
border-bottom: 1px solid #ddd;
}
th {
background-color: #f2f2f2;
}
.code {
font-family: 'Courier New', monospace;
background-color: #f5f5f5;
padding: 8px;
}
.language-json {
color: #333;
}
</style>
<table>
<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": [
{
"name": "denoise_tv_chambolle",
"weight": 0.01,
"iterations": 1
},
{
"name": "median",
"ksize": 3
}
]
}
</code></pre>
</td>
</tr>
</tbody>
</table>
<p>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.</p>
<p>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. There is also an option to save current command line setting as a preset using -d switch and its new name:</p>
<h2 id="available-filters-with-parameters">Available filters with parameters</h2>
<h1 id="section-1"></h1>
<p>Overview of all implemented filters and their parameters with descriptions is listed below.</p>
<ul>
<li><p>median blur</p>
<ul>
<li>ksize (int) - Kernel size, determines how large of an area the filter processes.</li>
</ul></li>
<li><p>gaussian blur</p>
<ul>
<li>sigma (int) - Gaussian kernel standart deviation, determines the weight of further pixels on the currently processed pixel.</li>
</ul></li>
<li><p>bilateral blur</p>
<ul>
<li>diameter (int) - Diameter of pixel neighborhood used for filtering.</li>
<li>sigmaColor (int) - Determines the weight of pixels of different color.</li>
<li>sigmaSpace (int) - Determines the weight of further pixels.</li>
</ul></li>
<li><p>bilateral_scikit</p>
<ul>
<li>sigmaColor (float) - Determines the weight of pixels of different color.</li>
<li>sigmaSpace (float) - Determines the weight of further pixels.</li>
</ul></li>
<li><p>nlmeans (non-local means)</p>
<ul>
<li>patch_size (int) - Size of patches used for denoising.</li>
<li>patch_distance (int) - Distance in pixels where to search for patches.</li>
<li>h (float) - Cut-off distance, higher means more smoothed image.</li>
</ul></li>
<li><p>total_variation</p>
<ul>
<li>weight (float) - Denoising weight, determines how much the image will be denoised.</li>
</ul></li>
<li><p>block_match</p>
<ul>
<li>sigma (float)- Standart deviation</li>
</ul></li>
<li><p>unsharp mask scikit</p>
<ul>
<li>radius (int) - Radius of the gaussian filter.</li>
<li>amount (float) - Strength of the unsharp mask, determines how much of the mask will be used for filtering.</li>
</ul></li>
<li><p>farid</p></li>
<li><p>meijering</p></li>
<li><p>sato</p></li>
<li><p>hessian</p>
<ul>
<li>sigmas (float) - Standart deviations</li>
</ul></li>
<li><p>invert</p></li>
<li><p>scale_values</p></li>
<li><p>binarize</p>
<ul>
<li>threshold (int) - Value to cut differentiate pixels.</li>
</ul></li>
<li><p>binarize_otsu</p></li>
<li><p>add_margin</p>
<ul>
<li>margin (int) - Number of pixels to add to the sides of the image.</li>
<li>color (int) - Color value of newly added pixels.</li>
</ul></li>
<li><p>erode</p>
<ul>
<li>kernel (numpy matrix) - Shape of the kernel used to erode image.</li>
</ul></li>
<li><p>dilate</p>
<ul>
<li>kernel (numpy matrix)- Shape of the kernel used to dilate image.</li>
</ul></li>
</ul>
<h1 id="generating-fingerprint-model">Generating fingerprint model</h1>
<h2 id="generating-curved-finger-model">Generating curved finger model</h2>
<p>It is possible to generate stl model using the <code>--stl</code> switch. This requires more parameters, first of which is the type of generated fingerprint.</p>
<p>If the mode is set to <code>c</code>, the output model will be a curved finger model, with optional parameters following the filename controlling its shape.</p>
<p>First optional parameter is papilar line height <code>height_line</code>, second is thickness of the model <code>height_base</code>, third the rate of curvature along x axis <code>curv_rate_x</code> and the third is the rate of curvature along y axis <code>curv_rate_y</code>.</p>
<ul>
<li><p>General form for curved stl generation:</p>
<pre><code>python3 src/main.py input_file output_file dpi --config config_file preset --stl c height_line height_base curvature_x curvature_y</code></pre></li>
<li><p>Working example curved stl generation:</p>
<pre><code>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</code></pre></li>
</ul>
<h2 id="generating-planar-finger-model">Generating planar finger model</h2>
<p>Using <code>p</code> mode makes the generated fingerprint model flat. Optional parameters are height of the papilar lines and base thickness.</p>
<ul>
<li><p>General command form for planar stl generation:</p>
<pre><code>python3 src/main.py input_file output_file dpi --config config_file preset --stl p height_line height_base</code></pre></li>
<li><p>Working example of planar stl generation:</p>
<pre><code>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</code></pre></li>
</ul>
<h2 id="mapping-to-existing-finger-model">Mapping to existing finger model</h2>
<p>This section will be added later, (if implemented) mapping of fingerprint to a given finger model.</p>
<ul>
<li><p>General command form for mapped stl generation:</p>
<pre><code>python3 src/main.py input_file output_file dpi --config config_file preset --stl m height_line height_base finger_file</code></pre></li>
</ul>
<h1 id="usage">Usage</h1>
<p>When in doubt, you can always check the help with:</p>
<pre><code>python3 src/main.py --help</code></pre>
<p>Which will print out the following message.</p>
<pre><code>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</code></pre>
<h1 id="troubleshooting">Troubleshooting</h1>
<table>
<thead>
<tr>
<th>
Error message
</th>
<th>
Solution
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
main.py: error: the following arguments are required: input_file, output_file, dpi, filters
</td>
<td>
You probably forgot to include some of the required arguments.
</td>
</tr>
<tr>
<td>
ERROR: Input file res/Palec_P14.tif does not exist
</td>
<td>
The file you want to process does not exist, check the filename again.
</td>
</tr>
<tr>
<td>
ERROR: Config file not found
</td>
<td>
The config file you want to load config from does not exist, check the filename again.
</td>
</tr>
<tr>
<td>
ERROR: Preset not found in config file
</td>
<td>
The preset is not present in selected config file, check the file again or select the correct config file.
</td>
</tr>
<tr>
<td>
ERROR: Filter undefined_filter not found
</td>
<td>
One of the filters from command line is not defined in the library, check its name.
</td>
</tr>
<tr>
<td>
ERROR: Unrecognized generation mode
</td>
<td>
The first parameter of stl generation should be p, c or m, check it again.
</td>
</tr>
<tr>
<td>
ERROR: Line depth must be less than plate thickness
</td>
<td>
When generating a cast, the depth must be less than the base plate thckness, otherwise it would have holes on the other side.
</td>
</tr>
<tr>
<td>
ERROR: Depth of plate height must be positive
</td>
<td>
Cannot generate negative base plate thickness, check order of arguments.
</td>
</tr>
<tr>
<td>
ERROR: Base and line height must both be positive
</td>
<td>
In curved generation any negative argument is an error, casts are only for planar mode.
</td>
</tr>
</tbody>
</table>

@ -0,0 +1,441 @@
# User Manual for fingerprint image filtering and model generating application
## Introduction
This project has been developed as a part of bachelor's thesis at Brno University of Technology - Faculty of Information Technology.
The topic of this thesis was Generating a 3D Fingerprint Model from input fingerprint image.
This application consists of two main parts.The first part of the application uses image filters to enhance fingerprint images.
Application also implements a custom filter library, which consists of several filters imported from image processing modules.
The second part uses the processed image to make a 3D model of the fingerprint.
The model can then be used to print an accurate representation of human fingerprint using a 3D printer.
## Getting started
The application has only been tested on Ubuntu gnu/linux machines.
It should however be possible to use it in on most linux distributions, WSLs and also virtual machines of most linux distributions.
To start off, you need these to succesfully use the application.
* **python** version 3.10 is a requirement might work on earlier python 3 versions:
```
sudo apt install python3.10
```
* **virtualenv** package for virtual enviroment creation, other packages are installed automatically later:
```
pip install virtualenv
```
## Installation
This will install the application and its components into the Documents directory.
It will also install several required python packages, including venv, which is used to create a virtual enviroment.
1. Go to a suitable installation folder, for example **Documents**:
```
cd /home/username/Documents
```
2. Clone the repository to a suitable directory, for example:
```
git clone ssh://git@strade.fit.vutbr.cz:3022/xlanro00/BP_DP-xlanro00.git
```
3. Go inside cloned directory:
```
cd BP_DP-xlanro00
```
4. Create and enter the virtual enviroment:
```
virtualenv .venv && source .venv/bin/activate
```
5. Install required python modules from **requirements.txt**:
```
pip install -r requirements.txt
```
6. Now, you are all set to run the application.
Examples of how to do this are listedin the section bellow.
# Filtering images
Once all the requirements are installed, the application is ready to use.
Fingerprint sample is located in res/examples, its name is Palec_P4.tif.
* You will need to enter the virtual enviroment every time you want to use the application.
```
source .venv/bin/activate
```
* The application requires **input** and **output filenames** including path from the root project directory, **dpi** and **filter list** as shown bellow.
```
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**:
```
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:
```
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.
Here the presets are stored and are ready to be used whenever needed. You can usehow many filters you need as long as you like the output.
It is therefore highly recommended to check the output after every preset change.
Filter used in the example above is listed bellow, along with the general form of configuration file.
<style>
table {
border-collapse: collapse;
width: 100%;
}
th, td {
padding: 8px;
text-align: left;
border-bottom: 1px solid #ddd;
}
th {
background-color: #f2f2f2;
}
.code {
font-family: 'Courier New', monospace;
background-color: #f5f5f5;
padding: 8px;
}
.language-json {
color: #333;
}
</style>
<table>
<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": [
{
"name": "denoise_tv_chambolle",
"weight": 0.01,
"iterations": 1
},
{
"name": "median",
"ksize": 3
}
]
}
</code></pre>
</td>
</tr>
</tbody>
</table>
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.
There is also an option to save current command line setting as a preset using -d switch and it's new name:
## Available filters with parameters
#
Overview of all implemented filters and their parameters with descriptions is listed below.
- median blur
- ksize (int) - Kernel size, determines how large of an area the filter processes.
- gaussian blur
- sigma (int) - Gaussian kernel standart deviation, determines the weight of further pixels on the currently processed pixel.
- bilateral blur
- diameter (int) - Diameter of pixel neighborhood used for filtering.
- sigmaColor (int) - Determines the weight of pixels of different color.
- sigmaSpace (int) - Determines the weight of further pixels.
- bilateral_scikit
- sigmaColor (float) - Determines the weight of pixels of different color.
- sigmaSpace (float) - Determines the weight of further pixels.
- nlmeans (non-local means)
- patch_size (int) - Size of patches used for denoising.
- patch_distance (int) - Distance in pixels where to search for patches.
- h (float) - Cut-off distance, higher means more smoothed image.
- total_variation
- weight (float) - Denoising weight, determines how much the image will be denoised.
- block_match
- sigma (float)- Standart deviation
- unsharp mask scikit
- radius (int) - Radius of the gaussian filter.
- amount (float) - Strength of the unsharp mask, determines how much of the mask will be used for filtering.
- farid
- meijering
- sato
- hessian
- sigmas (float) - Standart deviations
- invert
- scale_values
- binarize
- threshold (int) - Value to cut differentiate pixels.
- binarize_otsu
- add_margin
- margin (int) - Number of pixels to add to the sides of the image.
- color (int) - Color value of newly added pixels.
- erode
- kernel (numpy matrix) - Shape of the kernel used to erode image.
- dilate
- kernel (numpy matrix)- Shape of the kernel used to dilate image.
# Generating fingerprint model
## 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`.
* General form for curved stl generation:
```
python3 src/main.py input_file output_file dpi --config config_file preset --stl c height_line height_base curvature_x curvature_y
```
* Working example curved stl generation:
```
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
```
## Generating planar finger model
Using `p` mode makes the generated fingerprint model flat.
Optional parameters are height of the papilar lines and base thickness.
* General command form for planar stl generation:
```
python3 src/main.py input_file output_file dpi --config config_file preset --stl p height_line height_base
```
* Working example of planar stl generation:
```
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
```
## Mapping to existing finger model
This section will be added later, (if implemented) mapping of fingerprint to a given finger model.
* General command form for mapped stl generation:
```
python3 src/main.py input_file output_file dpi --config config_file preset --stl m height_line height_base finger_file
```
# Usage
When in doubt, you can always check the help with:
python3 src/main.py --help
Which will print out the following message.
```
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
```
# Troubleshooting
<table>
<thead>
<tr>
<th>Error message</th>
<th>Solution</th>
</tr>
</thead>
<tbody>
<tr>
<td>
main.py: error: the following arguments are required: input_file, output_file, dpi, filters
</td>
<td>
You probably forgot to include some of the required arguments.
</td>
</tr>
<tr>
<td>
ERROR: Input file res/Palec_P14.tif does not exist
</td>
<td>
The file you want to process does not exist, check the filename again.
</td>
</tr>
<tr>
<td>
ERROR: Config file not found
</td>
<td>
The config file you want to load config from does not exist, check the filename again.
</td>
</tr>
<tr>
<td>
ERROR: Preset not found in config file
</td>
<td>
The preset is not present in selected config file, check the file again or select the correct config file.
</td>
</tr>
<tr>
<td>
ERROR: Filter undefined_filter not found
</td>
<td>
One of the filters from command line is not defined in the library, check its name.
</td>
</tr>
<tr>
<td>
ERROR: Unrecognized generation mode
</td>
<td>
The first parameter of stl generation should be p, c or m, check it again.
</td>
</tr>
<tr>
<td>
ERROR: Line depth must be less than plate thickness
</td>
<td>
When generating a cast, the depth must be less than the base plate thckness, otherwise it would have holes on the other side.
</td>
</tr>
<tr>
<td>
ERROR: Depth of plate height must be positive
</td>
<td>
Cannot generate negative base plate thickness, check order of arguments.
</td>
</tr>
<tr>
<td>
ERROR: Base and line height must both be positive
</td>
<td>
In curved generation any negative argument is an error, casts are only for planar mode.
</td>
</tr>
</tbody>
</table>

@ -0,0 +1,5 @@
# Author: xlanro00
# Makefile pro preklad manualu a dokumentace
manual:
pandoc doc/manual/manual.md -o doc/manual/manual.html
Loading…
Cancel
Save