An image binarization library focussing on local adaptive thresholding
Project description
DoxaPy
Introduction
DoxaPy is an image binarization library focussing on local adaptive thresholding algorithms. In English, this means that it has the ability to turn a color or gray scale image into a black and white image.
Algorithms
- Otsu - "A threshold selection method from gray-level histograms", 1979.
- Bernsen - "Dynamic thresholding of gray-level images", 1986.
- Niblack - "An Introduction to Digital Image Processing", 1986.
- Sauvola - "Adaptive document image binarization", 1999.
- Wolf - "Extraction and Recognition of Artificial Text in Multimedia Documents", 2003.
- Gatos - "Adaptive degraded document image binarization", 2005. (Partial)
- NICK - "Comparison of Niblack inspired Binarization methods for ancient documents", 2009.
- Su - "Binarization of Historical Document Images Using the Local Maximum and Minimum", 2010.
- T.R. Singh - "A New local Adaptive Thresholding Technique in Binarization", 2011.
- Bataineh - "An adaptive local binarization method for document images based on a novel thresholding method and dynamic windows", 2011. (unreproducible)
- ISauvola - "ISauvola: Improved Sauvola’s Algorithm for Document Image Binarization", 2016.
- WAN - "Binarization of Document Image Using Optimum Threshold Modification", 2018.
Optimizations
- Shafait - "Efficient Implementation of Local Adaptive Thresholding Techniques Using Integral Images", 2008.
- Petty - An algorithm for efficiently calculating the min and max of a local window. Unpublished, 2019.
- Chan - "Memory-efficient and fast implementation of local adaptive binarization methods", 2019.
Performance Metrics
- Overall Accuracy
- F-Measure
- Peak Signal-To-Noise Ratio (PSNR)
- Negative Rate Metric (NRM)
- Matthews Correlation Coefficient (MCC)
- Distance-Reciprocal Distortion Measure (DRDM) - "An Objective Distortion Measure for Binary Document Images Based on Human Visual Perception", 2002.
Overview
DoxaPy uses the Δoxa Binarization Framework for quickly processing python Image files.
Example
This short demo uses DoxaPy to read in a color image, converts it to binary, and then compares it to a Ground Truth image in order to calculate performance.
from PIL import Image
import numpy as np
import doxapy
def read_image(file):
return np.array(Image.open(file).convert('L'))
# Read our target image and setup an output image buffer
grayscale_image = read_image("2JohnC1V3.png")
binary_image = np.empty(grayscale_image.shape, grayscale_image.dtype)
# Pick an algorithm from the DoxaPy library and convert the image to binary
sauvola = doxapy.Binarization(doxapy.Binarization.Algorithms.SAUVOLA)
sauvola.initialize(grayscale_image)
sauvola.to_binary(binary_image, {"window": 75, "k": 0.2})
# Calculate the binarization performance using a Ground Truth image
groundtruth_image = read_image("2JohnC1V3-GroundTruth.png")
performance = doxapy.calculate_performance(groundtruth_image, binary_image)
print(performance)
# Display our resulting image
Image.fromarray(binary_image).show()
Alternative Calls
DoxaPy can very efficiently reuse the same memory buffer for converting a grayscale image to binary. Unless you are constantly changing algorithm parameters for the same image, it is recommended that you call this method.
# Transforms the grayscale image buffer into binary with a single call
doxapy.Binarization.update_to_binary(doxapy.Binarization.Algorithms.NICK, grayscale_image)
Building with Pybind11
Release Build - Requires: NumPy, Pybind11
clone https://github.com/brandonmpetty/Doxa
cd Doxa/Bindings/Python
python copy-cpp-files.py
python setup.py install
License
CC0 - Brandon M. Petty, 2021
To the extent possible under law, the author(s) have dedicated all copyright and related and neighboring rights to this software to the public domain worldwide. This software is distributed without any warranty.
"Freely you have received; freely give." - Matt 10:8
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
File details
Details for the file doxapy-0.9.1.tar.gz
.
File metadata
- Download URL: doxapy-0.9.1.tar.gz
- Upload date:
- Size: 35.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5e4dac8752f2f667541e4ce35fb7c20056b7e6c3ce4e8c3a37726b83f4475ac6 |
|
MD5 | ea428d918f4638d2abe36abea11ad45f |
|
BLAKE2b-256 | 8b864c5dbc27fa60a519a14ae4c7a9b64e29b6f590eeeba00c95f2e838e4ef33 |
Provenance
File details
Details for the file doxapy-0.9.1-pp37-pypy37_pp73-win_amd64.whl
.
File metadata
- Download URL: doxapy-0.9.1-pp37-pypy37_pp73-win_amd64.whl
- Upload date:
- Size: 110.0 kB
- Tags: PyPy, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9c306b5d23259e9ec21def64b9ca0f345f8e8d5412c90867a3eccc36b67f8760 |
|
MD5 | 83b418216e630865f9b5e160d14a9c57 |
|
BLAKE2b-256 | f4aad8e2965b416559f59e623fec074300d51191f0ba56e90ed10776c76374f7 |
Provenance
File details
Details for the file doxapy-0.9.1-pp37-pypy37_pp73-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
.
File metadata
- Download URL: doxapy-0.9.1-pp37-pypy37_pp73-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
- Upload date:
- Size: 157.0 kB
- Tags: PyPy, manylinux: glibc 2.12+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5d843803879ea13a6c01e07493babb94e1b90434b2d5a454def0c2907811bdb0 |
|
MD5 | 427ba34bb2b140546697d8e7ded137e9 |
|
BLAKE2b-256 | 6df8378ae727bb85b78c9a1177a1f853b4941e7849022d9bfa0348be60174cee |
Provenance
File details
Details for the file doxapy-0.9.1-pp37-pypy37_pp73-macosx_10_14_x86_64.whl
.
File metadata
- Download URL: doxapy-0.9.1-pp37-pypy37_pp73-macosx_10_14_x86_64.whl
- Upload date:
- Size: 140.0 kB
- Tags: PyPy, macOS 10.14+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a2c77f3747d4c2e7996d6314f37901480ef5955e85421197905bcbb7b4a54fc5 |
|
MD5 | d2fed6e0ae49414b5744cc38dddb1ca9 |
|
BLAKE2b-256 | 744eb5152735765d65c3379d4fb7774633e02f3cee47190d6ef4269c6c4bd7cd |
Provenance
File details
Details for the file doxapy-0.9.1-cp310-cp310-win_amd64.whl
.
File metadata
- Download URL: doxapy-0.9.1-cp310-cp310-win_amd64.whl
- Upload date:
- Size: 111.6 kB
- Tags: CPython 3.10, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a3b93f8bd4fa7fcf7df04ad4b0f1057a78ec37024f5c10a6b439e2a914329aca |
|
MD5 | 6d3e01db2e4f5d6e219d6a88b3e88b37 |
|
BLAKE2b-256 | aead722cbd95862e90c83a87cacfed9ea83359b537a4f607bcfdf9b44bd112c3 |
Provenance
File details
Details for the file doxapy-0.9.1-cp310-cp310-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
.
File metadata
- Download URL: doxapy-0.9.1-cp310-cp310-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
- Upload date:
- Size: 164.4 kB
- Tags: CPython 3.10, manylinux: glibc 2.12+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1a2ef8e0bfced7fc03fbc982f3e9737a0b8ce8054b498e1c8f6d1a3f929c2d07 |
|
MD5 | 0af7165cb26d4a59be81f82ba953492c |
|
BLAKE2b-256 | 5181381104e3924257893a2a3ebc2723350ef03c5e440ad18091f8259831ea3f |
Provenance
File details
Details for the file doxapy-0.9.1-cp310-cp310-macosx_10_14_x86_64.whl
.
File metadata
- Download URL: doxapy-0.9.1-cp310-cp310-macosx_10_14_x86_64.whl
- Upload date:
- Size: 131.2 kB
- Tags: CPython 3.10, macOS 10.14+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5c131ed63cb998862b2e214fdefa6725875d6dabd43014a7c4224a8e07610058 |
|
MD5 | bfef970251e1e6f20a273417d6fc30e7 |
|
BLAKE2b-256 | 017b84d5ca5c6945dd27e48a5b3b22b925fdac588761e43ddd2a3c7c56cd2f9d |
Provenance
File details
Details for the file doxapy-0.9.1-cp39-cp39-win_amd64.whl
.
File metadata
- Download URL: doxapy-0.9.1-cp39-cp39-win_amd64.whl
- Upload date:
- Size: 110.6 kB
- Tags: CPython 3.9, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6d89ec02e9df484ffcaa1000f3ac3743c78149a4e0a4b950c7b286434df3d62c |
|
MD5 | 9dee85adbd7fac3f0038f7a4c35d570c |
|
BLAKE2b-256 | af7afb4d97d1784f46dfffb12515765db85115406c7bb8eb18b150d5f0d74123 |
Provenance
File details
Details for the file doxapy-0.9.1-cp39-cp39-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
.
File metadata
- Download URL: doxapy-0.9.1-cp39-cp39-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
- Upload date:
- Size: 164.6 kB
- Tags: CPython 3.9, manylinux: glibc 2.12+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | edffcb11cc8c1a7be2996eb339ef44ba4cd7d17db26cf80700c0480e9703eaf0 |
|
MD5 | ff93c9f239c84571b01cf2b342b5ab5a |
|
BLAKE2b-256 | be60de834e664ca3a69e8d5b0e152d43af9a97ba2e95376a303f0549b966bd56 |
Provenance
File details
Details for the file doxapy-0.9.1-cp39-cp39-macosx_10_14_x86_64.whl
.
File metadata
- Download URL: doxapy-0.9.1-cp39-cp39-macosx_10_14_x86_64.whl
- Upload date:
- Size: 131.4 kB
- Tags: CPython 3.9, macOS 10.14+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3246e4770c15ff6231c0a688f1818eead33a77ec4c3ac64e1e45803aac0af6c5 |
|
MD5 | 0dcdcb0bf7c79452146fb7e1c25b8ab2 |
|
BLAKE2b-256 | e995eb2f4b006a3e61649c07a512a1e13941b4c3020d8b3b0ae8f3b01a965cbb |
Provenance
File details
Details for the file doxapy-0.9.1-cp38-cp38-win_amd64.whl
.
File metadata
- Download URL: doxapy-0.9.1-cp38-cp38-win_amd64.whl
- Upload date:
- Size: 111.5 kB
- Tags: CPython 3.8, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b5ad6a401bfd374208cb4e1d30f6dee5d483d294cbf4cb28862618a2e978221a |
|
MD5 | 046f48aeb4654d3ac1f1fc065d74a37b |
|
BLAKE2b-256 | 696db77baee5efa521730abdedf2605010918e642c738abee62b0795f09da9a0 |
Provenance
File details
Details for the file doxapy-0.9.1-cp38-cp38-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
.
File metadata
- Download URL: doxapy-0.9.1-cp38-cp38-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
- Upload date:
- Size: 164.5 kB
- Tags: CPython 3.8, manylinux: glibc 2.12+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d675f72c5808068e8fb9c3b5fa64976f5ddfac96deb24a2e710c9791fdfd208f |
|
MD5 | 4a77919efbd90faebd5022fbcbce9054 |
|
BLAKE2b-256 | c1140a539b9ccef9dcf8bdf47cd84a67917d292f13af5f22d637dd6beade23d8 |
Provenance
File details
Details for the file doxapy-0.9.1-cp38-cp38-macosx_10_14_x86_64.whl
.
File metadata
- Download URL: doxapy-0.9.1-cp38-cp38-macosx_10_14_x86_64.whl
- Upload date:
- Size: 131.2 kB
- Tags: CPython 3.8, macOS 10.14+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 04d66f2c4116ee82223bd1e36eabf7d8d01d6e216f3d9edaf94991a49f335a50 |
|
MD5 | fec2f0d0f567fbda7159ee3cfa2989b3 |
|
BLAKE2b-256 | e6b27d82cc7d0d2fb3fb56107901f014e33a67fc5353a890c3fcf156de264c9d |
Provenance
File details
Details for the file doxapy-0.9.1-cp37-cp37m-win_amd64.whl
.
File metadata
- Download URL: doxapy-0.9.1-cp37-cp37m-win_amd64.whl
- Upload date:
- Size: 111.8 kB
- Tags: CPython 3.7m, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 39974441e210fb998dce1965e30d11f2be4339385e5a2c96c1eb1635b5ffa313 |
|
MD5 | f9465ead37ff4b0461f5ba4dd75e53ce |
|
BLAKE2b-256 | fe72567d67ccb0177a4ee957334f1577826a1d6765da36dcacb224001e035475 |
Provenance
File details
Details for the file doxapy-0.9.1-cp37-cp37m-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
.
File metadata
- Download URL: doxapy-0.9.1-cp37-cp37m-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
- Upload date:
- Size: 166.0 kB
- Tags: CPython 3.7m, manylinux: glibc 2.12+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b19b41786a30fa6d2ffec79c1737885f2351da999e1051b39ea9be32741a8c9e |
|
MD5 | 521baf2d571b99771a611f220fddbb0d |
|
BLAKE2b-256 | 9ed537034207803f23bb76340b5998924426c42f0e6c09d2857b433e0335198d |
Provenance
File details
Details for the file doxapy-0.9.1-cp37-cp37m-macosx_10_14_x86_64.whl
.
File metadata
- Download URL: doxapy-0.9.1-cp37-cp37m-macosx_10_14_x86_64.whl
- Upload date:
- Size: 128.6 kB
- Tags: CPython 3.7m, macOS 10.14+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 92fd1ff04317e1d42709aca987908cdc3c33598c9a3bab16b641d19cb53db74b |
|
MD5 | efb4d9394fafd9dc818e5946c1fa5cbf |
|
BLAKE2b-256 | c2bb800bd14a1c0b0f843e1b02737be757c74a13ae9d7f802dabd7db604f5d20 |
Provenance
File details
Details for the file doxapy-0.9.1-cp36-cp36m-win_amd64.whl
.
File metadata
- Download URL: doxapy-0.9.1-cp36-cp36m-win_amd64.whl
- Upload date:
- Size: 111.8 kB
- Tags: CPython 3.6m, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fd144872df38f822a85c55596624640933bba37aef51ce790c166f09d3c4a2d0 |
|
MD5 | 5a53021ac0a76b76a32629ccf339997f |
|
BLAKE2b-256 | d7b565fe69db9ef8cbfb7a20807de89a63922aa1cd76765cb472162c825ad751 |
Provenance
File details
Details for the file doxapy-0.9.1-cp36-cp36m-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
.
File metadata
- Download URL: doxapy-0.9.1-cp36-cp36m-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
- Upload date:
- Size: 165.9 kB
- Tags: CPython 3.6m, manylinux: glibc 2.12+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6cc152a88aed848e453c8b3cc4e5658c09591b3bb3e71cac3e815f4b2266b0ea |
|
MD5 | 530e196d49651698b1ba0a89c36f5352 |
|
BLAKE2b-256 | 9c8ce2f0572ac1ffc14e65cbe1fcc9514145fa4681c29cd853f87fd3fd363171 |
Provenance
File details
Details for the file doxapy-0.9.1-cp36-cp36m-macosx_10_14_x86_64.whl
.
File metadata
- Download URL: doxapy-0.9.1-cp36-cp36m-macosx_10_14_x86_64.whl
- Upload date:
- Size: 128.6 kB
- Tags: CPython 3.6m, macOS 10.14+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 42b2bf0423c61838749693b90a0c5db39d9d5782eb4142a62ee7c9d09e1e8379 |
|
MD5 | 814d22f1db3d29178c69073cf58bd9a0 |
|
BLAKE2b-256 | d65cd58716b835589b7f83d056e77aa53dcb0c77013c35eb2f3052129377d6d3 |