Skip to content

Commit

Permalink
Bump DataStructures version and fix doctests on nightly (#55)
Browse files Browse the repository at this point in the history
* Fix find_root! depwarn

This became a depwarn with DataStructures 0.18 but was
available in 0.17.11.

* Generalize some docstrings

Julia 1.6 changes how array types are printed.
  • Loading branch information
timholy authored Aug 27, 2020
1 parent dd88106 commit 62fef9d
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 17 deletions.
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "ImageSegmentation"
uuid = "80713f31-8817-5129-9cf8-209ff8fb23e1"
version = "1.4.5"
version = "1.4.6"

[deps]
Clustering = "aaaa29a8-35af-508c-8bc3-b662a17a0fe5"
Expand All @@ -17,7 +17,7 @@ Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"

[compat]
Clustering = "0.10, 0.11, 0.12, 0.13, 0.14"
DataStructures = "0.12, 0.13, 0.14, 0.15, 0.16, 0.17"
DataStructures = "0.17.11, 0.18"
Distances = "0.8"
Documenter = "0.24, 0.25"
ImageFiltering = "0.6"
Expand Down
4 changes: 2 additions & 2 deletions src/core.jl
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ function prune_segments(s::SegmentedImage, is_rem::Function, diff_fn::Function)

segments = Set{Int}()
for i in 1:nv(G)
push!(segments, find_root(u, i))
push!(segments, find_root!(u, i))
end

result = similar(s.image_indexmap)
Expand All @@ -253,7 +253,7 @@ function prune_segments(s::SegmentedImage, is_rem::Function, diff_fn::Function)
end

for p in CartesianIndices(axes(result))
result[p] = find_root(u, vert_map[s.image_indexmap[p]])
result[p] = find_root!(u, vert_map[s.image_indexmap[p]])
region_pix_count[result[p]] = get(region_pix_count, result[p], 0) + 1
region_means[result[p]] = get(region_means, result[p], zero(m_type)) + (s.segment_means[s.image_indexmap[p]] - get(region_means, result[p], zero(m_type)))/(region_pix_count[result[p]])
end
Expand Down
8 changes: 4 additions & 4 deletions src/fast_scanning.jl
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ julia> img[:,2] .= 0.6;
julia> seg = fast_scanning(img, 0.2);
julia> labels_map(seg)
3×3 Array{Int64,2}:
3×3 $(Matrix{Int}):
1 4 5
4 4 4
3 4 6
Expand Down Expand Up @@ -88,15 +88,15 @@ function fast_scanning(img::AbstractArray{CT,N}, threshold::Union{AbstractArray,
prev_label = 0
for p in neighbourhood(point)
if checkbounds(Bool, img, p)
root_p = find_root(temp_labels, result[p])
root_p = find_root!(temp_labels, result[p])
if diff_fn(region_means[root_p], img[point]) < getscalar(threshold, point, block_length)
if prev_label == 0
prev_label = root_p
elseif prev_label != root_p
same_label = false
end
sz += 1
v_neigh[sz] = find_root(temp_labels, root_p)
v_neigh[sz] = find_root!(temp_labels, root_p)
end
end
end
Expand Down Expand Up @@ -138,7 +138,7 @@ function fast_scanning(img::AbstractArray{CT,N}, threshold::Union{AbstractArray,
end

for point in CartesianIndices(axes(img))
result[point] = find_root(temp_labels, result[point])
result[point] = find_root!(temp_labels, result[point])
end

SegmentedImage(result, unique(temp_labels.parents), region_means, region_pix_count)
Expand Down
12 changes: 6 additions & 6 deletions src/felzenszwalb.jl
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ function felzenszwalb(edges::Array{ImageEdge}, num_vertices::Int, k::Real, min_s

for edge in edges
w = edge.weight
a = find_root(G, edge.index1)
b = find_root(G, edge.index2)
a = find_root!(G, edge.index1)
b = find_root!(G, edge.index2)
if a!=b
if w <= min(threshold[a], threshold[b])
merged_root = union!(G, a, b)
Expand All @@ -54,16 +54,16 @@ function felzenszwalb(edges::Array{ImageEdge}, num_vertices::Int, k::Real, min_s

#merge small segments
for edge in edges
a = find_root(G, edge.index1)
b = find_root(G, edge.index2)
a = find_root!(G, edge.index1)
b = find_root!(G, edge.index2)
if a!=b && (set_size[a] < min_size || set_size[b] < min_size)
union!(G, a, b)
end
end

segments = OrderedSet()
for i in 1:num_vertices
push!(segments, find_root(G, i))
push!(segments, find_root!(G, i))
end

num_sets = length(segments)
Expand All @@ -74,7 +74,7 @@ function felzenszwalb(edges::Array{ImageEdge}, num_vertices::Int, k::Real, min_s

index_map = Array{Int}(undef, num_vertices)
for i in 1:num_vertices
index_map[i] = segments2index[find_root(G, i)]
index_map[i] = segments2index[find_root!(G, i)]
end

return index_map, num_sets
Expand Down
6 changes: 3 additions & 3 deletions src/region_growing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ julia> seeds = [(CartesianIndex(3,1),1),(CartesianIndex(2,2),2)];
julia> seg = seeded_region_growing(img, seeds);
julia> labels_map(seg)
4×4 Array{Int64,2}:
4×4 $(Matrix{Int}):
1 1 1 1
1 2 2 2
1 2 2 2
Expand Down Expand Up @@ -150,7 +150,7 @@ function seeded_region_growing(img::AbstractArray{CT,N}, seeds::AbstractVector{T
if curr_diff < mindiff
mindiff = curr_diff
mindifflabel = result[point]
elseif isapprox(curr_diff, mindiff) #, atol=1e-8)
elseif isapprox(curr_diff, mindiff) #, atol=1e-8)
mindifflabel = 0
end
end
Expand Down Expand Up @@ -221,7 +221,7 @@ julia> img[2:4,2:4] .= 1;
julia> seg = unseeded_region_growing(img, 0.2);
julia> labels_map(seg)
4×4 Array{Int64,2}:
4×4 $(Matrix{Int}):
1 1 1 1
1 2 2 2
1 2 2 2
Expand Down

2 comments on commit 62fef9d

@timholy
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/20378

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v1.4.6 -m "<description of version>" 62fef9dcd314ce1452fe787689ffcaf8f4d9a7f9
git push origin v1.4.6

Please sign in to comment.