using Julia version 1.3.0-rc3 and ImageSegmentation v1.2.0 on Ubuntu 18.04.3 LTS.
Error message:
ArgumentError: PriorityQueue keys must be unique
Stacktrace:
[1] enqueue!(::DataStructures.PriorityQueue{DataStructures.Queue{CartesianIndex{2}},Float64,Base.Order.ForwardOrdering}, ::Pair{DataStructures.Queue{CartesianIndex{2}},Float64}) at /home/miriam/.julia/packages/DataStructures/RbN5c/src/priorityqueue.jl:236
[2] enqueue! at /home/miriam/.julia/packages/DataStructures/RbN5c/src/priorityqueue.jl:251 [inlined]
[3] seeded_region_growing(::Array{Gray{Normed{UInt8,8}},2}, ::Array{Tuple{CartesianIndex{2},Int64},1}, ::ImageSegmentation.var"#18#22"{CartesianIndex{2}}, ::typeof(ImageSegmentation.default_diff_fn)) at /home/miriam/.julia/packages/ImageSegmentation/KDHwp/src/region_growing.jl:142
[4] seeded_region_growing(::Array{Gray{Normed{UInt8,8}},2}, ::Array{Tuple{CartesianIndex{2},Int64},1}, ::Tuple{Int64,Int64}, ::Function) at /home/miriam/.julia/packages/ImageSegmentation/KDHwp/src/region_growing.jl:64
[5] seeded_region_growing at /home/miriam/.julia/packages/ImageSegmentation/KDHwp/src/region_growing.jl:57 [inlined] (repeats 2 times)
Analysis:
It can happen that nhq is exactly the same for several iterations. If the region means get updated in between the iterations, then in line 142 of region_growing.jl the same queue is tried to be enqueued into the priority queue again, which is not allowed.
Solution: use pq[q]=\delta instead of enqueue!(pq,q,\delta)
The priority queue allows for efficient updates of priorities for elements in the queue by using pq[q]=\delta instead of enqueue!(pq,q,\delta). This also renders checking the dictionary qdict redundant. With this functionality it also makes more sense to insert the pixels itself rather than queues of pixels into the priority queue. The priority queue becomes shorter this way and one avoids looping through a lot of already processed / labelled pixels again. Parallel processing of pixels with the same priority can still be achieved by looping through the priority queue until the lowest priority changes.
...when the function is called for
using Julia version 1.3.0-rc3 and ImageSegmentation v1.2.0 on Ubuntu 18.04.3 LTS.
Error message:
Analysis: It can happen that
nhq
is exactly the same for several iterations. If the region means get updated in between the iterations, then in line 142 of region_growing.jl the same queue is tried to be enqueued into the priority queue again, which is not allowed.Solution: use
pq[q]=\delta
instead ofenqueue!(pq,q,\delta)
The priority queue allows for efficient updates of priorities for elements in the queue by usingpq[q]=\delta
instead ofenqueue!(pq,q,\delta)
. This also renders checking the dictionaryqdict
redundant. With this functionality it also makes more sense to insert the pixels itself rather than queues of pixels into the priority queue. The priority queue becomes shorter this way and one avoids looping through a lot of already processed / labelled pixels again. Parallel processing of pixels with the same priority can still be achieved by looping through the priority queue until the lowest priority changes.Pull request to resolve the issue is forthcoming.