]> git.rustad.me Git - master/commitdiff
Gettin closer
authorBjørn Rustad <bjorn@rustad.me>
Fri, 6 Feb 2015 19:37:10 +0000 (20:37 +0100)
committerBjørn Rustad <bjorn@rustad.me>
Fri, 6 Feb 2015 19:37:10 +0000 (20:37 +0100)
appendix.tex
conclusion.tex
continuous.tex
discrete.tex
introduction.tex
main.tex
maxflow.tex
methods.tex
results.tex

index a47b6df937a2f335489004b7814be8e6584e74f1..c4491817a9a3d71cd7e741d96a859cb6d305e3bc 100644 (file)
@@ -1,46 +1,4 @@
 \chapter{\cpp{} implementation}
 
-\fixme{well, code is at daim also, mention that?}
-
-My \cpp{} implementation can be found online at \cite{github}. It uses
-the open computer vision library OpenCV \cite{opencv_library} to load
-and save image files. The implementation has been tested on a Ubuntu
-Linux distribution, but it should in theory be portable to other
-platforms supported by OpenCV. A rudimentary graphics interface has also
-been made, shown in Figure~\ref{fig:fiddle}, to make it easier to play
-with the parameters of the algorithm.
-
-Both the push-relabel and the Boykov--Kolmogorov algorithms have been
-implemented. Although an effort has been made to improve the performance
-of both implementations, they are not ment to beat the fastest. The
-focus has rather been on clarity.
-
-Note that when implementing maximum flow algorithms it is not a good
-idea, memory- and performance-wise, to actually construct the residual
-graph $G_f$. Instead, every time we update the flow $f(u,v)$ we set
-the flow in the opposite direction to its negative value $f(v,u) =
--f(u,v)$. Then we can at any time, consider the value $c(u,v) - f(u,v)$
-in the place of the residual capacity $c_f(u,v)$.
-
-For the gap relabeling heuristic of the push-relabel algorithm, we need
-to have a easy way of finding when a gap occurs. This is done by keeping
-track of how many vertices exist with each label.
-
-When the capacities have been updated in the Boykov--Kolmogorov
-algorithm, flow is sent along all two-edge paths such that they do not
-have to be considered by the main loop of the algorithm.
-
-\begin{figure}
-    \centering
-    \includegraphics[width=\textwidth]{fig/fiddle.png}
-    \caption[Graphical user interface]{Simple graphical user interface to play with the algorithm
-    parameters.}
-    \label{fig:fiddle}
-\end{figure}
-
-%\section{Performance comparison}
-
-%Maybe.
-
-%\inputminted[fontsize=\scriptsize]{c++}{../image-restoration/graph.cpp}
+\fixme{THIS SHOULD NOT BE INCLUDED ANYMORE!}
 
index 15ad84529f77ee850f4c785b7fe6f13af4642b6f..e44790e8454e086715093551c55326ecca2c579c 100644 (file)
@@ -5,42 +5,37 @@ In this thesis we have seen how the total variation restoration method
 can be extended using an anisotropy tensor, and how this fits into the
 discretization and graph cut framework used in my project work
 \cite{project}. The anisotropy tensor was introduced in hopes of
-reducing the amount of regularization applied across edges in the image. It was
-constructed based on the structure tensor which contains information
-about edge direction and steepness, and three parameters were exposed
-for controlling the anisotropy.
+reducing the amount of regularization applied across edges in the image,
+and by that prevent contrast loss. It was
+constructed based on the structure tensor which contains local information
+about edge direction and steepness.
 
-The continuous functional we initially wanted to minimize was then
-transformed using an anisotropic coarea formula and an anisotropic
-Cauchy--Crofton formula, both described in detail. The functional was
-discretized, and the discretization was shown---under some
-restrictions---to be consistent with the continuous functional.
+In order to arrive at a discrete functional that could be minimized
+using the same graph cut framework as in my project work~\cite{project},
+we transformed the continuous functional using an anisotropic coarea
+and Cauchy--Crofton formula, both described in detail. The resulting
+discrete functional was shown---under some restrictions---to be
+consistent with the continuous functional.
 
-As in my project work~\cite{project} the discrete functional was
-minimized using maximum flow algorithms to obtain successive minimum
-graph cuts. A description of the push-relabel algorithm was given as it
-is known to have
-good performance for general graphs. Further the
-Boykov--Kolmogorov algorithm was described, as it is tailored for the
-kinds of graphs appearing in imaging applications.
+The successive graph cuts, each giving a minimizer for a functional of
+a level in the image, were found using maximum flow algorithms.
+The push-relabel algorithm is know to have good all-round performance,
+while the Boykov--Kolmgorov algorithm is tailored for the kinds of
+graphs appearing in imaging applications. They were both described and
+implemented.
 
