Skip to content

Commit ae47f03

Browse files
committed
Update to ImageCore 0.9
1 parent 55c1310 commit ae47f03

File tree

7 files changed

+18
-15
lines changed

7 files changed

+18
-15
lines changed

Project.toml

Lines changed: 2 additions & 5 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,11 +19,10 @@ 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"
25+
ImageCore = "0.9"
2826
ImageFiltering = "0.6"
2927
ImageMorphology = "0.2.6"
3028
LightGraphs = "1.1"
@@ -36,8 +34,7 @@ julia = "1"
3634

3735
[extras]
3836
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
39-
Images = "916415d5-f1e6-5110-898d-aaa5f9f070e0"
4037
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
4138

4239
[targets]
43-
test = ["Documenter", "Images", "Test"]
40+
test = ["Documenter", "Test"]

src/ImageSegmentation.jl

Lines changed: 2 additions & 1 deletion
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
include("compat.jl")
@@ -41,7 +42,7 @@ export
4142
kmeans,
4243
fuzzy_cmeans,
4344
merge_segments,
44-
45+
4546
# types
4647
SegmentedImage,
4748
ImageEdge

src/core.jl

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

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

src/felzenszwalb.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,12 @@ function felzenszwalb(img::AbstractArray{T, 2}, k::Real, min_size::Int = 0) wher
9393
I1, Iend = first(R), last(R)
9494
num = 1
9595
for I in R
96+
imgI = img[I]
9697
for J in CartesianIndices(_colon(max(I1, I-I1), min(Iend, I+I1)))
9798
if I >= J
9899
continue
99100
end
100-
edges[num] = ImageEdge((I[2]-1)*rows+I[1], (J[2]-1)*rows+J[1], sqrt(sum(abs2,(img[I])-meantype(T)(img[J]))))
101+
edges[num] = ImageEdge((I[2]-1)*rows+I[1], (J[2]-1)*rows+J[1], sqrt(_abs2(imgI-meantype(T)(img[J]))))
101102
num += 1
102103
end
103104
end

src/region_growing.jl

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
2-
default_diff_fn(c1::CT1,c2::CT2) where {CT1<:Union{Colorant,Real}, CT2<:Union{Colorant,Real}} = sqrt(sum(abs2,(c1)-accum_type(CT2)(c2)))
3-
41
"""
52
seg_img = seeded_region_growing(img, seeds, [kernel_dim], [diff_fn])
63
seg_img = seeded_region_growing(img, seeds, [neighbourhood], [diff_fn])

test/runtests.jl

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

55
using Documenter

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)