Skip to content

Return value type from find_threshold doesn't match image #49

@timholy

Description

@timholy

Is the choice of returning a Float32 rather than a Gray{N0f8} deliberate?

julia> using ImageBinarization

julia> using ImageCore

julia> img = rand(Gray{N0f8}, 8, 8)
8×8 Array{Gray{N0f8},2} with eltype Gray{N0f8}:
 Gray{N0f8}(0.631)  Gray{N0f8}(0.486)  Gray{N0f8}(0.867)    Gray{N0f8}(0.745)  Gray{N0f8}(0.0)    Gray{N0f8}(0.361)
 Gray{N0f8}(0.847)  Gray{N0f8}(0.737)  Gray{N0f8}(0.765)     Gray{N0f8}(0.812)  Gray{N0f8}(0.533)  Gray{N0f8}(0.741)
 Gray{N0f8}(0.176)  Gray{N0f8}(0.89)   Gray{N0f8}(0.855)     Gray{N0f8}(0.373)  Gray{N0f8}(0.706)  Gray{N0f8}(0.333)
 Gray{N0f8}(0.204)  Gray{N0f8}(0.463)  Gray{N0f8}(0.286)     Gray{N0f8}(0.541)  Gray{N0f8}(0.094)  Gray{N0f8}(0.875)
 Gray{N0f8}(0.063)  Gray{N0f8}(0.792)  Gray{N0f8}(0.929)     Gray{N0f8}(0.714)  Gray{N0f8}(0.212)  Gray{N0f8}(0.957)
 Gray{N0f8}(0.616)  Gray{N0f8}(0.678)  Gray{N0f8}(0.737)    Gray{N0f8}(0.11)   Gray{N0f8}(0.176)  Gray{N0f8}(0.784)
 Gray{N0f8}(0.322)  Gray{N0f8}(0.263)  Gray{N0f8}(0.537)     Gray{N0f8}(0.357)  Gray{N0f8}(0.592)  Gray{N0f8}(0.8)
 Gray{N0f8}(0.514)  Gray{N0f8}(0.482)  Gray{N0f8}(0.545)     Gray{N0f8}(0.055)  Gray{N0f8}(0.89)   Gray{N0f8}(0.471)

julia> find_threshold(img, Otsu())
0.51138175f0

We can do either one, but this arises in the context of replacing otsu_threshold with this package in the Images 0.26 release; the implementation in Images.jl returns an element of the same type.

We just need a decision of whether this is an oversight or deliberate. If it's deliberate, in the depwarn we can add an explicit eltype(img)(find_threshold...).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions