Skip to content

Commit e495618

Browse files
authored
Bump DataStructures compat to 0.19 (#141)
* Switch to DataStructures 0.19: push, popfirst instead of enqueue, dequeue * Three-arg enqueue just pushes a pair * dequeue_pair can go too
1 parent dbdcc88 commit e495618

File tree

5 files changed

+18
-18
lines changed

5 files changed

+18
-18
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Requires = "ae029012-a4dd-5104-9daa-d747884805df"
1212
TiledIteration = "06e1c1a7-607b-532d-9fad-de7d9aa2abac"
1313

1414
[compat]
15-
DataStructures = "0.17.11, 0.18"
15+
DataStructures = "0.19"
1616
Documenter = "0.24, 0.25, 0.26, 0.27"
1717
ImageCore = "0.9, 0.10"
1818
LoopVectorization = "0.12"

src/ImageMorphology.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module ImageMorphology
22

3-
using DataStructures: Queue, enqueue!, dequeue!
3+
using DataStructures: Queue
44
using ImageCore
55
using ImageCore: GenericGrayImage, MappedArrays, FixedPointNumbers
66
using OffsetArrays

src/connected.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -512,10 +512,10 @@ function _generic_naive_labeling!(out, img, se, can_be_labelled=(x) -> true, is_
512512
# mark point as visited
513513
@inbounds visited[i] = true
514514
@inbounds out[i] = curr_label
515-
enqueue!(propagationfront, i)
515+
push!(propagationfront, i)
516516
while !isempty(propagationfront)
517517
#get indice from propagationfront
518-
idx_front = dequeue!(propagationfront)
518+
idx_front = popfirst!(propagationfront)
519519
# get value at current point
520520
@inbounds centervalue = img[idx_front]
521521
if can_be_labelled(centervalue) # eg could be specialize for no background
@@ -528,7 +528,7 @@ function _generic_naive_labeling!(out, img, se, can_be_labelled=(x) -> true, is_
528528
if is_connected(nl_value, centervalue)
529529
# yes, propagate the "connected" zones to this pixel
530530
@inbounds if !visited[ii]
531-
enqueue!(propagationfront, ii)
531+
push!(propagationfront, ii)
532532
# mark it as visited
533533
visited[ii] = true
534534
#propagate label

src/leveling.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Base.isless
22
import Base.isgreater
3-
import DataStructures.PriorityQueue, DataStructures.enqueue!, DataStructures.dequeue_pair!
3+
import DataStructures.PriorityQueue
44

55
"""
66
low_leveling(op, marker, mask; [dims])
@@ -66,14 +66,14 @@ function _low_leveling!(out::AbstractArray{T,N}, ref::AbstractArray{T,N}, marker
6666
end
6767
if @inbounds current_max != out[i]
6868
out[i] = min(ref[i], current_max)
69-
enqueue!(pq, i, out[i])
69+
push!(pq, i => out[i])
7070
end
7171
# else posponed to the end
7272
end
7373
end
7474
# Loop until all pixel have been examined
7575
while !isempty(pq)
76-
curr_idx, _ = dequeue_pair!(pq)
76+
curr_idx, _ = popfirst!(pq)
7777
for Δi in se # examine neighborhoods
7878
ii = curr_idx + Δi
7979
if checkbounds(Bool, R, ii) #check that we are in the image
@@ -159,14 +159,14 @@ function _high_leveling!(out::AbstractArray{T,N}, ref::AbstractArray{T,N}, marke
159159
end
160160
if @inbounds current_min != out[i]
161161
out[i] = max(ref[i], current_min)
162-
enqueue!(pq, i, out[i])
162+
push!(pq, i => out[i])
163163
end
164164
# else posponed to the end
165165
end
166166
end
167167
# Loop until all pixel have been examined
168168
while !isempty(pq)
169-
curr_idx, _ = dequeue_pair!(pq)
169+
curr_idx, _ = popfirst!(pq)
170170
for Δi in se # examine neighborhoods
171171
ii = curr_idx + Δi
172172
if checkbounds(Bool, R, ii) #check that we are in the image

src/ops/mreconstruct.jl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ end
8686
_prepare_reconstruct_ops(::op) where {op} = error("operation `$(op.instance)` is not supported for `mreconstruct`")
8787
_prepare_reconstruct_ops(::typeof(dilate)) = (max, min)
8888
_prepare_reconstruct_ops(::typeof(erode)) = (min, max)
89-
@inline _should_enqueue(::typeof(max)) = <
90-
@inline _should_enqueue(::typeof(min)) = >
89+
@inline _should_push(::typeof(max)) = <
90+
@inline _should_push(::typeof(min)) = >
9191

9292
# Single-CPU version, references are [1] and section 6.2 of [2]
9393
function _mreconstruct!((select_se, select_marker), out, marker, mask, se)
@@ -135,7 +135,7 @@ function _mreconstruct!((select_se, select_marker), out, marker, mask, se)
135135
@inbounds out[i] = select_marker(curr_val, mask[i])
136136
end
137137
# backward scan
138-
should_enqueue = _should_enqueue(select_se)
138+
should_push = _should_push(select_se)
139139
for i in reverse(R)
140140
@inbounds curr_val = out[i]
141141
for Δi in lower_se # examine neighborhoods
@@ -148,21 +148,21 @@ function _mreconstruct!((select_se, select_marker), out, marker, mask, se)
148148
for Δi in lower_se # examine neighborhoods
149149
ii = i + Δi
150150
if checkbounds(Bool, R, ii) #check that we are in the image
151-
@inbounds if should_enqueue(out[ii], out[i]) && should_enqueue(out[ii], mask[ii])
152-
enqueue!(queue, i)
151+
@inbounds if should_push(out[ii], out[i]) && should_push(out[ii], mask[ii])
152+
push!(queue, i)
153153
end
154154
end
155155
end
156156
end
157157
# Loop until all pixel have been examined
158158
while !isempty(queue)
159-
curr_idx = dequeue!(queue)
159+
curr_idx = popfirst!(queue)
160160
for Δi in se # examine neighborhoods
161161
ii = curr_idx + Δi
162162
if checkbounds(Bool, R, ii) #check that we are in the image
163-
@inbounds if should_enqueue(out[ii], out[curr_idx]) && mask[ii] != out[ii]
163+
@inbounds if should_push(out[ii], out[curr_idx]) && mask[ii] != out[ii]
164164
out[ii] = select_marker(out[curr_idx], mask[ii])
165-
enqueue!(queue, ii)
165+
push!(queue, ii)
166166
end
167167
end
168168
end

0 commit comments

Comments
 (0)