Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add findall_window #225

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft

Add findall_window #225

wants to merge 1 commit into from

Conversation

timholy
Copy link
Member

@timholy timholy commented Sep 3, 2021

Continued from #223

Closes #224

@timholy timholy marked this pull request as draft September 3, 2021 09:34
@codecov
Copy link

codecov bot commented Sep 3, 2021

Codecov Report

Merging #225 (7179644) into master (02407fa) will decrease coverage by 1.31%.
The diff coverage is 0.00%.

Impacted file tree graph

@@            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 data
Powered by Codecov. Last update 02407fa...7179644. Read the comment docs.

@timholy timholy mentioned this pull request Sep 4, 2021
@johnnychen94
Copy link
Member

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)

@timholy
Copy link
Member Author

timholy commented Sep 13, 2021

Did you try creating your own mean function in case it's something about the one in Statistics?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

introduce a findall version of mapwindow
2 participants