ImageFiltering.jl
ImageFiltering.jl copied to clipboard
Add findall_window
Continued from #223
Closes #224
Codecov Report
Merging #225 (7179644) into master (02407fa) will decrease coverage by
1.31%. The diff coverage is0.00%.
@@ Coverage Diff @@
## master #225 +/- ##
==========================================
- Coverage 91.60% 90.29% -1.32%
==========================================
Files 11 12 +1
Lines 1513 1535 +22
==========================================
Hits 1386 1386
- Misses 127 149 +22
| Impacted Files | Coverage Δ | |
|---|---|---|
| src/ImageFiltering.jl | 77.27% <ø> (ø) |
|
| src/findall_window.jl | 0.00% <0.00%> (ø) |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact),ø = not affected,? = missing dataPowered by Codecov. Last update 02407fa...7179644. Read the comment docs.
I haven't checked it very carefully, but maybe this is related to the performance gap to findlocalmaxima
function sum_window_mean_ver1(X)
out = zero(float(eltype(X)))
R = CartesianIndices(X)
Δ = oneunit(eltype(R))
@inbounds @simd for p in R
window = max(p-Δ, first(R)):min(p+Δ, last(R))
out += mean(view(X, window))
end
return out
end
function sum_window_mean_ver2(X)
out = zero(float(eltype(X)))
R = CartesianIndices(X)
Δ = oneunit(eltype(R))
@inbounds @simd for p in R
window = max(p-Δ, first(R)):min(p+Δ, last(R))
mean_val = zero(eltype(out))
for q in window
mean_val += X[q]
end
out += mean_val/length(window)
end
return out
end
julia> @btime sum_window_mean_ver1($X);
164.748 μs (0 allocations: 0 bytes)
julia> @btime sum_window_mean_ver2($X)
64.137 μs (0 allocations: 0 bytes)
Did you try creating your own mean function in case it's something about the one in Statistics?