always be a gap at label $k = N - 1$ such that we can construct our cut
by taking $S = \{ u \in V : d(u) \geq N \}$.
+Note that the vertices in $S$ are vertices earlier described as being on
+the source side of the cut, as no additional flow can go from these
+vertices to the sink.
+
\subsection{Complexity}
In their original article \cite{goldberg1988new}, Goldberg and Tarjan
The gap relabeling heuristic aims to find a label $k$ as in Theorem
\ref{thm:cut_identification} such that no vertex has that label.
From vertices $u$ with $d(u) > k$, there are no unsaturated edges going
-to vertices with smaller distance labels so no more flow can ever find
+to vertices with smaller distance labels, so no more flow can ever find
its way from these vertices to the sink. These vertices are therefore
given the label $N$ and never considered again as they will never become
active. Algorithm \ref{alg:gap} shows a pseudocode representation of
\label{alg:gap}
\end{algorithm}
-But why does this work? The only thing we need to verify is that given a
-network with a valid preflow and a valid labeling, the gap relabeling
-procedure will not change the validity of these two things.
+Before integrating the gap relabeling procedure into our algorithm we
+need to verify that it does not invalidate our preflow $f$ or distance
+labeling $d$.
+
+%But why does this work? The only thing we need to verify is that given a
+%network with a valid preflow and a valid labeling, the gap relabeling
+%procedure will not change the validity of these two things.
\begin{lemma}[Gap relabeling validity]
Given a network $G = (V, E, c)$, a distance labeling $d$ and a
unchanged, so the preflow and capacity constraint remain satisfied
after the gap relabeling.
- Define the vertex sets $S = \{ u \in V : d(u) > k\}$ and $T = V -
- S$. Initially, we have $d(u) \leq d(v) + 1$ for every edge $(u,v)
- \in E_f$. These inequalities have to hold after the gap procedure is
- finished, when all vertices $u \in S$ have label $d(u) = N$.
+ Define $S = \{ u \in V : d(u) > k\}$ and $T = V - S$. Initially
+ $d(u) \leq d(v) + 1$ for every edge $(u,v) \in E_f$. These
+ inequalities have to hold after the gap procedure is finished, when
+ $d(u) = N$ for all $u \in S$.
For $(u, v) \in E_f$ we have four possibilities
\begin{description}
- \item[$u, v \in T$]
+ \item[$u, v \in T$\textmd{:}]
The labels $d(u)$ and $d(v)$ remain unchanged and the
inequality still holds.
- \item[$u, v \in S$]
+ \item[$u, v \in S$\textmd{:}]
After the gap procedure we have $d(u) = d(v)$ so the
inequality still holds.
- \item[$u \in S, v \in T$]
+ \item[$u \in S, v \in T$\textmd{:}]
This is not possible as it would imply $d(u) \geq d(v) + 2$
and we have assumed an initial valid labeling.
- \item[$u \in T, v \in S$]
+ \item[$u \in T, v \in S$\textmd{:}]
After relabeling we have $d(u) < k < N < d(v) + 1$.
\end{description}
Hence, both the preflow $f$ and distance labeling $d$ are valid.
-
- \fixme{A bit too long compared to its interestingness/importance.}
\end{proof}
When running the push-relabel algorithm with the gap heuristic, we can
only the capacity of edges from sub-networks representing the fidelity
term depend on our level parameter $\lambda$. From the expression in
\eqref{eq:fidelity_energy0}, visualized in Figure
-\ref{fig:norm_evolution}, we see that the energy term $E^x(0)$ increases
-monotonically with increasing $\lambda$ parameter. Let $u, v \in V -
-\{s, t\}$. Since the edges in Figure \ref{fig:norm_subgraph} now are the
-only ones depending on $\lambda$, the following is true for
+\ref{fig:norm_evolution}, we see that the energy term $E_\lambda^x(0)$
+increases monotonically with increasing $\lambda$ parameter. Let $u, v
+\in V - \{s, t\}$. Since the edges in Figure \ref{fig:norm_subgraph} now
+are the only ones depending on $\lambda$, the following is true for
\emph{decreasing} values of $\lambda$
\begin{description}
\item[Edges from $s$ to $u$]
with a network $G = (V, E, c)$, a preflow $f$ and a labeling $d$. To
obtain the network for $\lambda = k-1$ we have to change the capacity of
two different kinds of edges, and this is done in the following way to
-keep the capacity and preflow constraints satisfied.
+keep the capacity, preflow and labeling constraints satisfied.
\begin{description}
\item[Edges from $s$ to $u$]
The capacity $c(s, u)$ is increased, and the flow is set to be
between the iterations of the push-relabel algorithm, we can guarantee
that this is possible.
-\fixme{More precise statement than ``stack on top of each other''}
-
Consider two subsequent runs of the push-relabel algorithm, for labels
$\lambda$ and $\lambda - 1$ ending with distance labels $d^\lambda$ and
$d^{\lambda-1}$ respectively. We already know that the distance labels
-$d$ are monotonically increasing. This means that the set $\{ u \in V :
-d(u) \geq N \}$ is increasing in size, more precisely, we have the
+$d$ are monotonically increasing. This means that the set $S = \{ u \in
+V : d(u) \geq N \}$ is increasing in size, more precisely, we have the
inclusion
\begin{equation}
\{ u \in V : d^\lambda(u) \geq N \} \subseteq \{ u \in V :
- d^{\lambda-1}(u) \geq N \}
+ d^{\lambda-1}(u) \geq N \}.
+\end{equation}
+For a pixel $x \in S$ we will set $u^\lambda_x = 0$, which together with
+the previous inclusion property implies
+\begin{equation}
+ u^\lambda_x \geq u^{\lambda-1}_x
\end{equation}
+for all $x \in \mathcal{G}$. Being equivalent with the inequality in
+\eqref{eq:stackable}, this means our algorithm produces stackable
+thresholded images $u^\lambda$.
We then construct our output image $u$ by giving each pixel the value
\begin{equation}
u_x = \min \{ \lambda \in \{0, \ldots, L-1\} : u^\lambda_x = 1 \}.
\end{equation}
This marks the end of the description of the implemented algorithm, but
-we will further discuss some possible improvements, and also look at
-results when using the method on different kinds of pictures, with
-different kinds of noise.
+we will further discuss some possible improvements, and also look at the
+results when using the method on different kinds of noisy images.
\subsection{Divide and conquer}
The possibility of re-using the network between separate level
\cite{goldfarb2009parametric} for more information.
\subsection{Implementation}
-A \cpp\ implementation can be found in appendix
+A \cpp\ implementation can be found in Appendix
\ref{app:c++implementation}. It uses the open computer vision library
OpenCV \cite{opencv_library} to load and save image files.
-Note that when implementing maximum flow algorithms, it is not a good
+Note that when implementing maximum flow algorithms it is not a good
idea, memory- and performance-wise, to actually construct the residual
network $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) =
problem.
The term $\TV(u)$ in \eqref{eq:energy_function} is the total variation
-of the image, introduced earlier as $\int_\Omega \abs{\nabla u}$. Since
-it can be problematic to calculate the traditional gradient, the
-following definition is introduced, using Green's identity to transfer
-the derivative to a smooth test function.
+of the image, introduced earlier as $\int_\Omega \abs{\nabla u}$, and
+often called the regularization term. Since it can be problematic to
+calculate the traditional gradient, the following definition is
+introduced, using Green's identity to transfer the derivative to a
+smooth test function.
\begin{definition}[Total variation]
Given a function $u \in L^1(\Omega)$, the total variation of $u$,
often written $\int_\Omega \abs{Du}$, where the $D$ is the gradient
this edge and the next edge, if the edges are sorted by increasing
angles. These parameters are also shown in Figure
\ref{fig:common_neighborhoods}. Boykov and Kolmogorov prove we have
-convergence when all of $h$, $\Delta \phi_{xy}$, and $d_{xy}$ go to
-zero. \fixme{BLOOP}
+convergence when all of $h$, $\sup_{xy} \Delta \phi_{xy}$, and
+$\sup_{xy} d_{xy}$ go to zero.
\subsubsection{Fidelity term}
-Now that the total variation is discretized, we need to take care of the
-fidelity term. We define the following function for some pixel value
+The first integral of \eqref{eq:energy_function} is often called the
+fidelity term as it controls the similarity of the output and input
+image. As for the regularization term, we want to discretize it and
+write it as a sum over the level values $\lambda$.
+
+We define the following function for some pixel value
$k$ and some pixel position $x$ in the original image $v$, which is the
value of the energy if we were to color pixel $x$ with label $k$
\begin{equation}
\big) + N(0) \\
&= \sum_{\lambda=0}^{L-2} \big(
N(\lambda + 1) - N(\lambda)
- \big) \mathbbm{1}_{\lambda < k} + N(0).
+ \big) I(\lambda < k) + N(0).
\end{aligned}
\end{equation}
-Since $\mathbbm{1}_{\lambda < u_x} = (1 - u^\lambda_x)$ we rewrite
-\eqref{eq:norm_discrete_int} and obtain
+Here $I(x)$ is an indicator function that takes the value $1$ if $x$ is
+true, and $0$ if $x$ is false. Since $I(\lambda < u_x) = (1 -
+u^\lambda_x)$ we rewrite \eqref{eq:norm_discrete_int} and obtain
\begin{equation}
\sum_x N_x(u_x) =
\sum_{\lambda=0}^{L-2} \sum_x
\big)
(1 - u^\lambda_x) + N_x(0).
\end{equation}
-\fixme{BLOOP}
\subsubsection{Total energy}
\label{sec:total_energy}
\begin{equation}
u^\lambda_x \leq u^\mu_x \quad \forall \lambda \leq \mu,
\quad \forall x \in S.
+ \label{eq:stackable}
\end{equation}
In the following sections we will present a graph cut algorithm that
finds thresholded images minimizing each level, \emph{while guaranteeing
that they meet this requirement.}
-\fixme{Consistently call them the fidelity and regularization terms.}
-