## MaxMinFilters.jl

Julia implementation of Daniel Lemire's Streaming Maximum-Minimum Filter
Author sairus7
Popularity
15 Stars
Updated Last
3 Months Ago
Started In
October 2019

# 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):

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

```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")```

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

#png("plot2.png")```