Skip to content

Commit e18aea6

Browse files
authored
Update to ImageCore 0.9 (#72)
1 parent 22a75f7 commit e18aea6

File tree

7 files changed

+16
-15
lines changed

7 files changed

+16
-15
lines changed

Project.toml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ version = "1.5.1"
44

55
[deps]
66
Clustering = "aaaa29a8-35af-508c-8bc3-b662a17a0fe5"
7-
ColorVectorSpace = "c3611d14-8923-5661-9e6a-0046d554d3a4"
87
DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
98
Distances = "b4f34e82-e78d-54a5-968a-f98e89d6e8f7"
109
ImageCore = "a09fc81d-aa75-5fe9-8630-4744c3626534"
@@ -20,12 +19,11 @@ Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
2019

2120
[compat]
2221
Clustering = "0.10, 0.11, 0.12, 0.13, 0.14"
23-
ColorVectorSpace = "0.7, 0.8"
2422
DataStructures = "0.17.11, 0.18"
2523
Distances = "0.8, 0.9.2, 0.10"
2624
Documenter = "0.24, 0.25"
27-
ImageCore = "0.8.6"
28-
ImageFiltering = "0.6"
25+
ImageCore = "0.9"
26+
ImageFiltering = "0.6, 0.7"
2927
ImageMorphology = "0.2.6"
3028
LightGraphs = "1.1"
3129
MetaGraphs = "0.6.6"
@@ -38,9 +36,8 @@ julia = "1"
3836
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
3937
FileIO = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549"
4038
ImageMagick = "6218d12a-5da1-5696-b52f-db25d2ecc6d1"
41-
Images = "916415d5-f1e6-5110-898d-aaa5f9f070e0"
4239
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
4340
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
4441

4542
[targets]
46-
test = ["Documenter", "FileIO", "ImageMagick", "Images", "SparseArrays", "Test"]
43+
test = ["Documenter", "FileIO", "ImageMagick", "SparseArrays", "Test"]

src/ImageSegmentation.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import Base: show
44

55
using LinearAlgebra, Statistics
66
using DataStructures, StaticArrays, ImageCore, ImageFiltering, ImageMorphology, LightGraphs, SimpleWeightedGraphs, RegionTrees, Distances, StaticArrays, Clustering, MetaGraphs
7+
using ImageCore.ColorVectorSpace: MathTypes
78
import Clustering: kmeans, fuzzy_cmeans
89

910
const PairOrTuple{K,V} = Union{Pair{K,V},Tuple{K,V}}

src/core.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@ accum_type(::Type{T}) where {T<:Real} = Float64
44
accum_type(::Type{T}) where {T<:FixedPoint} = floattype(T)
55
accum_type(::Type{C}) where {C<:Colorant} = base_colorant_type(C){accum_type(eltype(C))}
66

7+
accum_type(val) = isa(val, Type) ? throw_accum_type(val) : convert(accum_type(typeof(val)), val)
8+
throw_accum_type(T) = error("type $T not supported in `accum_type`")
9+
10+
_abs2(c::MathTypes) = c c
11+
_abs2(x) = abs2(x)
12+
13+
default_diff_fn(c1::CT1,c2::CT2) where {CT1<:Union{Colorant,Real}, CT2<:Union{Colorant,Real}} = sqrt(_abs2(c1-accum_type(c2)))
14+
715
"""
816
`SegmentedImage` type contains the index-label mapping, assigned labels,
917
segment mean intensity and pixel count of each segment.

src/felzenszwalb.jl

Lines changed: 1 addition & 1 deletion
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

src/region_growing.jl

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
2-
default_diff_fn(c1::CT1,c2::CT2) where {CT1<:Union{Colorant,Real}, CT2<:Union{Colorant,Real}} = sqrt(_abs2((c1)-accum_type(CT2)(c2)))
3-
_abs2(c) = mapreducec(v->float(v)^2, +, 0, c)/length(c)
4-
51
"""
62
seg_img = seeded_region_growing(img, seeds, [kernel_dim], [diff_fn])
73
seg_img = seeded_region_growing(img, seeds, [neighbourhood], [diff_fn])

test/runtests.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using ImageSegmentation, Images, Test, SimpleWeightedGraphs, LightGraphs, StaticArrays, DataStructures
1+
using ImageSegmentation, ImageCore, ImageFiltering, Test, SimpleWeightedGraphs, LightGraphs, StaticArrays, DataStructures
22
using RegionTrees: isleaf, Cell, split!
33
using MetaGraphs: MetaGraph, clear_props!, get_prop, has_prop, set_prop!, props, vertices
44

test/watershed.jl

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ using ImageFiltering
44

55
img = zeros(100, 100)
66
img[25:75, 25:75] .= 1
7-
8-
img, _ = magnitude_phase(img)
7+
img[26:74, 26:74] .= 0
98

109
markers = zeros(Int, size(img))
1110
markers[1, 1] = 1
@@ -45,7 +44,7 @@ using ImageFiltering
4544
# since this is using the compact algorithm with a high value for
4645
# compactness, the boundary between labels 1 and 2 should occur halfway
4746
# between the two markers
48-
@test sum(labels .== 1) == sum(1:50) - 2
47+
@test sum(labels .== 1) == sum(1:50)
4948
end
5049

5150
@testset "h-minima transform" begin

0 commit comments

Comments
 (0)