-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] refactor codebase with functor APIs #29
Conversation
file structure of NoiseAPI is available at: https://github.com/johnnychen94/ImageNoise.jl/tree/8934d6333d471857fef82af8b3a85cace1b87d47/src/NoiseAPI
* replace `BinarizationAlgorithm` with `AbstractImageBinarizationAlgorithm` * import `binarize` and `binarize!` from `BinarizationAPI` * move concrete algorithms struct definitions to seperated files This is a intermediate commit as a start point for the following code refactor, i.e., moving implementations to concrete functors
Codecov Report
@@ 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
Continue to review full report at Codecov.
|
* move implementations to AdaptiveThreshold functor * Rewrite AdaptiveThreshold with CartesianIndices to support n-D images * update and simplify the docstring * enhance the test codes and fix several bugs * add CartetianIndex compat to Julia 1.0 * deprecate `window_size` and `recommend_size`
This is a PR-commit for PR #29 that refactors the whole codebase to use the new functor API, which is discussed in more details in #26 and explained in my GSoC 2019 blog https://nextjournal.com/johnnychen94/the-principles-of-imagesjl-part-i Changes: * move implementations into functor * enhance the test codes with wider test coverage
This is a PR-commit for PR #29 that refactors the whole codebase to use the new functor API, which is discussed in more details in #26 and explained in my [GSoC 2019 blog](https://nextjournal.com/johnnychen94/the-principles-of-imagesjl-part-i) Changes: * support `Color3` input * move implementations into functor * enhance the test codes with wider test coverage
This is a PR-commit for PR #29 that refactors the whole codebase to use the new functor API, which is discussed in more details in #26 and explained in my [GSoC 2019 blog](https://nextjournal.com/johnnychen94/the-principles-of-imagesjl-part-i) Changes: * support `Color3` input * move implementations into functor * enhance the test codes with wider test coverage
This is a PR-commit for PR #29 that refactors the whole codebase to use the new functor API, which is discussed in more details in #26 and explained in my [GSoC 2019 blog](https://nextjournal.com/johnnychen94/the-principles-of-imagesjl-part-i) Changes: * support `Color3` input * move implementations into functor * enhance the test codes with wider test coverage
This is a PR-commit for PR #29 that refactors the whole codebase to use the new functor API, which is discussed in more details in #26 and explained in my [GSoC 2019 blog](https://nextjournal.com/johnnychen94/the-principles-of-imagesjl-part-i) Changes: * support `Color3` input * move implementations into functor * enhance the test codes with wider test coverage
refactor Intermodes using the functor API
refactor Balanced using the functor API
refactor MinimumError using functor API
function binarize(algorithm::AdaptiveThreshold, img::AbstractArray{T,2}) where T <: Gray | ||
s = algorithm.window_size | ||
t = algorithm.percentage | ||
if s < 0 || t < 0 || t > 100 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a reminder to myself:
we need to check whether the given window_size
is valid, i.e., >=0
for AdaptiveThreshold
, Niblack
, Sauvola
.
Codecov Report
@@ 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
Continue to review full report at Codecov.
|
Codecov Report
@@ 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
Continue to review full report at Codecov.
|
Otherwise it would return `nothing`
* AdaptiveThreshold: infer the window_size from img during construction * Niblack: revert the deprecation on window_size
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):
The idea here is to encourage users to use Any comments before I merge this PR? @zygmuntszpak |
I found filter specification greatly reduces the complexity of code structure and improves the style consistency when I played with
ImageQualityIndexes
andImageNoise
. 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:
AdaptiveThreshold
PR: refactor and enhance AdaptiveThreshold method #30Balanced
PR: refactor Balanced using the functor API #32Entropy
PR: refactor Entropy using the functor API #33Intermodes
PR: refactor Intermodes using the functor API #34MinimumError
PR: refactor MinimumError using functor API #35MinimumIntermodes
PR: refactor MinimumIntermodes using functor API #36Moments
PR: refactor Moments using the functor API #37Niblack
PR: refactor Niblack using the functor API #42Otsu
PR: refactor Otsu using the functor API #38Polysegment
PR: refactor Polysegment using the functor API #44Sauvola
PR: refactor Sauvola using the functor API #43UnimodalRosin
PR: refactor UnimodalRosin using the functor API #39Yen
PR: refactor Yen using the functor API #40recommend_size
with function AdaptiveThreshold (closes #41) #45binarize
#25)