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
Hashes for doxapy-0.9.2-pp39-pypy39_pp73-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bc2974fce823e2fb85b5750acc882d3e2b2b35716a491d0f15572abaae39d1d4 |
|
MD5 | 2b73a32c933674ee1b67250553994cc8 |
|
BLAKE2b-256 | 0e0cb71909eb2d32a7bea7fdb0dcc6ecb3d03351d91ed0b78daa9595df06c1cd |
Hashes for doxapy-0.9.2-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8532deca56a43643fc9e7975517312b0f45f886fec3bb5aa80bd0ebcb5d22ab9 |
|
MD5 | ee4e04c26612cf0d619ee508ee9329b0 |
|
BLAKE2b-256 | 945e93b2a6706ccca40ae516d082f0deedfd816d5cfa9a1b4d0f46b2daef4d69 |
Hashes for doxapy-0.9.2-pp39-pypy39_pp73-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 399a9ab92dffdcbd9fea986adbdad1e83335aeea09c1bace3dcf4a3b8c45ef70 |
|
MD5 | 2adc3f7d10db48805733a69bad061794 |
|
BLAKE2b-256 | b8fc9407ab0d93c2620ca7a112288a98fe4ca535ad03ae08dceb8da1206d78a2 |
Hashes for doxapy-0.9.2-pp38-pypy38_pp73-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e29213e1128658633c4992c25990bf4d8a222c9848608fd528743e3843b45166 |
|
MD5 | 72f36ea9bdab828383a7b3eee9631a48 |
|
BLAKE2b-256 | 2b921b761c0359253286512d1b3262b54506aa6f32f169c42564c7e8b4df80fb |
Hashes for doxapy-0.9.2-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7fcb57b57479dfec1eb9c54fe28ff132b8f56b7bbc141a850134fb7ee97c8e98 |
|
MD5 | e091c1d20d42ca902eb1b95ee6813937 |
|
BLAKE2b-256 | 2416b0782c88218a59223df1ac00a42a6aa96fb03ccd949a4d55503eedb1fc75 |
Hashes for doxapy-0.9.2-pp38-pypy38_pp73-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a742d3c1339c917beef083132337bc6b1f3ad244fa6b050111814197fc12b5e0 |
|
MD5 | 1830ff020552b045c86bf5b4748f8d18 |
|
BLAKE2b-256 | c666731d73838ba89070c43e7732e4a1d661d995a54b32dfbf445d78ac0886db |
Hashes for doxapy-0.9.2-pp37-pypy37_pp73-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 00ee4e9a1953d236e25f2f0791e489d0cbdbc56bd4f5e018345be79dce7a805b |
|
MD5 | 0d79f7027519c1245ee4b0330f3446cf |
|
BLAKE2b-256 | b300823f84c7d6f2601ab1c309a36b6d53c950a47f320ca642179e44da32d83f |
Hashes for doxapy-0.9.2-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 42b84e4b4e0e526d5744c01770969ce748b0c290c54dd17c64dc7e627341ed51 |
|
MD5 | 5d024b29fcfc9c80c6c9255b39d4f3a0 |
|
BLAKE2b-256 | 5bc373446b8ca2c6d639c3fb408f386835494329da8c4a3f76b21bb1fce91cc7 |
Hashes for doxapy-0.9.2-pp37-pypy37_pp73-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4b5ec49774a1e40867acb1e88d82a299d633f293dbf60fe8b1a082ede5052e48 |
|
MD5 | 3cdaee1db0b6a0cc3c9e77f3ce44d1fd |
|
BLAKE2b-256 | a15d6dd5e0ddb028ee630c2581bb86dbc68b705d38e751af96e2b264528f6ac8 |
Hashes for doxapy-0.9.2-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | af87a2a843c2fe30d57a2dc89a7add9d61d62df4fdb85c071126f3dd66dc0d58 |
|
MD5 | 1cb6c1307e96e3c5f263658de016175d |
|
BLAKE2b-256 | 268fb2b2c1d130e43e563fefaa94b8beaf14bd931eaa0df7e54443b2db003bdc |
Hashes for doxapy-0.9.2-cp311-cp311-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 30d3336dc58c8f10812c1844cf2aab0ef8c10c73240507ba29e749af88b95ee4 |
|
MD5 | 6a61ca22e93919a4e1bade98bf24b6b1 |
|
BLAKE2b-256 | 2615805116a1092532f23f149cab24dbdb71f1639bc37961b3312cb024d43437 |
Hashes for doxapy-0.9.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7710e6ae075b39764fa69ddb7cea8a1b44396ed0ba1da1284685c4d9f83d458c |
|
MD5 | 730f7aec4c9b20e7aed3776c3c4fb26c |
|
BLAKE2b-256 | 26ea276cddbce40512bac66e7b534a14e9e439948f94afb32fb10282494bda59 |
Hashes for doxapy-0.9.2-cp311-cp311-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 36891cd7b42e110cbb67716bab5a3e31c5ab97476ad5fd1fd34245e4ae1e768c |
|
MD5 | cc466aefd84f3b6acf0f622024f671c0 |
|
BLAKE2b-256 | e1a7ec267647b6c369ea9e00c869acaaf04643b0c55379817bd2c5e078b372bb |
Hashes for doxapy-0.9.2-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f12e7572cf923d89d62c3dbe1438e141aaef798933fdd60dda3aab4a20d9d9f2 |
|
MD5 | 4f92efad4df948228fdc4204e3b69a10 |
|
BLAKE2b-256 | 11cab4f7f44837a98fd6e792de790f3b63c7c5d350f87e001b114f9ac815c36c |
Hashes for doxapy-0.9.2-cp310-cp310-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5898f3827ad286bdeac1efa241f99605e2c65f20f09dafa7a725a635c276b7db |
|
MD5 | 63da748cb415b91211b41e2399ec0ca1 |
|
BLAKE2b-256 | 9d4650c6a712c7242e67d03e47784eb63a28d127b02a12b178618580e9c5891e |
Hashes for doxapy-0.9.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 07e272e7090228322d49d85506a5c1a19e18ad6d262526fb5e8650a88680089f |
|
MD5 | 3a9baef29f5f8c31ed06e2ae9a20ac01 |
|
BLAKE2b-256 | c0723fff222d35fd951be9ecb864286c93cb313d15b2ec945b60b8bff73fe52f |
Hashes for doxapy-0.9.2-cp310-cp310-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ade8aba9aa558af184c7a9533bd4ef811e3be6d022ce370fbc230c5eea156357 |
|
MD5 | cef1354d60710eba73e1f16d3e5fea3c |
|
BLAKE2b-256 | 8d07072a7c04dbe30a705756454ff9bd04a3b6147f514d7ac54e35eacfb987cb |
Hashes for doxapy-0.9.2-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8c5762676006ed4f9ae0b567467fa979d24aba6f9addb54326c77acd50153202 |
|
MD5 | 94bfca39fb25045094ed278dc3f04011 |
|
BLAKE2b-256 | bca0b4342ae3e49829803869f461813d4ef52ba692c0f37179d19082236aff6d |
Hashes for doxapy-0.9.2-cp39-cp39-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bd8d0a25cc39cb246138883fa01d1fd31c5d397dc681585a757a1c68d2a2ccc2 |
|
MD5 | 5de2f6ba9a5509972771906986251028 |
|
BLAKE2b-256 | bcd85b1ffc3b41ba87c391b059bdb30a49b8274784d82b8c8f1c466b17f28c00 |
Hashes for doxapy-0.9.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c43474e2761b778a568d8df0cf7a87ffa1a4ed23cd0b31eee2160db6df22e69c |
|
MD5 | 1d2490ca486183a28e92ff00bd88144f |
|
BLAKE2b-256 | 80805a623df6c7aa691427ff35c5dd65cfe9aecd62091c8b85fb89c8577bd463 |
Hashes for doxapy-0.9.2-cp39-cp39-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5e0a053a74d2f7ec6af9f5c809363657fd1ccccf645140c6cb2ab563318e22e6 |
|
MD5 | 6e39d56acdde71873c96d6b618317ba0 |
|
BLAKE2b-256 | 9948205cb6e4673b317dbb6433e369bab7dc2c48f9f03346ca47259ee1d90881 |
Hashes for doxapy-0.9.2-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | df7283abfab199510ac85d8afd4bc6a1cb00134f79d1f25e1de4f4a209d0190d |
|
MD5 | 4f3596b44a96ca5ff747e7a040434820 |
|
BLAKE2b-256 | 82442e5288edaa86798c6e600c58eb9b6d311c6526eade8306503fe9baf02c93 |
Hashes for doxapy-0.9.2-cp38-cp38-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a3239147070957c29460341ee30e0ca3d6bf96593edce75c21ab515e3f943e87 |
|
MD5 | c907dd583c0e7f57045c6dcdb14872cb |
|
BLAKE2b-256 | 56657c7d68e2061d9e5a40c202142e99d66cda124fc8ec1f32eeceab4e21c81f |
Hashes for doxapy-0.9.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 03f7c760aff816e5f0c421635b21d67ec6a15c15c953d8eda306701b5b1d77af |
|
MD5 | 6a4380ea9745720c965fadf6bc145573 |
|
BLAKE2b-256 | 4ba6a8bb61789d05221b59ae37c0832b4dc2315826706c36aa3e0b008f3ef62d |
Hashes for doxapy-0.9.2-cp38-cp38-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 216e42f2c1d17cfed94cab1e4a5ebf554d1c0c296d0e1d719598f92a09e48a87 |
|
MD5 | 256c06b14b2c94d0731cf63c9f7743fb |
|
BLAKE2b-256 | 49e1235ef24085ab64cf93d72e2ecd004634c790dcecff1fbe598a1bf0ce75f1 |
Hashes for doxapy-0.9.2-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fb90b82b21ed72efef3285e59e2d866c9c95cb33aac7f9077c06d62707f8397f |
|
MD5 | afe528b2e89045795001123b6fc9e859 |
|
BLAKE2b-256 | d43526920bf4204f16efc6d6ab693d875a598b34cdfda78e8a6439ca7ba4d634 |
Hashes for doxapy-0.9.2-cp37-cp37m-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0ef1f1bd6c8bb519b8f0f48bfffb9d07e6743055855b7a47610c36cb9b4efab1 |
|
MD5 | 8649ca485571d82dc6f1bec4999f7b20 |
|
BLAKE2b-256 | f6ce74afa10dffa2740d561d2672603c2dfeb764e1708a6cdf78dc576f084fa4 |
Hashes for doxapy-0.9.2-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f1c6d125d24d74542c9c509a323ab2fb580db378173c617cd11d2d34bdb1243a |
|
MD5 | 65a01566e4866e863f5a625c8c26fa0b |
|
BLAKE2b-256 | 35e79231a25ea6a02d03395373287177715b41a8e559b52ae0a5ad21c6af5d5f |
Hashes for doxapy-0.9.2-cp37-cp37m-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e719b2b0d1df754fb781707f6494fedbbf8740df65100aad5b92f5aacb56ac62 |
|
MD5 | 54c27e6444049f9dd8187737ebf320bf |
|
BLAKE2b-256 | 5f96499784196a7f26704eae6ba85509fbbb678421884c01049c3528dbeb84ef |
Hashes for doxapy-0.9.2-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fea8b79d16179913c53ac20948955539743535c66064b45b6f1ca3ec17c75cfa |
|
MD5 | d5154e04dbc394c75d0cfc2326c03ef7 |
|
BLAKE2b-256 | 63f145ea8d8dca574aa84f06074d638334e783feae7314a5110e3f4db7e64703 |
Hashes for doxapy-0.9.2-cp36-cp36m-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6cbb37184918faacf40c90804cb8d50b33006ef3a99ae839ed116e6efa447638 |
|
MD5 | e8977be58a32974db26188c6aada9cf9 |
|
BLAKE2b-256 | 59616a98bda8de1727b59c32ada53edef0f200acfbbaf26f63eec7dbd62c93e9 |
Hashes for doxapy-0.9.2-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 76fafc3779859d7afdcf2d86745157fe1b6523c9bf87ddd55d20416ee6d2e45b |
|
MD5 | c0f4a33533c1e822760f075e6c0e8d82 |
|
BLAKE2b-256 | e4b93d9c6fb8484bcb95f9f2c3dbaab210f90d48dd697756996b13664724a8b4 |
Hashes for doxapy-0.9.2-cp36-cp36m-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a76f72e4fa92f80c5e3e3349cbc4571e656bc072ee082f53dd8fb936c20b3927 |
|
MD5 | 3a2355924b7d046b6e40c4af2f795cff |
|
BLAKE2b-256 | 7f2077cc3e59497c81d665bd1769555de394dbafb49c5b48b4f41abd6640fc68 |