Skip to content

Commit 043f8fc

Browse files
authored
[compat] ImageCore 0.10 (#97)
This also yanks out the old `abs2` deprecation in favor of using the new implementation in ColorVectorSpace.
1 parent 32eb2dc commit 043f8fc

File tree

4 files changed

+5
-10
lines changed

4 files changed

+5
-10
lines changed

Project.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "ImageSegmentation"
22
uuid = "80713f31-8817-5129-9cf8-209ff8fb23e1"
3-
version = "1.8.1"
3+
version = "1.8.2"
44

55
[deps]
66
Clustering = "aaaa29a8-35af-508c-8bc3-b662a17a0fe5"
@@ -23,7 +23,7 @@ DataStructures = "0.17.11, 0.18"
2323
Distances = "0.8, 0.9.2, 0.10"
2424
Documenter = "0.24, 0.25"
2525
Graphs = "1.4.1"
26-
ImageCore = "0.9"
26+
ImageCore = "0.10"
2727
ImageFiltering = "0.6, 0.7"
2828
ImageMorphology = "0.2.6, 0.3, 0.4"
2929
MetaGraphs = "0.7"

src/core.jl

+1-6
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,7 @@ accum_type(::Type{C}) where {C<:Colorant} = base_colorant_type(C){accum_type(e
77
accum_type(val) = isa(val, Type) ? throw_accum_type(val) : convert(accum_type(typeof(val)), val)
88
throw_accum_type(T) = error("type $T not supported in `accum_type`")
99

10-
# TODO:
11-
# _abs2(c::MathTypes) = c ⋅ c
12-
_abs2(c::MathTypes) = mapreducec(v->float(v)^2, +, 0, c)
13-
_abs2(x) = abs2(x)
14-
15-
default_diff_fn(c1::CT1,c2::CT2) where {CT1<:Union{Colorant,Real}, CT2<:Union{Colorant,Real}} = sqrt(_abs2(c1-accum_type(c2)))
10+
default_diff_fn(c1::CT1,c2::CT2) where {CT1<:Union{Colorant,Real}, CT2<:Union{Colorant,Real}} = sqrt(abs2(c1-accum_type(c2)))
1611

1712
"""
1813
`SegmentedImage` type contains the index-label mapping, assigned labels,

src/felzenszwalb.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ function felzenszwalb(img::AbstractArray{T}, k::Real, min_size::Int = 0) where T
102102
if I >= J
103103
continue
104104
end
105-
edges[num+=1] = ImageEdge(L[I], L[J], sqrt(_abs2(imgI-meantype(T)(img[J]))))
105+
edges[num+=1] = ImageEdge(L[I], L[J], sqrt(abs2(imgI-meantype(T)(img[J]))))
106106
end
107107
end
108108
deleteat!(edges, num+1:num_edges) # compensate for the ones we were missing at the image edges

test/flood_fill.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ using Test
5656
# Colors
5757
path = download("https://github.com/JuliaImages/juliaimages.github.io/raw/source/docs/src/pkgs/segmentation/assets/flower.jpg")
5858
img = load(path)
59-
seg = flood(img, CartesianIndex(87,280); thresh=0.3*sqrt(3)) # TODO: eliminate the sqrt(3) when we transition to `abs2(c) = c ⋅ c`
59+
seg = flood(img, CartesianIndex(87,280); thresh=0.3)
6060
@test 0.2*length(seg) <= sum(seg) <= 0.25*length(seg)
6161
c = mean(img[seg])
6262
# N0f8 makes for easier approximate testing

0 commit comments

Comments
 (0)