Box & boxKDE algos + notation fixes

This commit is contained in:
2018-02-20 14:08:58 +01:00
parent e49c7a1cbf
commit 0bbc43e269
4 changed files with 78 additions and 39 deletions

View File

@@ -9,7 +9,7 @@ Consequently, the filter kernel of a Gaussian filter is a Gaussian with finite s
Assuming a finite-support Gaussian filter kernel of size $M$ and a input signal $x$, discrete convolution produces the smoothed output signal
\begin{equation}
\label{eq:gausFilt}
y[n] = \frac{1}{\sigma\sqrt{2\pi}} \sum_{k=0}^{M-1} x[k]\expp{-\frac{(n-k)^2}{2\sigma^2}} \text{,}
(G_{\sigma}*x)(i) = \frac{1}{\sigma\sqrt{2\pi}} \sum_{k=0}^{M-1} x(k) \expp{-\frac{(i-k)^2}{2\sigma^2}} \text{,}
\end{equation}
where $\sigma$ is a smoothing parameter called standard deviation.
@@ -31,14 +31,14 @@ The box filter is a simplistic filter defined as convolution of the input signal
A discrete box filter of \qq{radius} $l\in N_0$ is given as
\begin{equation}
\label{eq:boxFilt}
y[n] = \sum_{k=0}^{L-1} x[k] B_L(n-k)
(B_L*x)(i) = \sum_{k=0}^{L-1} x(k) B_L(i-k)
\end{equation}
where $L=2l+1$ is the width of the filter and
\begin{equation}
\label{eq:boxFx}
B_L(n)=
B_L(i)=
\begin{cases}
L^{-1} & \text{if } -l \le n \le l \\
L^{-1} & \text{if } -l \le i \le l \\
0 & \text{else }
\end{cases}
\end{equation}
@@ -55,11 +55,26 @@ Opposed to the Gaussian filter where several evaluations of the exponential func
The most efficient way to compute a single output value of the box filter is:
\begin{equation}
\label{eq:recMovAvg}
y[i] = y[i-1] + x[i+r] - x[i-r-1]
y(i) = y(i-1) + x(i+l) - x(i-l-1)
\end{equation}
This recursive calculation scheme further reduces the time complexity of the box filter to $\landau{N}$, by reusing already calculated values.
Furthermore, only one addition and subtraction is required to calculate a single output value.
The overall algorithm to efficiently compute \eqref{eq:boxFilt} is listed in Algorithm~\ref{alg:naiveboxalgo}.
\begin{algorithm}[ht]
\caption{Recursive 1D box filter}
\label{alg:naiveboxalgo}
\begin{algorithmic}[1]
\Statex \textbf{Input:} $f$ defined on $[1,N]$ and box radius $l$
\Statex \textbf{Output:} $u \gets B_L*f$
\State $a := \sum_{i=-l}^{l} f(i) $
\State $u(1) := a/(2l+1)$
\For{$i=2 \textbf{ to } N$}
\State $a:= a + f(i+l) - f(i-l-1) $ \Comment{\eqref{eq:recMovAvg}}
\State $u(i) := a/(2l+1)$
\EndFor
\end{algorithmic}
\end{algorithm}
Given a fast approximation scheme, it is necessary to construct a box filter analogous to a given Gaussian filter.
As seen in \eqref{eq:gausFilt}, the solely parameter of the Gaussian kernel is the standard deviation $\sigma$.
@@ -100,6 +115,7 @@ However, the overall shape will not change.
Just like the conventional box filter, the extended version has a uniform value in the range $[-l; l]$, but unlike the conventional the extended box filter has different values at its edges.
This extension introduces only marginal computational overhead over conventional box filtering.
\commentByToni{Warum benutzen wir den extended box filter nicht? oder tun wir das? Liest sich so, als wäre er der heilige Gral.
Ansonsten: Kapitel find ich gut. Vielleicht kann man hier und da noch paar sätze fusionieren um etwas Platz zu sparen.}