JuliaImages / JuliaImages/ImageFiltering.jl
optimized mean filter using IntegralArrays
Nobody has claimed this yet.
- Dominant language
- Julia
- Stars
- 104
- Forks
- 52
- PR merge metrics
- No merged PRs in 30d
Description
When one needs to compute the sum/average of all blocks extracted from an image, pre-building the integral array usually provides a more efficient computation.
using BenchmarkTools, IntegralArrays
# simplified 3x3 mean filter; only for demo purpose
function mean_filter_naive!(out, X)
Δ = CartesianIndex(1, 1)
for i in CartesianIndex(2, 2):CartesianIndex(size(X).-1)
block = @view X[i-Δ: i+Δ]
out[i] = mean(block)
end
return out
end
function mean_filter_integral!(out, X)
iX = IntegralArray(X)
for i in CartesianIndex(2, 2):CartesianIndex(size(X).-1)
x, y = i.I
out[i] = iX[x±1, y±1]/9
end
return out
end
X = Float32.(rand(1:5, 64, 64));
m1 = copy(X);
m2 = copy(X);
@btime mean_filter_naive!($m1, $X); # 65.078 μs (0 allocations: 0 bytes)
@btime mean_filter_integral!($m2, $X); # 12.161 μs (4 allocations: 16.17 KiB)
m1 == m2 # true
One needs to specialize the mapwindow on mean function, e.g.,
function mapwindow(::typeof(mean), img, ...)
...
end
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the existing mapwindow entry point and its handling of mean operations, then compare its behavior with the IntegralArray example in the issue. The work is done when mean windows use the specialized path while preserving the existing results and interface; no specific file or test is named.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- computer-vision, performance
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100