JuliaImages / ImageBinarization.jl

A Julia package of algorithms for analyzing images and automatically binarizing them into background and foreground.
MIT License
35 stars 8 forks source link

[WIP] refactor codebase with functor APIs #29

Closed johnnychen94 closed 5 years ago

johnnychen94 commented 5 years ago

I found filter specification greatly reduces the complexity of code structure and improves the style consistency when I played with ImageQualityIndexes and ImageNoise. Check my GSoC 2019 blog The principles of Images.jl: Part I as an example and illustration. Also, see Proposal: add abstract types ImageAlgorithm and ImageFilter for a unified API that enables extensibility without loss of API consistency.

To make this PR easy to review, the first eight commits serve as a start point, future commits are submitted in the form of PRs.

TODO:

codecov[bot] commented 5 years ago

Codecov Report

Merging #29 into master will decrease coverage by 23.92%. The diff coverage is 95.95%.

Impacted file tree graph

@@             Coverage Diff             @@
##           master      #29       +/-   ##
===========================================
- Coverage   94.47%   70.55%   -23.93%     
===========================================
  Files          16       20        +4     
  Lines         163      180       +17     
===========================================
- Hits          154      127       -27     
- Misses          9       53       +44
Impacted Files Coverage Δ
src/sauvola.jl 0% <ø> (-93.75%) :arrow_down:
src/niblack.jl 0% <ø> (-93.75%) :arrow_down:
src/ImageBinarization.jl 100% <ø> (ø) :arrow_up:
src/polysegment.jl 0% <ø> (-91.67%) :arrow_down:
src/minimum_error.jl 100% <100%> (ø) :arrow_up:
src/intermodes.jl 100% <100%> (ø) :arrow_up:
src/otsu.jl 100% <100%> (ø) :arrow_up:
src/moments.jl 100% <100%> (ø) :arrow_up:
src/BinarizationAPI/binarize.jl 100% <100%> (ø)
src/unimodal.jl 100% <100%> (ø) :arrow_up:
... and 16 more

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 2ff0e10...07704cb. Read the comment docs.

codecov-io commented 5 years ago

Codecov Report

Merging #29 into master will decrease coverage by 23.92%. The diff coverage is 95.95%.

Impacted file tree graph

@@             Coverage Diff             @@
##           master      #29       +/-   ##
===========================================
- Coverage   94.47%   70.55%   -23.93%     
===========================================
  Files          16       20        +4     
  Lines         163      180       +17     
===========================================
- Hits          154      127       -27     
- Misses          9       53       +44
Impacted Files Coverage Δ
src/sauvola.jl 0% <ø> (-93.75%) :arrow_down:
src/niblack.jl 0% <ø> (-93.75%) :arrow_down:
src/ImageBinarization.jl 100% <ø> (ø) :arrow_up:
src/polysegment.jl 0% <ø> (-91.67%) :arrow_down:
src/minimum_error.jl 100% <100%> (ø) :arrow_up:
src/intermodes.jl 100% <100%> (ø) :arrow_up:
src/otsu.jl 100% <100%> (ø) :arrow_up:
src/moments.jl 100% <100%> (ø) :arrow_up:
src/BinarizationAPI/binarize.jl 100% <100%> (ø)
src/unimodal.jl 100% <100%> (ø) :arrow_up:
... and 16 more

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 2ff0e10...88202fe. Read the comment docs.

codecov-io commented 5 years ago

Codecov Report

Merging #29 into master will increase coverage by 0.46%. The diff coverage is 96.69%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #29      +/-   ##
==========================================
+ Coverage   94.47%   94.94%   +0.46%     
==========================================
  Files          16       20       +4     
  Lines         163      178      +15     
==========================================
+ Hits          154      169      +15     
  Misses          9        9
Impacted Files Coverage Δ
src/util.jl 100% <ø> (ø) :arrow_up:
src/ImageBinarization.jl 100% <ø> (ø) :arrow_up:
src/minimum_error.jl 100% <100%> (ø) :arrow_up:
src/intermodes.jl 100% <100%> (ø) :arrow_up:
src/otsu.jl 100% <100%> (ø) :arrow_up:
src/sauvola.jl 94.73% <100%> (+0.98%) :arrow_up:
src/moments.jl 100% <100%> (ø) :arrow_up:
src/BinarizationAPI/binarize.jl 100% <100%> (ø)
src/niblack.jl 100% <100%> (+6.25%) :arrow_up:
src/unimodal.jl 100% <100%> (ø) :arrow_up:
... and 14 more

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 2ff0e10...125c3e4. Read the comment docs.

johnnychen94 commented 5 years ago

Regardless of all those dirty and lengthy details in this PR which I believe nobody would like to review, as a summary, this PR does:

Breaking changes (Deprecated in 0.3):

made window_size of AdaptiveThreshold not an optional argument.

The idea here is to encourage users to use AdaptiveThreshold(img) to infer window_size rather than some fixed integer 32.


Any comments before I merge this PR? @zygmuntszpak