-Effort was put into giving a complete overview of the method, describing
-each part needed to go from the initial continuous problem, to the
-discrete solution. This way, readers can get an understanding of the
-inner workings of the method, and also easily be able to implement it.
+A goal was to give readers a good understanding of the inner workings
+of the method, as well as everything necessary for a working
+implementation. Thus we put effort into describing all steps, from the
+initial continuous formulation, to the discretization, and the maximum
+flow algorithms in the end.
 
-Further work is possible in the study of the continuous problem, its
-well-foundedness, and also the anisotropic coarea and Cauchy--Crofton
-formulas, which can be studied on a measure-theoretic foundation. The
-construction of the tensor offers choices that can be explored further.
-
-Regarding the discretization, the choice of neighborhood stencil also
-allows for further discussion, as approximation error can be traded for
-algorithm performance. Opening for non-uniform stencils, where the
-stencil choice depends on the level of detail in the neighborhood is
-a possibility.
+%Effort was put into giving a complete overview of the method, describing
+%each part needed to go from the initial continuous problem, to the
+%discrete solution. This way, readers can get an understanding of the
+%inner workings of the method, and also easily be able to implement it.
 
-In the end we looked at how the different parameters affect the
+One part of the thesis consists of studies of how the different parameters affect the
 performance of the algorithm. We will not give any unified conclusion as
 to whether this method is ``better'' or ``worse'' than the regular total
 variation method it is based on, or other methods. In different
@@ -49,6 +44,19 @@ also have different hopes for, and restrictions on the output image. But
 we have seen how the anisotropy tensor affects the restoration, and that
 it can have positive effects on contrast loss as well as method noise.
 
+Further work is possible in the study of the continuous problem, its
+well-foundedness, and also the anisotropic coarea and Cauchy--Crofton
+formulas, which can be studied on a measure-theoretic foundation. Also,
+the construction of the tensor offers choices that can be explored
+further.
+
+Regarding the discretization, the choice of neighborhood stencil also
+allows for further discussion, as approximation error can be traded for
+algorithm performance. One particular possibility would be the
+application of non-uniform stencils with varying stencil size depending
+on the local level of detail. This could give better performance without
+sacrificing too much in solution accuracy.
+
 %Because we have spread our attention across all parts of the restoration
 %method, it is also possible to go deeper into the theory behind all of
 %them. The well-foundedness of the continuous formulation and the
index 8d2f39057c5b9289a565454d5d52e183b526443a..820f73836e55ff4afc087ececb5e3b9306ba4921 100644 (file)
@@ -20,8 +20,6 @@ leads up to the discretization of our functional in the next chapter.
 
 \section{Anisotropic total variation}
 
-\fixme{Rating: 8/10}
-
 The method considered will build on the total variation regularization
 method of Section~\ref{sec:total_variation}. From anisotropic diffusion
 in Section~\ref{sec:anisotropic_diffusion} we borrow the idea of making
