Skip to content

Commit

Permalink
Enhancements
Browse files Browse the repository at this point in the history
VS2019 Platform Tools support (v142), Added Matthews Correlation Coefficient performance metric, Python build pipeline enhancements with mac support and a python fix to update_to_binary.
  • Loading branch information
brandonmpetty committed Oct 10, 2021
1 parent eb6bd71 commit 7324ec8
Show file tree
Hide file tree
Showing 18 changed files with 817 additions and 28 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/pythonpackage.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
name: Python package

on:
push:
# push:
release:
types:
- published

jobs:
build-wheels:
#if: github.event_name == 'release' && github.event.action == 'published'

strategy:
matrix:
os: [ubuntu-latest, windows-latest]
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: [3.8]
runs-on: ${{ matrix.os }}

Expand All @@ -34,12 +33,13 @@ jobs:
python -m cibuildwheel
env:
CIBW_ARCHS: auto64
# C++17 support started in MacOS 10.13, full support in 10.14+
MACOSX_DEPLOYMENT_TARGET: 10.14
- uses: actions/upload-artifact@v2
with:
path: Bindings/Python/wheelhouse/*.whl

build-sdist:
#if: github.event_name == 'release' && github.event.action == 'published'

runs-on: ubuntu-latest

Expand Down
3 changes: 2 additions & 1 deletion Bindings/Python/DoxaPy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ py::dict CalculatePerformance(const py::array_t<Pixel8>& groundTruthImageArray,
auto dict = py::dict();
dict["accuracy"] = ClassifiedPerformance::CalculateAccuracy(classifications);
dict["fm"] = ClassifiedPerformance::CalculateFMeasure(classifications);
dict["mcc"] = ClassifiedPerformance::CalculateMCC(classifications);
dict["psnr"] = ClassifiedPerformance::CalculatePSNR(classifications);
dict["nrm"] = ClassifiedPerformance::CalculateNRM(classifications);
dict["drdm"] = DRDM::CalculateDRDM(groundTruthImage, binaryImage);
Expand Down Expand Up @@ -72,7 +73,7 @@ class Binarization
{
Binarization binAlg(algorithm);
binAlg.Initialize(imageArray);
binAlg.ToBinary(imageArray);
binAlg.ToBinary(imageArray, parameters);
}

Algorithms CurrentAlgorithm() { return algorithm; }
Expand Down
1 change: 1 addition & 0 deletions Bindings/Python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ DoxaPy is an image binarization library focussing on local adaptive thresholding
* 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.


Expand Down
10 changes: 9 additions & 1 deletion Bindings/Python/setup.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import sys
from setuptools import setup
from pathlib import Path
from pybind11.setup_helpers import Pybind11Extension

cflags = []
Expand All @@ -15,12 +16,19 @@
),
]

# Read contents from the README
this_directory = Path(__file__).parent
long_description = (this_directory / "README.md").read_text()

if __name__ == "__main__":
setup(
author="Brandon M. Petty",
author_email="[email protected]",
name="doxapy",
description="An image binarization library focussing on local adaptive thresholding",
version="0.9.0",
long_description=long_description,
long_description_content_type="text/markdown",
version="0.9.1",
url="https://github.com/brandonmpetty/doxa",
license="CC0-1.0",
ext_modules=ext_modules
Expand Down
3 changes: 3 additions & 0 deletions Bindings/WebAssembly/DoxaWasm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ struct Performance
{
double Accuracy;
double FM;
double MCC;
double PSNR;
double NRM;
double DRDM;
Expand All @@ -34,6 +35,7 @@ Performance CalculatePerformance(intptr_t groundTruthData, intptr_t binaryData,
Performance perf;
perf.Accuracy = ClassifiedPerformance::CalculateAccuracy(classifications);
perf.FM = ClassifiedPerformance::CalculateFMeasure(classifications);
perf.MCC = ClassifiedPerformance::CalculateMCC(classifications);
perf.PSNR = ClassifiedPerformance::CalculatePSNR(classifications);
perf.NRM = ClassifiedPerformance::CalculateNRM(classifications);
perf.DRDM = DRDM::CalculateDRDM(groundTruthImage, binaryImage);
Expand Down Expand Up @@ -134,6 +136,7 @@ EMSCRIPTEN_BINDINGS(doxa_wasm) {
value_object<Performance>("Performance")
.field("accuracy", &Performance::Accuracy)
.field("fm", &Performance::FM)
.field("mcc", &Performance::MCC)
.field("psnr", &Performance::PSNR)
.field("nrm", &Performance::NRM)
.field("drdm", &Performance::DRDM);
Expand Down
2 changes: 1 addition & 1 deletion Bindings/WebAssembly/dist/doxaWasm.js

Large diffs are not rendered by default.

Binary file modified Bindings/WebAssembly/dist/doxaWasm.wasm
Binary file not shown.
12 changes: 7 additions & 5 deletions Demo/Cpp/demo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,18 @@ void DisplayPerformance(const Doxa::Image& groundTruthImage, const Doxa::Image&

double scoreAccuracy = Doxa::ClassifiedPerformance::CalculateAccuracy(classifications);
double scoreFM = Doxa::ClassifiedPerformance::CalculateFMeasure(classifications);
double scoreMCC = Doxa::ClassifiedPerformance::CalculateMCC(classifications);
double scorePSNR = Doxa::ClassifiedPerformance::CalculatePSNR(classifications);
double scoreNRM = Doxa::ClassifiedPerformance::CalculateNRM(classifications);
double scoreDRDM = Doxa::DRDM::CalculateDRDM(groundTruthImage, binaryImage);

std::cout << std::endl
<< "Accuracy:\t" << scoreAccuracy << std::endl
<< "F-Measure:\t" << scoreFM << std::endl
<< "PSNR:\t\t" << scorePSNR << std::endl
<< "NRM:\t\t" << scoreNRM << std::endl
<< "DRDM:\t\t" << scoreDRDM << std::endl
<< "Accuracy:\t" << scoreAccuracy << std::endl
<< "F-Measure:\t" << scoreFM << std::endl
<< "MCC:\t\t" << scoreMCC << std::endl
<< "PSNR:\t\t" << scorePSNR << std::endl
<< "NRM:\t\t" << scoreNRM << std::endl
<< "DRDM:\t\t" << scoreDRDM << std::endl
<< std::endl;
}

Expand Down
2 changes: 2 additions & 0 deletions Demo/Cpp/demoOpenCV.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,15 @@ void DisplayPerformance(const Doxa::Image& groundTruthImage, const Doxa::Image&

double scoreAccuracy = Doxa::ClassifiedPerformance::CalculateAccuracy(classifications);
double scoreFM = Doxa::ClassifiedPerformance::CalculateFMeasure(classifications);
double scoreMCC = Doxa::ClassifiedPerformance::CalculateMCC(classifications);
double scorePSNR = Doxa::ClassifiedPerformance::CalculatePSNR(classifications);
double scoreNRM = Doxa::ClassifiedPerformance::CalculateNRM(classifications);
double scoreDRDM = Doxa::DRDM::CalculateDRDM(groundTruthImage, binaryImage);

std::cout << std::endl
<< "Accuracy:\t" << scoreAccuracy << std::endl
<< "F-Measure:\t" << scoreFM << std::endl
<< "MCC:\t\t" << scoreMCC << std::endl
<< "PSNR:\t\t" << scorePSNR << std::endl
<< "NRM:\t\t" << scoreNRM << std::endl
<< "DRDM:\t\t" << scoreDRDM << std::endl
Expand Down
2 changes: 2 additions & 0 deletions Demo/Cpp/demoQt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,15 @@ void DisplayPerformance(const Doxa::Image& groundTruthImage, const Doxa::Image&

double scoreAccuracy = Doxa::ClassifiedPerformance::CalculateAccuracy(classifications);
double scoreFM = Doxa::ClassifiedPerformance::CalculateFMeasure(classifications);
double scoreMCC = Doxa::ClassifiedPerformance::CalculateMCC(classifications);
double scorePSNR = Doxa::ClassifiedPerformance::CalculatePSNR(classifications);
double scoreNRM = Doxa::ClassifiedPerformance::CalculateNRM(classifications);
double scoreDRDM = Doxa::DRDM::CalculateDRDM(groundTruthImage, binaryImage);

std::cout << std::endl
<< "Accuracy:\t" << scoreAccuracy << std::endl
<< "F-Measure:\t" << scoreFM << std::endl
<< "MCC:\t\t" << scoreMCC << std::endl
<< "PSNR:\t\t" << scorePSNR << std::endl
<< "NRM:\t\t" << scoreNRM << std::endl
<< "DRDM:\t\t" << scoreDRDM << std::endl
Expand Down
Loading

0 comments on commit 7324ec8

Please sign in to comment.