Skip to content

Julia implementation of Daniel Lemire's Streaming Maximum-Minimum Filter

License

Notifications You must be signed in to change notification settings

sairus7/MaxMinFilters.jl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MaxMinFilters.jl

Julia implementation of Daniel Lemire's Streaming Maximum-Minimum Filter:

Daniel Lemire, Streaming Maximum-Minimum Filter Using No More than Three Comparisons per Element. Nordic Journal of Computing, 13 (4), pages 328-339, 2006. http://arxiv.org/abs/cs.DS/0610046

Implemented both as functions over a moving window, and stateful filter objects. Available filters: minimum, maximum, minimum+maximum, range, envelope

Installation

]add MaxMinFilters

Comparison with other packages

There are three other Julia packages with overlapping functionality for moving window maximum/minimum functions:

Compared to these packages, MaxMinFilters.jl provides significant speed-up, and its complexity does not depend on window length (benchmark available at examples/benchmark.jl):

plot

Also MaxMinFilters.jl provides stateful filter objects, allowing you to process a signal of indefinite length in RAM-friendly chunks, similar to DSP.jl.

Examples

examples/example.jl:

using Plots
using MaxMinFilters
using Random

Random.seed!(0)
len = 300
x = randn(len)
x[1] = 0;
for i = 1+1:len
    x[i] = -(0.5 + x[i-1]*0.8 + x[i]*0.2)
end

w = 5
mx, mn = movmaxmin(x, w)
xrange = movrange(x, w)

plot(x, label = "x")
plot!(mx, label = "mx")
plot!(mn, label = "mn")
plot!(xrange, label = "range")

#png("plot1.png")

plot1

envelope = movenvelope(x, w)
plot(x, label = "x")
plot!(envelope[w-1:end], label = "envelope")

#png("plot2.png")

plot2

About

Julia implementation of Daniel Lemire's Streaming Maximum-Minimum Filter

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages