-
Notifications
You must be signed in to change notification settings - Fork 22
Open
Description
I exported a strel from matlab using strel
>> se = strel('disk', 50)
se =
strel is a disk shaped structuring element with properties:
Neighborhood: [99×99 logical]
Dimensionality: 2I import this strel (kind of tricky to build from scratch) into Julia and do the recommended conversions
(temp) pkg> st
Status `\temp\Project.toml`
[787d08f9] ImageMorphology v0.4.4
julia> using ImageMorphology
julia> se_mask = centered(make_disk50_se());
julia> se_offsets = strel(CartesianIndex, se_mask);
julia> se
99×99 OffsetArray(::BitMatrix, -49:49, -49:49) with eltype Bool with indices -49:49×-49:49:
(rest of output suppressed)Then I do the benchmarking with a very simple image
>> bw = zeros(500, 500);
>> bw(125:250, 125:250) = 1;
>> f = @() imdilate(bw, se);
>> timeit(f)
ans =
0.0268
>> timeit(f)
ans =
0.0259
>> julia> bw = zeros(Bool, 500, 500);
julia> bw[125:250, 125:250] .= true;
julia> @time ImageMorphology.dilate(bw, se);
1.713545 seconds (31 allocations: 736.844 KiB)
julia> @time ImageMorphology.dilate(bw, se);
1.731762 seconds (31 allocations: 736.844 KiB)In my use case with a much larger and much more complex image Matlab does this work in about 0.11 seconds, while Julia takes close to 300 seconds 😕.
Metadata
Metadata
Assignees
Labels
No labels