Skip to content

Commit 1957aa5

Browse files
authored
Use component_lengths to count labels (#33)
`component_lengths` is faster
1 parent f09fb69 commit 1957aa5

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/imfill.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ function imfill(img::AbstractArray{Bool}, interval::Tuple{Real,Real}, connectivi
2828

2929
labels = label_components(img,connectivity)
3030

31-
count_labels = Dict([(i,count(x->x==i,labels)) for i in unique(labels)])
31+
count_labels = component_lengths(labels)
3232

3333
new_img = similar(img)
3434
for ind in eachindex(img)
35-
if img[ind] == true && interval[1] <= count_labels[labels[ind]] <= interval[2]
35+
if img[ind] == true && interval[1] <= count_labels[labels[ind]+1] <= interval[2]
3636
new_img[ind] = false
3737
else
3838
new_img[ind] = img[ind]

0 commit comments

Comments
 (0)