Giter Club home page Giter Club logo

imagebinarization.jl's People

Contributors

betttris13 avatar github-actions[bot] avatar johnnychen94 avatar juliatagbot avatar rjww avatar sherrin0825 avatar thecosmicstorm avatar timholy avatar zygmuntszpak avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

imagebinarization.jl's Issues

duplicated travis CI

Looks like both travis-ci.org and travis-ci.com are used in CI tests.

I think you can disable one of them. BTW the URL link in README's CI badge is travis-ci.com :D

RFC: a new API that plans algorithm with prior information before binarize

In #30 we changed the usage of AdaptiveThreshold from

w = recommend_window_size(img)
f = AdaptiveThreshold(window_size = w, percentage = 15)
binarize(img, f)

to

f = AdaptiveThreshold(percentage = 15)
binarize(img, f)

By doing this, users no longer need to call recommend_window_size anymore, which is an improvement.

However, this isn't what we really want in the beginning, since we'd like to hold all parameters of AdaptiveThreshold inside of it.

a window_size is something that is intrinsic to an adaptive method since the existence of a window is what often differentiates global thresholding from adaptive local thresholding. A sensible choice of window_size does indeed depend on the size of the image.
-- @zygmuntszpak

As a solution, I’m keeping thinking of introducing another set of API that generate the algorithms with the “best” inferred parameters from prior information, for example, the usage could be:

# option 1
f = AdaptiveThreshold(img)
# option 2
f = algorithm_plan(:AdaptiveThreshold, img)

binarize(img, f)

The idea here is, use img to infer as much information as needed, and leave the others using the default value.

A toy implementation of option 1 could be:

AdaptiveThreshold(img::AbstractArray; kwargs...) = 
    AdaptiveThreshold(;window_size=default_AdaptiveThreshold_window_size(img), kwargs...)

P.S., a practical example of this design is used in my NonlocalMean, where we infer the best r_p (aka. window_size) using img.

introduce a curried form of `binarize`

It would be convenient to make binarize(alg) return a function so that

map(binarize(Yen()), imgs)

This is equivalent to binarize.(Ref(Yen()), imgs) but a function can be composed together with other functions using , or eventually the |> API similar to that in Augmentor:

pipeline = FlipX(0.5) |> Rotate([-5,-3,0,3,5]) |> CropSize(64,64) |> Zoom(1:0.1:1.2)

Cases that I know in Base are isequal, isapprox(in Julia 1.5), startwith(in Julia 1.5) and endswith(in Julia 1.5):

julia> map(isequal(2), 1:5)
5-element Array{Bool,1}:
 0
 1
 0
 0
 0

More info needed for Basic Usage example to work

The basic usage example has the below code:

img = testimage("cameraman")
alg = Otsu()
img = binarize(img, alg)

If one just copies and pastes the above into a Julia 1.2 REPL it does not work, even after adding in using ImageBinarization. Digging around the docs found mention of a using TestImages, but simply adding that package to Julia has its own issues when trying to use it on a MacOS 10.14.6 with errors about QuartzImageIO etc.. So for the sake of greater adoption and ease of use it would be worth having a nice self contained examples that one can simply cut and paste and have it work.

OffsetArray support

Currently,

using OffsetArrays, ImageBinarization
Xo = OffsetArray(rand(10, 10), OffsetArrays.Origin(0))
binarize(Xo, Otsu()) # oops

Background: common warp operations(e.g., imrotate) in ImageTransformations returns an OffsetArray.

transparent color support

Currently, ImageBinarization doesn't support transparent colors (e.g., RGBA) so I open this issue to see your opinions:

  • leave it unsupported
  • drop the transparent channel
  • keep the transparent channel and output the transparent gray color, e.g., GrayA{T} (Unfortunately, T can't be Bool here).

I'm not sure if we should support this. Neither dropping or making output GrayA{Float64} type doesn't sound very good to me.

cc: @ashwani-rathee

Swap arguments?

The package looks great, thanks for the contribution!

Would it make sense to swap the arguments? Most Julia APIs I've came across adopt the following convention:

binarize(img, alg)

as opposed to

binarize(alg, img)

I read the first version as "binarize the image with algorithm", the second version doesn't have a clear "spelling", at least for me.

I adopted the above mentioned convention in ImageInpatining.jl for example, and in the internals of GeoStats.jl in multiple places.

dispatch binarize on HistogramThresholding.ThresholdAlgorithm

It's a bit awkward that two closely related packages have name conflicts:

julia> using HistogramThresholding

julia> using ImageBinarization
[ Info: Precompiling ImageBinarization [cbc4b850-ae4b-5111-9e64-df94c024a13d]

julia> Yen
WARNING: both ImageBinarization and HistogramThresholding export "Yen"; uses of it in module Main must be qualified
ERROR: UndefVarError: Yen not defined

A simple and intuitive solution to this is to reuse the type HistogramThresholding.Yen and directly dispatch binarize on it. But this requires some code organization changes and it may have other unexpected side effects.

TagBot trigger issue

This issue is used to trigger TagBot; feel free to unsubscribe.

If you haven't already, you should update your TagBot.yml to include issue comment triggers.
Please see this post on Discourse for instructions and more details.

If you'd like for me to do this for you, comment TagBot fix on this issue.
I'll open a PR within a few hours, please be patient!

Please add install instructions

Please add install instructions for brand new user stumbling across Julia on how to add the package. This will increase usability.

Filter specification: an alternative to `binarize`

abstract type BinarizationAlgorithm end
struct Otsu <: BinarizationAlgorithm end

The current design is

  • (Design A)
binarize(algo::Otsu, img) = println("binarize img with Otsu")

The usage is

julia> algo = Otsu()
julia> binarize(algo, img)
binarize img with Otsu

Actually, there's an alternative design, which is commonly used in Flux.jl AFAIK

  • (Design B)
(binarizer::Otsu)(img) = println("binarize img with Otsu")

The usage is:

julia> binarizer = Otsu()
julia> binarizer(img)
binarize img with Otsu

In design A, two different algorithms are connected in two ways: BinarizationAlgorithm and binarize. In design B, they're only connected by BinarizationAlgorithm.

According to the naming guide https://github.com/JuliaImages/Images.jl/issues/767, we should use binarize

for functions that compute something or perform an operation, start with a verb (e.g., warp)

But I guess there would be some cases Design B is more natural.

Any ideas?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.