handwritten writer identification using classical machine learning pattern recognition techniques
you can install the requirements using
pip install -r requirements.txt
or you can use conda to create a virtual environment and install packages using
conda env create -f environment.yaml
At the right is the test image.
At the left are the tuning images of the 3 authors sorted from top to bottom (1, 2, 3).
Our system predicted author 1 for this test sample.
1- Make sure to install all of the requirements.
2- Place test data at folder named data to be ordered in that matter:
data/001/1/1.png
data/001/1/2.png
data/001/2/1.png
data/001/2/2.png
data/001/3/1.png
data/001/3/2.png
data/001/test.png
and so on...
3- run: `python src/main.py`
4- check results at `results.txt` and timing at `time.txt`
A test case folder in the data folder should contain a folder for each author containing 2 images of that author, and a test image.
Results file will contain -for each test case at the data
folder- the predicted number of author that wrote the test.png
image.
Author number corresponds to the folder number that contains the images of the author.
We used IAM Handwritten Database to validate our pipeline.
It has the following statistics.
+ Total number of authors: 657
+ Total number of authors with three or more forms: 159
+ Total number of forms that correspond to the 159 authors that have 3 or more forms: 899
+ Total number of forms in the system: 1539
We ran our pipeline on the 159 authors that have three forms or more, selecting each form of one author at a time as a test image, and retrieving two other random authors for tuning, each author of the 3 has 2 tuning images.
We achieved 99.44 % accuracy, failing in only 5 trials out of the 899.
The pipeline is as follows 0. read the tune images and test image
- preprocess images and segment lines out of the image, then apply otsu binary thresholding.
- perform feature extraction using wavelet transform, then CSLBCoP that is local binary pattern (LBP) followed by grayscale co-occurrence matrix (GLCM) proposed by this paper.
- perform principal component analysis (PCA) to extract useful features from the resultant feature vector.
- fit the classifiers (we used SVM and KNN) to the tuning images, and predict the test image
- take a vote from the classifiers (in case SVM predicted with low confidence)
- report the predicted author and the time taken by pipeline without IO operations.
For more information, you can refer to the document
src
folder contains the main code for preprocessing, feature extraction, classification, pipeline, and evaluation.graphs
folder contains the useful generated graphs during development.doc
folder contains the project document.script
folder contains a shell script to organize the tuning data.
you can use the script
folder to organize the files of the IAM database, just move all the complete form images (that are like the test sample, not the words nor lines images) of the IAM database and put it in script
folder.
Running the script will create a data_tune
folder at the project directory and put the images of the same author at a separate folder in it.