Skip to content

Commit

Permalink
restrict img type to gray image for binarize!(img, f)
Browse files Browse the repository at this point in the history
  • Loading branch information
johnnychen94 committed Jul 22, 2019
1 parent b7ed27e commit ca471b8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/BinarizationAPI/BinarizationAPI.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
module BinarizationAPI

using ColorTypes
const GenericGrayImage = AbstractArray{<:Union{Number, AbstractGray}}

"""
AbstractImageAlgorithm
Expand Down
12 changes: 7 additions & 5 deletions src/BinarizationAPI/binarize.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@ TODO: Otsu
"""
abstract type AbstractImageBinarizationAlgorithm <: AbstractImageFilter end

binarize!(out, img,
binarize!(out::GenericGrayImage,
img,
f::AbstractImageBinarizationAlgorithm,
args...; kwargs...) =
f(out, img, args...; kwargs...)

function binarize!(img,
# in-place binarize! only supports gray image input
function binarize!(img::GenericGrayImage,
f::AbstractImageBinarizationAlgorithm,
args...; kwargs...)
tmp = copy(img)
Expand All @@ -40,10 +42,10 @@ function binarize(::Type{T},
return out
end

binarize(img,
binarize(img::AbstractArray{T},
f::AbstractImageBinarizationAlgorithm,
args...; kwargs...) =
binarize(Gray{eltype(eltype(img))}, img, f, args...; kwargs...)
args...; kwargs...) where T <:Union{Number, Colorant} =
binarize(Gray{eltype(T)}, img, f, args...; kwargs...)

### Docstrings

Expand Down

0 comments on commit ca471b8

Please sign in to comment.