Browse Source

Adds stub for the second report. Adds some auxilary files.

master
Joshua Moerman 11 years ago
parent
commit
ee13222e43
  1. BIN
      wavelet_report/costs.gcx
  2. BIN
      wavelet_report/optimize_costs.gcx
  3. BIN
      wavelet_report/optimize_costs2.gcx
  4. 52
      wavelet_report/report.tex
  5. 6
      wavelet_scripts/convert.sh
  6. 5
      wavelet_scripts/some_scripts.sh

BIN
wavelet_report/costs.gcx

Binary file not shown.

BIN
wavelet_report/optimize_costs.gcx

Binary file not shown.

BIN
wavelet_report/optimize_costs2.gcx

Binary file not shown.

52
wavelet_report/report.tex

@ -0,0 +1,52 @@
\begin{abstract}
In this paper we will derive a parallel algorithm to perform a Daubechies wavelet transform of order four (DAU4). To conceptualize this transform we will first look into the Fourier transform to motivate first of all why we want such a transform and secondly to point out one of the shortcomings of the Fourier transform. After this introduction we will derive mathematical properties of the Daubechies wavelet transform, this mathematical description will also give us a naive sequential algorithm. By looking at which data is needed by which processor, we can give a parallel algorithm. As an application we will look into image compression using this wavelet transform.
\end{abstract}
\section{Introduction}
\label{sec:intro}
In this section we will motivate the need for wavelets. We will start with the well known Fourier transform and discuss things we can change. As an example we will be using a 1-dimensional signal of length $128$. This section will be a bit informal and will not focus on algorithms.
\subsection{Recalling the Fourier transform}
Recall the Fourier transform; given an input signal $x = \Sum_{i=1}^{128} x_i e_i$ (written on the standard basis) we can compute Fourier coefficients $x'_i$ such that $x = \Sum_{i=1}^{128} x'_i f_i$. As we're not interested in the mathematics behind this transform, we will not specify $f_i$. Conceptually the Fourier transform is a basis transformation:
$$ SampleDomain \to FourierDomain. $$
Furthermore this transformation has an inverse. Applications of this transform consist of going to the Fourier domain, applying some (easy to compute) function there and go back to sample domain again.
In figure~\ref{fig:fourier_concepts} we've written an input signal of length $128$ on the standard basis, and on the Fourier basis (simplified, for illustrational purposes). We see that this signal is better expressed in the Fourier domain, as we only need three coefficients instead of all $128$.
% fig:fourier_concepts
% spelling out a sum of basis elements in both domains
We see that we might even do compression based on the Fourier coefficients. Instead of sending all samples, we just only a few coefficients from which we are able to approximate the original input. However there is a shortcoming to this. Consider the following scenario. A sensor on Mars detects a signal, transforms it and sends the coefficients to earth. During the transmission one of the coefficients is corrupted. This results in a wave across the whole signal. The error is \emph{non-local}. If, however, we decided to send the original samples, a corrupted sample would only affect a small part of the signal, i.e. the error is \emph{local}. This is illustrated in figure~\ref{fig:fourier_error}.
% fig:fourier_error
% add 0.5 * e_10 and 0.5 * f_10 to both signals
\subsection{The simplest wavelet transform}
At the heart of the Fourier transform is the choice of the basis elements $f_i$. With a bit of creativity we can cook up different basis elements with different properties. To illustrate this we will have a quick look at the so-called ``Haar wavelets''. In our case where $n=128$ we can define the following $128$ elements:
$$ h_0 = \Sum_{i=1}^{128} e_i,
h_1 = \Sum_{i=1}^{64} e_i - \Sum_{i=65}^{128} e_i,
h_2 = \Sum_{i=1}^{32} e_i - \Sum_{i=33}^{64} e_i,
h_2 = \Sum_{i=65}^{96} e_i - \Sum_{i=97}^{128} e_i, \ldots,
h_{2^n + j} = \Sum_{i=2^{6-n}j+1}^{2^{6-n}(j+1)} e_i - \Sum_{i=2^{6-n}(j+1)+1}^{2^{6-n}(j+2)} e_i (j < 2^n) $$
We will refer to these elements as \emph{Haar wavelets}. To give a better feeling of these wavelets, they are plotted in figure~\ref{fig:haar_waveleta} on the standard basis. There is also an effective way to write an element written in the standard basis on this new basis, this is the Haar wavelet transform. Again our example can be written on this new basis, and again we see that the first coefficient already approximates the signal and that the other coefficients refine it.
To go back to our problem of noise, if we add $0.5*h_9$ (there is a shift of indices) to this signal, only a small part of the signal is disturbed as shown in figure~\ref{fig:haar_error}.
Another important difference is the way these basis elements can represent signals. With the Fourier basis elements we can easily approximate smooth signals, but with the Haar basis elements this is much harder. However representing a piecewise constant signal is easier with the Haar wavelets. In photography the latter is preferred, as edges are very common (think of branches of a tree against a clear sky or hard edges of a building). So depending on the application this \emph{non-smoothness} is either good or bad.
\section{Daubechies wavelets}
\label{sec:dau}
We now have seen three different bases to represent signals: in the sample domain, in the Fourier domain and in the Haar wavelets domain. The all have different properties. We have reasoned that the Haar wavelets have nice properties regarding images; it is able to represent edges well and errors are local. However a little bit of smoothness is sometimes asked for (again in photography, think of a blue sky: it's white/blue on the bottom, darker on the top). This is exactly what the Daubechies wavelets of order four add.
Instead of explicitly defining or showing the basis elements, we will directly describe the wavelet transform.\footnote{Note that we didn't describe the transforms described in section~\ref{sec:intro}, as this section was motivational only.} In fact we will describe it as an algorithm, as our intent is to implement it.
\subsection{The Daubechies wavelet transform}

6
wavelet_scripts/convert.sh

@ -0,0 +1,6 @@
#!/bin/bash
input="$1"
output=`basename "$1"`
output="images/${output%.*}.png"
convert "$input" -sigmoidal-contrast 3,50% -resize 1024x1024^ -gravity center -extent 1024x1024 -colorspace Gray "$output"

5
wavelet_scripts/some_scripts.sh

@ -0,0 +1,5 @@
(for i in $(seq 5 26); do echo -e "#define NEXP $i\n" > ../wavelet/defines.hpp && make -B -j4 mockup && echo $i && ./wavelet/mockup || break; done) | grep "parallel\|sequential"
(for i in $(seq 5 26); do echo -e "#define NEXP $i\n" > ../wavelet/defines.hpp && make -B -j4 mockup && echo $i && mpirun -np 4 ./wavelet/mockup || break; done) | grep "parallel\|sequential"
for i in $(seq 1 21); do echo 2 | ./bench | grep "r="; done
for i in $(seq 1 21); do echo 4 | mpirun -np 4 ./bench | grep "r="; done