Fixed many bugs

This commit is contained in:
2018-02-27 10:49:05 +01:00
parent 9d4927a365
commit 1fb9461a5f
8 changed files with 67 additions and 68 deletions

View File

@@ -6,7 +6,7 @@
% Simple multipass, n/m approach, extended box filter
Digital filters are implemented by convolving the input signal with a filter kernel, i.e. the digital filter's impulse response.
Consequently, the filter kernel of a Gaussian filter is a Gaussian with finite support \cite{dspGuide1997}.
Assuming a finite-support Gaussian filter kernel of size $M$ and a input signal $x$, discrete convolution produces the smoothed output signal
Assuming a finite-support Gaussian filter kernel of size $M$ and an input signal $x$, discrete convolution produces the smoothed output signal
\begin{equation}
\label{eq:gausFilt}
(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{,}
@@ -18,15 +18,15 @@ While in both equations the constant factor of the Gaussian is removed of the in
This factor is necessary to ensure that the estimate is a valid density function, i.e. that it integrates to one.
Such a restriction is superfluous in the context of digital filters, so the normalization factor is omitted.
Computation of a digital filter using the a naive implementation of the discrete convolution algorithm yields $\landau{NM}$, where $N$ is again the input size given by the length of the input signal and $M$ is the size of the filter kernel.
Computation of a digital filter using the naive implementation of the discrete convolution algorithm yields $\landau{NM}$, where $N$ is again the input size given by the length of the input signal and $M$ is the size of the filter kernel.
In order to capture all significant values of the Gaussian function the kernel size $M$ must be adopted to the standard deviation of the Gaussian.
A faster $\landau{N}$ algorithm is given by the well-known approximation scheme based on iterated box filters.
While reducing the algorithmic complexity this approximation also reduces computational time significantly due to the simplistic computation scheme of the box filter.
Following that, a implementation of the iterated box filter is one of the fastest ways to obtain an approximative Gaussian filtered signal.
Following that, an implementation of the iterated box filter is one of the fastest ways to obtain an approximative Gaussian filtered signal.
% TODO mit einem geringen Fehler
% TODO und somit kann der mvg filter auch die BKDE approxen?
\subsection{Box Filter}
%\subsection{Box Filter}
The box filter is a simplistic filter defined as convolution of the input signal and the box (or rectangular) function.
A discrete box filter of radius $l\in \N_0$ is given as
\begin{equation}
@@ -50,8 +50,8 @@ Given by the central limit theorem of probability, repetitive convolution of a r
Likewise, filtering a signal with the box filter several times approximately converges to a Gaussian filter.
In practice three to five iterations are most likely enough to obtain a reasonable close Gaussian approximation \cite{kovesi2010fast}.
This allows rapid approximation of the Gaussian filter using box filter, which only requires a few addition and multiplication operations.
Opposed to the Gaussian filter where several evaluations of the exponential function are necessary.
This allows rapid approximation of the Gaussian filter using iterated box filter, which only requires a few addition and multiplication operations.
Opposed to the Gaussian filter, where several evaluations of the exponential function are necessary.
The most efficient way to compute a single output value of the box filter is:
\begin{equation}
\label{eq:recMovAvg}
@@ -79,7 +79,7 @@ The overall algorithm to efficiently compute \eqref{eq:boxFilt} is listed in Alg
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$.
In contrast, the box function \eqref{eq:boxFx} is parametrized by its width $L$.
Therefore, in order to approximate the Gaussian filter of a given $\sigma$ a corresponding value of $L$ must be found.
Therefore, in order to approximate the Gaussian filter of a given $\sigma$, a corresponding value of $L$ must be found.
Given $n$ iterations of box filters with identical sizes the ideal size $\Lideal$, as suggested by Wells~\cite{wells1986efficient}, is
\begin{equation}
\label{eq:boxidealwidth}
@@ -102,14 +102,14 @@ In order to reduce the rounding error Kovesi~\cite{kovesi2010fast} proposes to p
\end{align}
Given $L_1$ and $L_2$ the approximation is done by computing $m$ box filters of width $L_1$ followed by $(n-m)$ box filters of size $L_2$, where $0\le m\le n$.
As all other values are known $m$ can be computed with
As all other values are known, $m$ can be computed with
\begin{equation}
\label{eq:boxrepeatm}
m=\frac{12\sigma^2-nL_1^2-4nL_1-3n}{-4L_1-4} \quad \text{.}
\end{equation}
The approximated $\sigma$ as a function of the integer width has a staircase shaped graph.
By reducing the rounding error the step size of the function is reduced.
By reducing the rounding error, the step size of the function is reduced.
However, the overall shape will not change.
\etal{Gwosdek}~\cite{gwosdek2011theoretical} proposed an approach which allows to approximate any real-valued value of $\sigma$.
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.