@@ -72,9 +70,13 @@ where $\xi$ and $\eta = \Ahalf \xi$ are in $C_c^\infty(\Omega,
 In the following we define the norms $\lnorm{\xi}_A = \sup_x (\xi^T A
 \xi)^{\sfrac{1}{2}}$ and
 $\lnorm{\eta}_A^* = \sup_x (\eta^T A^{-1} \eta)^{\sfrac{1}{2}}$, and with that we
+\nomenclature{$\lnorm{\xi}_A$}{The norm $\sup_x (\xi^T A
+\xi)^{\sfrac{1}{2}}$}%
+\nomenclature{$\lnorm{\eta}_A^*$}{The norm $\sup_x (\eta^T A^{-1}
+\eta)^{\sfrac{1}{2}}$.}%
 present the formal definition of the anisotropic total variation.
 \begin{definition}[Anisotropic total variation]
-    For a function $u \in BV(\Omega)$ and a continuous symmetric
+    For a function $u \in L^2(\Omega)$ and a continuous symmetric
     positive definite tensor $A : \Omega \to \mathbb{R}^{2 \times 2}$ we
     define the anisotropic total variation
     \begin{equation}
@@ -85,8 +87,8 @@ present the formal definition of the anisotropic total variation.
     \end{equation}
     \label{def:extended_tv}
 \end{definition}
-\nomenclature{$\TVA(u)$}{Anisotropic total variation of image $u$, with
-anisotropy tensor $A(u)$.}%
+\nomenclature{$\TVA(u)$}{Anisotropic total variation of image $u$ given
+the anisotropy tensor $A$.}%
 
 With this extended definition, we have arrived at a minimization problem
 where we seek to find a minimizer of the functional
@@ -103,8 +105,6 @@ affects our numerical solution method.
 \subsection{Anisotropy tensor}
 \label{sec:anisotropy_tensor}
 
-\fixme{Rating: 6/10}
-
 There are many possible choices for the anisotropy tensor $A(x)$. Our
 constraints are that we have assumed it to be continuous and symmetric
 positive definite, and we have some wishes for its properties. We would
@@ -227,6 +227,7 @@ and for $\sigma_1$ and $\sigma_2$ we choose
     \end{aligned}
     \label{eq:sigma_construction}
 \end{equation}
+\nomenclature{$\omega$}{Anisotropy parameter.}
 Thus the eigenvectors of $A(x)$ and $S_\rho(x)$ are equal, while the
 eigenvalues are different. A visualization of the two tensors can be
 seen in Figure~\ref{fig:tensor_viz} where the two tensors are shown at
@@ -271,8 +272,6 @@ fingerprint analysis.
 
 \section{Well-posedness}
 
-\fixme{Rating: 7/10}
-
 The theory of existence and uniqueness for these kinds of variational
 methods is a minefield of more or less subtle problems. Even if we
 restrict ourselves to a nice space such as $L^2(\Omega)$ we will at some
@@ -536,11 +535,6 @@ can conclude that we have existence from \cite[Theorem
 
 \section{Anisotropic coarea formula}
 
-\fixme{Rating: 6.5/10, especially the part after the proof needs some
-work.}
-
-\fixme{More flow between the sections. Somehow.}
-
 The anisotropic coarea formula we will present here allows us to write
 the anisotropic total variation as an integral over the levels of the
 image. For a similar presentation of the regular coarea formula for all
@@ -781,7 +775,7 @@ the following definition of the anisotropic set perimeter.
         \PerA(U;\Omega) = \TVA(\idfun_U).
     \end{equation}
 \end{definition}
-\nomenclature{$\PerA(u;\Omega)$}{Anisotropic perimeter of set $U$ using
+\nomenclature{$\PerA(U;\Omega)$}{Anisotropic perimeter of set $U$ using
 anisotropy tensor $A$.}%
 The anisotropic set perimeter is not like the regular set perimeter and
 does not measure the length of the boundary of the set, but it can for
@@ -825,9 +819,6 @@ perimeter will be computed using a graph cut machinery.
 
 \section{Cauchy--Crofton formulas}
 
-\fixme{Rating: 7/10, the stuff after the proof could use some
-work.}
-
 \begin{figure}
     \input{fig/line_param}
 \end{figure}
index 4704c513db2091bd87984fe05ee050e1ca1ced96..a63c617bc39ad3b7ac7af3f9da01fd709c30a9be 100644 (file)
@@ -10,8 +10,6 @@ a global minimizer in polynomial time.
 
 \section{Discretization}
 
-\fixme{Rating: 4/10}
-
 Assume that our discrete images are given on a uniform grid $\mathcal{G}$,
 where each grid point is called a pixel. The image is a function giving
 each pixel a value in the set of levels $\mathcal{P} = \{0, \hdots,
@@ -30,8 +28,6 @@ functional.
 
 \subsection{Fidelity term}
 
-\fixme{Rating: 7/10}
-
 Since it is not affected by our introduction of the anisotropy tensor,
 the fidelity term can be discretized as in my project work
 \cite{project}. For some pixel position $x \in \mathcal{G}$ and some
@@ -40,6 +36,7 @@ level value $k \in
 \begin{equation}
     N_x(k) = \abs{k - f_x}^2
 \end{equation}
+\nomenclature{$N_x(k)$}{Helper function $N_x(k) = \abs{k-f_x}^2$.}%
 which is the value of the fidelity term if we were to give $u_x$ a value
 of $k$. This allows us write
 \begin{equation}
@@ -77,8 +74,6 @@ thresholded image $u^{L-1}$ is equal to zero everywhere.
 \subsection{Regularization term}
 \label{sec:disc_regularization}
 
-\fixme{Rating: 6/10}
-
 Discretizing the regularization term is more challenging. We introduce
 the discrete levels to get
 \begin{equation}
@@ -150,6 +145,7 @@ discretization $\mathcal{L}_D$, then $a \in \mathcal{N}(b)$. Extending the edges
 Figure~\ref{fig:line_neigh} gives all lines going through the point considered.
 Figure~\ref{fig:line_family} shows all lines of a given family, i.e.\
 lines having the same angle parameter $\phi$.
+\nomenclature{$\mathcal{N}(x)$}{Neighborhood of pixel $x$.}%
 
 Thus not only have we discretized the set of lines, but each line is
 made up of edges going from one grid point to the next. We will
@@ -308,8 +304,6 @@ this requirement.}
 
 \subsubsection{Consistency}
 
-\fixme{Rating: 6/10}
-
 Consistency relates to whether a solution to the continuous problem
 fits in the discretized equation, in other words, whether the
 discretized equation approximates the continuous one.
@@ -462,8 +456,6 @@ $F^\lambda$. The description is taken with some small adjustments from my projec
 
 \subsection{Graphs}
 
-\fixme{Maybe just call them graphs this time? from $E$ to $F$!}
-
 Using the notation of \cite{cormen2009introduction} we will denote a
 directed graph as $G = (V, E)$ where $V$ is a finite set of vertices, and
 $E$ is a binary relation on $V$. If $(u, v) \in E$ we say that there is
@@ -478,6 +470,9 @@ allow self-loops in our graph. When a directed graph $G$ is equipped
 with capacity function $c$, one might call it a capacitated graph or a
 flow network, but as all our graphs will be capacitated from this point,
 we will just call them graphs and we write $G = (V, E, c)$.
+\nomenclature{$G = (V,E,c)$}{A graph given by the set of vertices $V$,
+the set of edges $E$, and the capacity function $c$.}%
+\nomenclature{$c(u,v)$}{The capacity function $c : V \times V \to \left[0, \infty \right)$.}%
 
 There are two special vertices in the graph, the source $s$ and the
 sink $t$. Contrary to other vertices, which can neither produce nor
@@ -485,6 +480,8 @@ receive excess flow, the source can produce and the sink can receive an
 unlimited amount of flow. The most basic problem in graph flow theory
 is the question of how much flow it is possible to send through the
 graph from the source to the sink.
+\nomenclature{$s$}{The source vertex.}%
+\nomenclature{$t$}{The sink vertex.}%
 
 What we seek in our final graph is a minimum $s$-$t$-cut, a ``minimal''
 line through the graph that cuts a set of edges and
index 2832ebc90d1ba1fae92b3fd029049d57e86eac1d..994e92598b0898a7dc253c7db8d3895604a227b8 100644 (file)
@@ -4,68 +4,69 @@ Image processing is becoming an increasingly important part of our
 modern computerized world. Tasks previously only performed by humans,
 like detecting edges, recognizing textures and inferring shapes and
 motions can now be performed algorithmically. The background of these
-methods span several fields, including psychology and biology for the
+methods spans several fields, including psychology and biology for the
 study of human vision, statistics and analysis for the mathematical
 background, and computer science for their implementation and
 performance analysis.
 
-Image restoration methods are concerned with trying to remove noise in
-images. This noise can result from the physical nature of light
+Image restoration methods are concerned with trying to remove noise or
+recover otherwise degraded images.
+Possible noise can result from the physical nature of light
 traveling to your sensor, dust on your lens, and many other sources.
 Therefore
 numerous different approaches to denoising exist, each having their own
-strengths and weaknesses. Before going into
-detail on the main focus of this thesis---the anisotropic total
-variation method---we will look into some other popular methods in
-Chapter~\ref{chap:methods}.
+strengths and weaknesses. Some of these are introduced in
+Chapter~\ref{chap:methods}, all having the weakness that edges in the
+original are smoothed over.
 
-In my project work \cite{project}, I described a total variation based
-image restoration method, using a graph cut framework for the numerical
-solution. The method consisted of trying to reduce the total variation,
-while still
-staying ``close'' to the original
-image. The main strength of the total variation
-method is
-its ability to recover edges, as the total variation does not favor smooth gradients
-over edges like many other methods. However, the method may introduce edges from
-noise, and it may also reduce the contrast of the image.
+A method well known for recovering edges is the total variation
+method, as the total variation does not favor smooth gradients over
+edges. In my project work~\cite{project}, I described how a graph cut
+framework can be used to obtain a numerical
+solution in a total variation based
+image restoration method.
+The method consisted of trying to reduce the total variation of the
+image, while still staying ``close'' to the original.
 
-In this thesis we extend the total variation method by introducing an anisotropy
+A problem with the total varation method is that
+contrast is often lost, especially in fine
+details and thin structures. In this thesis we try to alleviate this.
+We extend the method by introducing an anisotropy
 tensor into the total variation, thus making it directionally dependent.
 This means we can control the regularization
 applied to the image based on position and direction. The main idea is then to reduce
 the regularization across edges in the image. Information about the
 edges are extracted using the structure tensor.
-The continuous problem is then transformed through an
-anisotropic coarea formula and an anisotropic Cauchy--Crofton formula to
-facilitate the discretization. The description of the continuous
-functional and its transformation can be found in
-Chapter~\ref{chap:continuous}.
 
-The integrals of the continuous formulation are discretized into sums in
-Chapter~\ref{chap:discrete},
-and we make sure that the discrete formulation is consistent with the
-continuous one.
-A provable optimal solution to the discrete problem is then found using
-a graph cut algorithm. For each level in the image, a graph is
-constructed, and a minimum cut is found. The restored image can then
-be extracted from all these partial solutions.
+This continuous problem is a convex minimization problem, and many
+optimization approaches exist. However, we choose to discretize in such
+a way that we can apply the same graph cut framework used in my project
+work~\cite{project}. Through the coarea formula, the functional is
+decomposed into a sequence of minimization problems, one for each level of the image.
+These separate level problems are then transformed and discretized
+further using an anisotropic Cauchy--Crofton formula that we develop.
+Similar formulas have been presented before in other contexts.
 
-For finding the minimum cuts, two algorithms are presented. The
-push-relabel algorithm is considered to be the fastest and most
-versatile for general graphs, while the Boykov--Kolmogorov algorithm is
-specially tailored for the type of graphs we find in these kinds of
-imaging applications. These are presented in Chapter~\ref{chap:maxflow}.
+A nice property of this numerical approach is that we can prove that the
+graph cut framework finds an exact global minimizer of the discrete
+functional. Additionally we verify that the discrete functional is
+consistent with the continuous one.
 
-In the end we inspect restoration results to see how the method
-performs. The construction of the tensor exposes three parameters, two
-controlling the scale of the structures it should be sensitive to, and
-one controlling the amount of anisotropy. We experiment with these
-parameters to show that they do what we expect them to do. The method is
-also compared with regular the total variation method to see that some
-improvements are achieved. We also explore and look at the different
-artifacts caused by approximations in the discretization, and how they
-affect the restoration.
+We present and implement two maximum flow algorithms that allow us
+to find minimum cuts corresponding to minimizers of the discrete
+functionals. The push-relabel algorithm is considered to be the fastest
+and most versatile for general graphs, while the Boykov--Kolmogorov
+algorithm is specially tailored for the type of graphs we find in these
+kinds of imaging applications.
+
+In the end we present numerical results that show how the
+different parameters affect the restoration, and we look into and explain some
+artifacts caused by approximations in the discretization. Further we look at how the
+introduction of the anisotropy in some cases amend some of the
+weaknesses of the total variation method.
+
+%artifacts caused by approximations in the discretization, and how they
+%affect the restoration.
 
 %In everyday life cameras are used to capture a moment and save it for
 %eternity, but imaging technology technology can be used in many other
index 003dec5a482370ddea28ae3b5fd91d9f03187098..7d473b17bfe586b946845669699f07e2467391ec 100644 (file)
--- a/main.tex
+++ b/main.tex
@@ -69,7 +69,7 @@
 %\usepackage[subrefformat=parens,labelformat=parens]{subcaption}
 \usepackage{subcaption}
 \usepackage{xfrac}
-\usepackage{nomencl}
+\usepackage[refpage]{nomencl}
 
 \usepackage{algorithm}
 \usepackage{algpseudocode}
@@ -99,9 +99,9 @@
 \pagenumbering{roman}
 
 % Inkluder forsida:
-\input{titlepage}
-
-\cleardoublepage
+%\input{titlepage}
+%
+%\cleardoublepage
 
 %\abstract{%
 %    BLEEP BLOOP.
 %There are numerous methods for image denoising and restoration.
 In this
 thesis we consider a particular kind of edge-enhancing image restoration method based on
-total variation. A directional dependence is introduced to the total
-variation method through an
+total variation. We want to address the fact that the total variation
+method in
+some cases leads to contrast loss in thin structures, and so
+a directional dependence is introduced
+through an
 anisotropy tensor. The tensor controls the regularization applied based on
 position and direction, and is
-constructed using edge information extracted from the noisy image.
-Through a coarea formula and a
-Cauchy--Crofton style formula the continuous problem is transformed to
-obtain a discretizable minimization problem. A solution is found by constructing
-graphs where the minimum cuts correspond to minimizers of the discrete
-functional. Parameters exposed allows us to control the amount of
-regularization applied across edges, and experiments are presented
-to show how the anisotropy and its parameters affect the method.
-
+constructed using edge information extracted from the noisy image. In
+order to minimize the resulting functional, it is discretized in such a
+way that we can construct graphs where minimum cuts correspond to
+minimizers of the discrete functional. This transformation is made
+possible by a coarea and Cauchy--Crofton formula.
+We end with some experiments on the different parameters to see how the
+method can be controlled and we show that the introduced anisotropy in
+some cases improve the results.
 
 %There are numerous methods for image denoising and restoration. In this
 %thesis we consider a total variation based method modified with an
@@ -179,7 +181,9 @@ I would like to thank my supervisor Markus Grasmair at the Department of
 Mathematical Sciences for invaluable help and discussion throughout my
 work with my project and this thesis.
 
-Thanks to Kine for helpful life coaching.
+Finally I would like to thank my family for their support, and Mats,
+Lars, Kine, Hager, Henrik and Edvard for life coaching and productive
+discussions around the coffee pot.
 
 Bjørn Rustad, \today.
 
@@ -234,12 +238,12 @@ Bjørn Rustad, \today.
 \markboth{\MakeUppercase\nomname}{\MakeUppercase\nomname}
 \printnomenclature[2.5cm]
 
-\cleardoublepage
-% En latex-kommando for å si fra at kapitlene/seksjonene fra nå 
-% av skal nummereres med store bokstaver:
-\appendix
-
-\input{appendix}
+%\cleardoublepage
+%% En latex-kommando for å si fra at kapitlene/seksjonene fra nå 
+%% av skal nummereres med store bokstaver:
+%\appendix
+%
+%\input{appendix}
 
 % Indeks for rapporten. Ta bort prosenttegn hvis du vil ha det med.
 %\printindex
index 824f1f17ef664869383d0cc70f3302a71e1a8260..196de92c1472113cba2ec6c16204d17be3512ca2 100644 (file)
@@ -257,6 +257,7 @@ As in most of the cited push-relabel literature, we define $N =
 which represents the amount of flow which disappears in vertex
 $u$. Equivalent to the preflow conservation constraint is stating that
 $e(u) \geq 0$ for all vertices $u \in V - \{s,t\}$.
+\nomenclature{$e(u)$}{Excess in vertex $u$.}%
 
 %The idea of the algorithm is to maintain a height map of the
 %vertices in the graph where connected vertices can not have a large
@@ -272,6 +273,8 @@ graph, i.e.\ every edge with $c_f(u, v) > 0$, we require that $d(u) \leq
 d(v) + 1$. For all vertices $u$, the label $d(u)$ will be a lower bound
 on the length from $u$ to $t$ in $G_f$ which is why it is also often
 called a distance labeling.
+\nomenclature{$d(u)$}{Height map or distance labeling $d : V \to
+\mathbb{N}$.}%
 
 A vertex $u$ is \emph{active} if $u \in V - \{s,t\}$, it has positive
 excess ($e(u) > 0$) and $d(u) < N$. These are the vertices we want to
@@ -1066,3 +1069,35 @@ paths from $s$ to $t$ as there are pixels in the image. When increasing
 the capacity of edges $(v, t)$, a quick sweep over these two-edged paths
 to send any possible flow may speed up the algorithm.
 
+\section{Implementation}
+
+A \cpp{} implementation was submitted together with this thesis and can
+also be found online at \cite{github}. It uses
+the open computer vision library OpenCV \cite{opencv_library} to load
+and save image files and contains compilation and usage instructions.
+The implementation has been tested on an installation of the Ubuntu
+Linux distribution, but it should in theory be portable to other
+platforms supported by OpenCV. A rudimentary graphics interface has also
+been made, to make it easier to play with the parameters of the
+algorithm.
+
+Both the push-relabel and the Boykov--Kolmogorov algorithms have been
+implemented. Although an effort has been made to improve the performance
+of both implementations, they are not ment to beat the fastest. The
+focus has rather been on clarity and understanding.
+
+Note that when implementing maximum flow algorithms it is not a good
+idea, memory- and performance-wise, to actually construct the residual
+graph $G_f$. Instead, every time we update the flow $f(u,v)$ we set
+the flow in the opposite direction to its negative value $f(v,u) =
+-f(u,v)$. Then we can at any time, consider the value $c(u,v) - f(u,v)$
+in the place of the residual capacity $c_f(u,v)$.
+
+For the gap relabeling heuristic of the push-relabel algorithm, we need
+to have a easy way of finding when a gap occurs. This is done by keeping
+track of how many vertices exist with each label.
+
+When the capacities have been updated in the Boykov--Kolmogorov
+algorithm, flow is sent along all two-edge paths such that they do not
+have to be considered by the main loop of the algorithm.
+
index 73bcf7f84411caa22193a2ec4b60ecc1ecaf6954..4e92d3612546147248ad9a3219b2fe3a7e647683 100644 (file)
@@ -1,8 +1,6 @@
 \chapter{Methods in image restoration}
 \label{chap:methods}
 
-\fixme{Rating: 7/10}
-
 There are numerous methods in image restoration, and since we do not
 have time nor space to discuss them all, this short overview will focus on the ones
 related to the anisotropic total variation method considered later in
@@ -12,6 +10,8 @@ background on image processing in general.
 In this chapter, and also in the rest of the thesis we will assume that
 we are given an image $f : \Omega \to \mathbb{R}$ where $\Omega$ is a
 rectangular, open domain. Because of limitations in the numerical method
+\nomenclature{$f$}{Original, noisy image.}%
+\nomenclature{$\Omega$}{Rectangular, open domain.}%
 used, the codomain is $\mathbb{R}$ and we are thus restricted to
 monochrome, or grayscale images. Such images are produced in large
 numbers by for example ultrasound, X-ray and MRI machines.
@@ -24,7 +24,9 @@ types of noise.
 
 We will assume that the given image $f$ is a combination of an
 underlying, actual image $u^*$, and some noise $\delta$. The simplest
+\nomenclature{$\delta$}{Noise.}%
 model is additive noise where the assumption is that $f = u^* + \delta$.
+\nomenclature{$u^*$}{Usually unknown, actual image without noise.}%
 There is also multiplicative noise where $f = u^* \cdot \delta$. An
 other much seen noise type is salt and pepper noise, which is when black
 and white pixels randomly appear in the image.
@@ -40,8 +42,6 @@ restoration methods.
 \section{Diffusion filtering}
 \label{sec:diffusion_filtering}
 
-\fixme{Rating: 8/10}
-
 Diffusion filtering is a broad group of filtering and restoration methods
 based on physical diffusion processes. The basic idea is to take the
 noisy image as the initial value of some diffusion process, and then let it
@@ -78,8 +78,6 @@ vary between different parts of the image.
 
 \subsection{Non-linear diffusion filtering}
 
-\fixme{Rating: 8/10}
-
 In the theory of the heat equation one can introduce a \emph{thermal
 diffusivity} $\alpha$ such that the equation becomes
 \begin{equation}
@@ -168,9 +166,11 @@ edge estimator $\nabla u_\sigma$ where
 \begin{equation}
     u_\sigma := K_\sigma * \tilde{u}
 \end{equation}
-\nomenclature{$u_\sigma$}{Image $u$ smoothed with a Gaussian of
+\nomenclature{$u_\sigma$}{Edge estimator, image $u$ smoothed with a Gaussian of
 parameter $\sigma$.}%
 and $\tilde{u}$ is an extension of $u$ from $\Omega$ to $\mathbb{R}^2$
+\nomenclature{$\tilde{u}$}{Symmetric extension of $u$ from $\Omega$ to
+$\mathbb{R}^2$}%
 made by symmetrically extending $u$ across the edges.
 Assuming we are at an edge in the image, the
 direction of $\nabla u_\sigma$ should be perpendicular to the edge,
@@ -198,6 +198,8 @@ Even if the diffusivity tensor was introduced to reduce the amount of
 smoothing across edges, the solution of \eqref{eq:aniso_diff} will still be
 infinitely differentiable \cite{weickert1998anisotropic}, i.e.\ $u(T) \in
 C^\infty(\Omega)$ for $T > 0$. Thus there are no real discontinuities, and
+\nomenclature{$C^\infty(\Omega)$}{The space of infinitely differentiable
+functions from $\Omega$ to $\mathbb{R}$.}%
 no real edges in the solution.
 
 Further, the anisotropic diffusion may introduce structure based on
@@ -224,8 +226,6 @@ problem we aim to avoid in our anisotropic total variation method.
 \section{Total variation}
 \label{sec:total_variation}
 
-\fixme{Rating: 8/10, numerical methods: 5/10}
-
 Total variation was initially introduced to the field of image
 restoration by Rudin, Osher and Fatemi in \cite{rudin1992nonlinear} and
 is usually formulated as a minimization problem
@@ -239,6 +239,10 @@ is usually formulated as a minimization problem
         \label{eq:first_min_presentation}
     \end{gathered}
 \end{equation}
+\nomenclature{$F(u)$}{Variational functional on $u$.}%
+\nomenclature{$L^p(\Omega)$}{Real functions $f$ on $\Omega$ for which
+$\int_\Omega \labs{f}^p < \infty$.}%
+\nomenclature{$\beta$}{Regularization parameter.}%
 where $p$ is normally taken to be 1 or 2.
 The fidelity term penalizes images $u$ that are far from the original
 image $f$. The
@@ -274,7 +278,11 @@ variation using the distributional derivative.
     $\Omega$.
     \label{def:tv}
 \end{definition}
-\nomenclature{$\TV(u)$}{Total variation of image $u$.}%
+\nomenclature{$\TV(u)$}{Total variation of the image $u$.}%
+\nomenclature{$C^\infty_c\left(\Omega, \mathbb{R}^2\right)$}{The space of smooth
+    functions from $\Omega$ to $\mathbb{R}^2$ with compact support in
+$\Omega$.}%
+\nomenclature{$\varphi$}{Test function.}%
 
 Note that since $\Omega$ is open and bounded, the test functions
 $\varphi$ vanish on the boundary of $\Omega$. Thus no variation is
@@ -374,9 +382,6 @@ approach we take in this thesis.
 
 \subsubsection{Graph cut approach}
 
-\fixme{Could probably be shortened a lot, but I thought it could be
-useful to at least give an idea how it is done.}
-
 Using graph cuts is the approach we will be taking later when
 considering the anisotropic total variation regularization, and it is
 therefore valuable to briefly look into how graph cuts are used in the
@@ -391,6 +396,8 @@ the functional.
 
 In the discrete setting our image consists of pixels, and is represented
 by a function $u : \mathcal{G} \to \mathcal{P}$ where $\mathcal{G}$ is a
+\nomenclature{$\mathcal{G}$}{Regular grid of pixels over $\Omega$.}%
+\nomenclature{$\mathcal{P}$}{Discrete set of pixel values, or levels.}%
 regular grid over $\Omega$, and $\mathcal{P} = \{0, \hdots, L-1\}$ is
 the discrete set of pixel values, or \emph{levels}. We denote the value
 in pixel $x$ as $u(x) = u_x$.
@@ -399,6 +406,7 @@ For an image $u$ and a level $\lambda$ we denote the \emph{level set} by
 $\{ u > \lambda\}$, defined as the set $\{ x \in \Omega : u_x > \lambda
 \}$. The thresholded image $u^\lambda$, an indicator function, is then
 defined as
+\nomenclature{$u^\lambda$}{Thresholded image at level $\lambda$.}%
 \begin{equation}
     u^\lambda = \idfun_{u > \lambda}.
 \end{equation}
index 4ed32e93301619ece269d279b9c36b53243615ec..363cc3e5c8a4cfb518bae1e2f76953c36d1146a0 100644 (file)
@@ -615,40 +615,40 @@ Figure~\ref{fig:lena_method_noise_atv2}.
 
 \begin{figure}
     \centering{}
-    \begin{subfigure}[t]{0.30\textwidth}
+    \begin{subfigure}[t]{0.31\textwidth}
         \centering
-        \includegraphics[trim=200 200 0 0,clip=true,width=\textwidth]{fig/factory/lena_method/r_p2_n16_b3000_g1000000000000_r8_s3.png}
+        \includegraphics[trim=210 210 10 10,clip=true,width=\textwidth]{fig/factory/lena_method/r_p2_n16_b3000_g1000000000000_r8_s3.png}
     \end{subfigure}
     ~
-    \begin{subfigure}[t]{0.30\textwidth}
+    \begin{subfigure}[t]{0.31\textwidth}
         \centering
-        \includegraphics[trim=200 200 0 0,clip=true,width=\textwidth]{fig/factory/lena_method/r_p2_n16_b3000_g110_r8_s3.png}
+        \includegraphics[trim=210 210 10 10,clip=true,width=\textwidth]{fig/factory/lena_method/r_p2_n16_b3000_g110_r8_s3.png}
     \end{subfigure}
     ~
-    \begin{subfigure}[t]{0.30\textwidth}
+    \begin{subfigure}[t]{0.31\textwidth}
         \centering
-        \includegraphics[trim=200 200 0 0,clip=true,width=\textwidth]{fig/factory/lena_method/r_p2_n16_b3191_g110_r8_s3.png}
+        \includegraphics[trim=210 210 10 10,clip=true,width=\textwidth]{fig/factory/lena_method/r_p2_n16_b3191_g110_r8_s3.png}
     \end{subfigure}
 
-    \begin{subfigure}[t]{0.30\textwidth}
+    \begin{subfigure}[t]{0.31\textwidth}
         \centering
-        \includegraphics[trim=200 200 0 0,clip=true,width=\textwidth]{fig/factory/lena_method/m_r_p2_n16_b3000_g1000000000000_r8_s3.png}
+        \includegraphics[trim=210 210 10 10,clip=true,width=\textwidth]{fig/factory/lena_method/m_r_p2_n16_b3000_g1000000000000_r8_s3.png}
         \caption{Regular total variation, $\beta = 3000$, $\norm{u -
         f}_{L^2} = 9771$}
         \label{fig:lena_method_noise_tv}
     \end{subfigure}
     ~
-    \begin{subfigure}[t]{0.30\textwidth}
+    \begin{subfigure}[t]{0.31\textwidth}
         \centering
-        \includegraphics[trim=200 200 0 0,clip=true,width=\textwidth]{fig/factory/lena_method/m_r_p2_n16_b3000_g110_r8_s3.png}
+        \includegraphics[trim=210 210 10 10,clip=true,width=\textwidth]{fig/factory/lena_method/m_r_p2_n16_b3000_g110_r8_s3.png}
         \caption{Anisotropic TV, $\beta = 3000$, $\omega = 110$,
         $\norm{u-f}_{L^2} = 9556$}
         \label{fig:lena_method_noise_atv1}
     \end{subfigure}
     ~
-    \begin{subfigure}[t]{0.30\textwidth}
+    \begin{subfigure}[t]{0.31\textwidth}
         \centering
-        \includegraphics[trim=200 200 0 0,clip=true,width=\textwidth]{fig/factory/lena_method/m_r_p2_n16_b3191_g110_r8_s3.png}
+        \includegraphics[trim=210 210 10 10,clip=true,width=\textwidth]{fig/factory/lena_method/m_r_p2_n16_b3191_g110_r8_s3.png}
         \caption{Anisotropic TV, $\beta = 3191$, $\omega = 110$,
         $\norm{u-f}_{L^2} = 9771$}
         \label{fig:lena_method_noise_atv2}