section.
We will now consider the two kinds of summands in the energy function in
-\eqref{eq:total_energy}. The fidelity term comes from our aim to keep
-the output image close to the original image, and in the decomposition,
-the edge capacities resulting from this term will depend on the level
-value.
-
-The regularization term of \eqref{eq:total_energy} comes from our aim to
-minimize to total variation, and the edge capacities coming from this
-term will not depend on the level value.
-
-\fixme{MEH}
+\eqref{eq:total_energy}. The fidelity term coming from our aim to keep
+the output image close to the original image, and the regularization
+term coming from our aim to minimize the total variation.
\subsubsection{Fidelity term}
The fidelity term of our energy function in \eqref{eq:total_energy}
\end{figure}
Figure \ref{fig:norm_subgraph} shows how networks can be constructed to
-represent this part of the total energy. The construction is a bit
-different, depending on whether $E^x(0)$ is positive or negative. Table
+represent this part of the total energy. The construction differs
+depending on whether $E^x(0)$ is positive or negative. Table
\ref{tab:fid_energy} shows how the cuts correspond to the values of
-$u^\lambda_x$ and makes it easy to verify that the constructed network
+$u^\lambda_x$ and we can easily verify that the constructed network
actually represents the fidelity term in the energy function.
\begin{table}
\centering
- \caption{An overview of the two possible values of $u^\lambda_x$ in
- the fidelity term $E^x(u^\lambda_x)$. For each value, the
- corresponding energy and the cut in the graph obtaining this
- value is shown. The last two columns show the capacities of the
- cut for each of the two network constructions in Figure
+ \caption{Each row represents one of the two possible values of
+ $u^\lambda_x \in \{0,1\}$. The energy $E^x(u^\lambda_x)$ and
+ minimum cut obtaining this configuration is shown. The last two
+ columns show the capacities of the cut for each of the two
+ network constructions in Figure
\ref{fig:norm_subgraph}. We verify that, for each of the two
network constructions, the cut capacities are equal to the
energies plus a constant.
\label{eq:neigh_energies}
\end{equation}
and by Theorem \ref{thm:network_rep_id} our energy function is graph
-representable. Kolmogorov and Zabih presents a way to construct a graph
-for any graph representable function in \cite{kolmogorov2002energy}.
-Since our energies in \eqref{eq:neigh_energies} are especially simple,
-the construction and presentation is simplified.
+representable. In \cite{kolmogorov2002energy}, Kolmogorov and Zabih
+presents a way to construct a graph for any graph representable function
+on the form shown in theorem \ref{thm:network_rep_id}. Since the
+energies in \eqref{eq:neigh_energies} are especially simple, the
+construction and presentation is simplified.
\begin{figure}
-\input{fig/neigh_subgraph}
+ \input{fig/neigh_subgraph}
\end{figure}
Figure \ref{fig:neigh_subgraph} shows two different ways of how a network
-can be constructed to represent the regularization term. Table
-\ref{tab:neigh_energy} shows the energies, and also the cut capacities
-of the different possible variable value combinations, making it easy to
-verify that these two network constructions actually represent our
-energy function.
+can be constructed to represent the regularization term. See Table
+\ref{tab:neigh_energy} for an overview of how the two values of
+$u^\lambda_x$ corresponds to cuts in the network.
\begin{table}
\centering
\hline
$(u^\lambda_x, u^\lambda_y)$
& $E^{x,y}(u^\lambda_x, u^\lambda_y)$
- & Min. cut $(S, T)$
+ & Min.\ cut $(S, T)$
& Alt.\ \subref{fig:neigh_subgraph_alt1} cut cap. & Alt.\
\subref{fig:neigh_subgraph_alt2} cut cap. \\
\hline
\section{Maximum flow approach}
-\fixme{Capacities introduced in the last chapter. Introduce flow here,
-and shortly what is to come}
+\fixme{Must be clear earlier that we are considering one level at the
+time.}
+
+In the previous section we have seen how finding the minimum cut of
+carefully constructed network can give us the thresholded image
+minimizing the energy function for one level value $\lambda$. We will in
+this, and the next section see how such a minimum cut can be found by
+sending flow through the network, and trying to identify the
+``bottleneck''.
\subsection{Flow networks}
We have already introduced capacities, and briefly mentioned the notion
-of flow as something the capacity limits. In other words, flow is
+of flow as something limited by the capacity. In other words, flow is
something we can send through our network, but the capacity limits how
-much we can send along each edge. It is useful to imagine for example a
-water supply network with pipes of different sizes. The source and sink
-introduced earlier would then be represented by a water reservoir, and a
-drain out to sea, respectively.
+much we can send along each edge. It is useful to imagine a water supply
+network with pipes of different sizes. The source and sink would then be
+the water source, and water sink in the network.
Formally, we introduce the \emph{flow} as the function $f : V \times V
\to [0, \infty)$. This function keeps count of how much flow we are
\begin{equation}
\sum_{v \in V} f(v, u) = \sum_{v \in V} f(u, v),
\end{equation}
- i.e., for any node except the source and the sink, the
- flow into the node must be equal to the flow out of the node.
+ i.e., for any vertex except the source and the sink, the
+ flow into the vertex must be equal to the flow out of the
+ vertex.
\end{description}
Note that we have defined $f$ with all pairs of vertices as its domain,
even though it is only non-zero on edges $(u, v) \in E$. This makes it
-easier to write sums like in the flow conservation constraint.
+easier to write sums as in the flow conservation constraint.
We denote $\abs{f}$ as the net amount of flow from the source to the
sink in the network. Because of the flow conservation constraint, this
\sum_{u \in S} f(v, u).
\label{eq:net_flow_cut}
\end{equation}
-Note how this definition is different from the capacity of a cut
-$c(S,T)$ in Definition \ref{def:s_t_cut}. While the capacity of a cut
-represents how much flow it is maximally possible to send from $S$ to
-$T$, the net flow across a cut represents just that, the net amount of
-flow across the cut, counting flow that goes back from $T$ to $S$.
+Note how this definition differs from the capacity of a cut $c(S,T)$ in
+Definition \ref{def:s_t_cut}. While the capacity of a cut represents how
+much flow it is maximally possible to send from $S$ to $T$, the net flow
+across a cut represents the net amount of flow going across the cut,
+counting negatively the flow that goes back from $T$ to $S$.
For any $s$-$t$-cut we have that
\begin{equation}
- \abs{f} = f(S, T)
+ \abs{f} = f(S, T).
\label{eq:total_flow_eq_cut}
\end{equation}
-This is trivial for the cut $S = \{s\}$, $T = V - S$. A proof that this
-is true for the rest of the cuts can start at this trivial cut, and move
-vertex by vertex from $T$ to $S$, maintaining the equality of
-\eqref{eq:total_flow_eq_cut} at each step.
+This is quite intuitive given the flow conservation constraint, and a
+full chain of arguments can be found in \cite{cormen2009introduction}.
-Following from \eqref{eq:total_flow}, \eqref{eq:net_flow_cut} and
-\eqref{eq:total_flow_eq_cut}, we can show that
+Following from \eqref{eq:net_flow_cut} and \eqref{eq:total_flow_eq_cut},
+we find that
\begin{equation}
- \abs{f} \leq c(S, T)
- \label{eq:flow_leq_cut}
+ \begin{aligned}
+ \abs{f} &= \sum_{u \in S} \sum_{v \in T} f(u, v)
+ - \sum_{v \in T} \sum_{u \in S} f(v, u) \\
+ &\leq \sum_{u \in S} \sum_{v \in T} f(u, v) \\
+ &\leq \sum_{u \in S} \sum_{v \in T} c(u, v) \\
+ &\leq c(S, T)
+ \label{eq:flow_leq_cut}
+ \end{aligned}
\end{equation}
-for any $s$-$t$-cut $C = (S, T)$. See \cite{cormen2009introduction} for
-a full proof of this chain of arguments.
+for any $s$-$t$-cut $C = (S, T)$. We will see in the next theorem that
+this becomes an equality only when the flow is a maximum flow.
-\fixme{No anti-parallel edges.}
-\fixme{More references to Cormen for proofs.}
+\fixme{No anti-parallel edges. Or save that for the residual network
+section.}
+\fixme{Whoops, a bit of a gap here.}
Recall that we want to find the minimum $s$-$t$ cut in our network. When
finding this minimum cut, we make use of an important duality theorem in
network flow theory, stating that the capacity of a minimum $s$-$t$-cut
-in a network, is equal to the maximum flow from $s$ to $t$.
+in a network, is equal to the maximum flow from the source to the sink.
\begin{theorem}[Max-flow min-cut theorem]
If $f$ is a flow in a network $G = (V, E, c)$ with source $s$ and
sink $t$, then the following is equivalent:
But how does this help us? We know that if we know the maximum flow
value, and we have an $s$-$t$-cut with capacity equal to the maximum
flow, we actually have a minimum cut. The question is then, how do we
-find the maximum flow, and how do we find a minimum cut.
-
-\fixme{But how do we find THE minimum cut? Which one do we want? The
-maximum one? The minimum one? EEEEK}
+find a maximum flow, and how do we find a minimum cut?
-\subsection{Augmenting flow algorithms}
+\subsection{Augmenting path algorithms}
The family of augmenting flow algorithms represent a popular approach to
the maximum flow problem. The idea is simply to look for paths from the
-source to the sink in the graph, along which is is possible to send more
-flow, and then send the maximum amount of flow along this path. When no
-such path exists anymore, no more flow can be sent through the graph,
-and maximum flow has been reached.
+source to the sink that can carry additional flow, and then send the
+maximum possible amount of flow along this path. When no such path
+exists anymore, no more flow can be sent from the source to the sink,
+and a maximum flow has been reached.
\subsubsection{Residual network}
When further discussing approaches to solving the max-flow problem we
with $c_f(u, v) > 0$. Since we can in $E_f$ at most have all the
original edges, and their reversals, we have $\abs{E_f} \leq 2 \abs{E}$.
+Figure \ref{fig:aug_flow} shows a simple network which already has five
+units flowing from $s$ to $t$. The marked path is a possible augmenting
+path, and note that it follows an edge in $E$ in the reverse direction,
+made possible by the construction of the residual network just
+described.
+
\begin{figure}
- \centering
- \begin{tikzpicture}[scale=1.5]
- \node[vertex] (s) at (0, 0) {s};
- \node[vertex] (u) at (2, 1) {u};
- \node[vertex] (v) at (2, -1) {v};
- \node[vertex] (t) at (4, 0) {t};
-
- \path[edge] (s) -- node[weight] {5/5} (u);
- \path[selected edge] (s) -- node[weight] {} (v);
- \path[edge] (s) -- node[weight] {0/5} (v);
- \path[selected edge] (u) -- node[weight] {} (v);
- \path[edge] (u) -- node[weight] {5/5} (v);
- \path[selected edge] (u) -- node[weight] {} (t);
- \path[edge] (u) -- node[weight] {0/5} (t);
- \path[edge] (v) -- node[weight] {5/5} (t);
- \end{tikzpicture}
- \caption{A network with the flow and capacity of each edge shown as
- flow/capacity. The marked path is a valid augmenting path from
- $s$ to $t$, and by increasing the flow along it, we will push
- flow back from $v$ to $u$. \fixme{refer to this figure
- somewhere!}
- }
- \label{fig:aug_flow}
+ \input{fig/aug_flow}
\end{figure}
\subsubsection{Ford-Fulkerson}
-The Ford-Fulkerson algorithm is the most basic augmenting flow
+The Ford-Fulkerson algorithm is the most basic augmenting path
algorithm, which can be extended to more advanced algorithms. It is
stated in pseudocode in Algorithm \ref{alg:ford_fulkerson}, and the idea
is to augment the flow along paths from $s$ to $t$ until it is no longer
\State $\alpha \gets \min\{c_f(u, v) : (u, v) \in p \}$
\ForAll{$(u, v) \in p$}
\State $f(u, v) \mathrel{+}= \alpha$
- \State $f(v, u) \mathrel{-}= \alpha$
\EndFor
\EndWhile
\EndFunction
the source node until the sink node is found, as this will yield the
shortest possible augmenting path. This version of the algorithm is
called Edmonds-Karp and has a running time of $O(\abs{V}\abs{E}^2)$.
-See \cite{cormen2009introduction} for a description of the breadth-first
-search, and a formal proof of the running time of the algorithm.
+See for example \cite{cormen2009introduction} for a description of the
+breadth-first search, and a formal proof of the running time of the
+algorithm.
\subsubsection{Dinitz'}
\fixme{I did implement this, but it is maybe not very central to the
only goes from nodes with one label to nodes with greater labels. When
this blocking flow is found we restart at the BFS.
-\subsection{The push-relabel algorithm}
+\section{The push-relabel algorithm}
+\fixme{Maybe this could be a section? Since it is a bit different than
+regular max-flow-min-cut}
+
The push-relabel algorithm is a different approach to the maximum flow
problem, presented by Goldberg and Tarjan in \cite{goldberg1988new}.
-Unlike the augmenting flow algorithms, it does not at all times maintain
-a valid flow $f$ in the network at all times, but still obtains a
-maximum valid flow when the algorithm is finished.
+Unlike the augmenting flow algorithms, it does not maintain a valid flow
+$f$ in the network at all times, but still obtains a valid maximum flow
+when the algorithm is finished.
-\subsubsection{Preflow}
+\subsection{Preflow}
Instead of maintaining a valid flow, we introduce the concept of a
-\emph{preflow}, as we relax the flow concervation constraint from
-earlier. For a preflow $f$, the flow must always be less than the
-capacity, as before, but we allow positive excess in all vertices except
-the source and the sink. The flow conservation constraint from before
-then becomes
+\emph{preflow} as we relax the flow conservation constraint from
+earlier. For a preflow $f$, the capacity constraint still holds so the
+flow must always be less than the capacity, but we allow positive excess
+in the vertices. The flow conservation constraint from before then
+becomes
\begin{description}
\item[Preflow conservation:] For all $u \in V - \{s, t\}$
\begin{equation}
\end{description}
\fixme{Vertex vs.\ node.}
-
\fixme{Describe saturated in the $G_f$ section. And $N$.}
For all vertices $u \in V$ we define the excess
\end{equation}
which represents the amount of flow which \emph{disappears} in node $u$.
Equivalent to the preflow conservation constraint is stating that $e(u)
-\geq 0$ for all vertices except the source and the sink.
+\geq 0$ for all vertices $u \in V - \{s,t\}$.
The idea of the algorithm is to maintain a height map of the
-nodes of the network and then ``lift'' the source node to let as many
-units as possible flow through the edges of the network towards the
+vertices of the network where connected nodes can not have a large
+height difference. Then we ``lift'' the source vertex to let as
+many units as possible flow through the edges of the network towards the
sink. When a maximum preflow is reached, there will normally be excess
flow in some of the vertices, which has to be pushed back towards the
source in order to obtain a valid flow.
The height map $d : V \to \mathbb{N}$ is also often called a distance
-labeling and it satisfies $d(t) = 0$ and for every edge $(u, v)$ in the
-residual network, i.e.\ every edge with $c_f(u, v) > 0$, the labeling
-satisfies $d(u) \leq d(v) + 1$. For every vertex $u$ for which there is
-a path through the residual network to the sink, $d(u)$ will be a lower
-bound on the length of such a path.
+labeling and it satisfies $d(t) = 0$, and for every edge $(u, v)$ in the
+residual network, i.e.\ every edge with $c_f(u, v) > 0$, we require that
+$d(u) \leq d(v) + 1$. For every vertex $u$ for which there is a path
+through the residual network to the sink, $d(u)$ will be a lower bound
+on the length of such a path.
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 nodes we want to
operate on to increase the preflow.
+\subsection{Basic operations}
+
The algorithm performs two basic operations, the \emph{push} and
\emph{relabel} operations, while always maintaining a valid preflow $f$
and a valid distance labeling $d$.
\subsubsection{The push procedure}
-The push operation moves excess flow from an active vertex along an edge
+The push procedure moves excess flow from an active vertex along an edge
$(u, v) \in E_f$ such that $d(u) = d(v) + 1$, i.e.\ to a vertex with a
smaller distance label. We call such edges \emph{admissible}. See
Algorithm \ref{alg:push} for a pseudocode implementation of the push
all other vertices.
The distance labels are not changed during the push procedure, however,
-the residual network is changed. The edge $(u, v)$ might disappear, and
+the residual network can change. The edge $(u, v)$ might disappear, and
an edge $(v, u)$ will surely appear if it does not already exist. Assume
that $d$ is a valid labeling. When starting the push procedure we have
$d(u) = d(v) + 1$, so we also have the following
d(u) &\leq d(v) + 1 \\
d(v) &\leq d(u) + 1,
\end{align}
-and $d$ remains a valid labeling. \fixme{not very clear?}
+and $d$ remains a valid labeling, even if the edge $(v, u)$ appears.
\fixme{Change height $h$ to distance $d$.}
\end{algorithm}
\subsubsection{The relabel procedure}
-The relabel procedure is our tool for changing the distance labeling of
+The relabel procedure is our tool for changing the distance labels of
our vertices. It changes the label of a vertex to the greatest possible
value, which is one more than the lowest label among its neighbors in
-the residual graph. See Algorithm \ref{alg:relabel} for a pseudocode
-implementation.
+the residual graph. See Algorithm \ref{alg:relabel} for a rather
+mathematical pseudocode implementation.
\begin{algorithm}
\begin{algorithmic}
\Function{Relabel}{$u$}
% \If{$u$ is only node at its height}
% \Call{Gap}{$u$}
% \Else
- \State $d(u) \gets min(d(v) \; \forall v \in
- neighbors(u) : c_f(u, v) > 0) + 1$
+ \If{there is a $v$ such that $(u, v) \in E_f$}
+ \State $d(u) \gets \min\{d(v), \; \forall v \in V : (u,v) \in E_f\} + 1$
+ \Else
+ \State $d(u) \gets N$
+ \EndIf
% \EndIf
\EndFunction
\end{algorithmic}
\label{alg:relabel}
\end{algorithm}
-\fixme{Relabel: What if the set is empty?}
-
If $d$ was a valid labeling before running the relabel procedure, then
we still have $d(u) \leq d(v) + 1$ for all neighbors $v$ of $u$ in the
residual graph, and $d$ remains a valid labeling. The capacity
-constraint and preflow constraint remain valid assuming they were
-fulfilled before the procedure was started.
+constraint and preflow constraint remain satisfied assuming they were
+satisfied before the procedure was started.
-\subsubsection{Putting it all together}
+\subsection{Putting it all together}
In the first phase of the algorithm we initialize a valid preflow and
distance labeling by saturating all edges out of the source $s$, and
then setting its distance label $d(s) = N$. We then run the push and
-relabel when possible until a maximum preflow is obtained. This phase is
-finished when there are no more active nodes.
+relabel procedures when applicable until there are no more active nodes
+and a maximum preflow is obtained.
\fixme{What is saturated?}
-A node $u$ can only be successfully relabeled to obtain a new label if
+A vertex $u$ can only be successfully relabeled to obtain a new label if
the edges outgoing edges of $u$ in the residual network have changed.
This is why the push and relabel procedures often are combined into a
\emph{discharge} procedure as shown in Algorithm \ref{alg:discharge}.
\fixme{Sketch of proof, could be nicer, shorter (split up?) and more
rigorous maybe.}
-\subsubsection{Complexity}
+\subsection{Complexity}
Bleep bloop.
\fixme{Edge list problematikk.}
-\subsubsection{Vertex selection rules}
+\subsection{Vertex selection rules}
\fixme{Also mention this over complexity.}
Until now we have just stated that the discharge procedure is run on
active nodes until there are no more active nodes left. The choice of
largest distance label.
\fixme{Running time and reference.}
-\subsubsection{Heuristics}
+\subsection{Heuristics}
Different heuristics exists that can speed up the algorithm
considerably. Being heuristics, they are not guaranteed to work, and
might perform differently on different kinds of graphs. The most used
results when using the method on different kinds of pictures, with
different kinds of noise.
-\subsubsection{Divide and conquer}
+\subsection{Divide and conquer}
\fixme{Write something here.}
\subsection{Implementation}