From: Bjørn Rustad Date: Wed, 2 Apr 2014 14:29:57 +0000 (+0200) Subject: Some fixes X-Git-Url: http://git.rustad.me/?a=commitdiff_plain;h=67ad26e4c7dc40f49cd04aadc9a2208b2f93c47c;p=prosjektoppgave Some fixes --- diff --git a/total.tex b/total.tex index 268255f..acced19 100644 --- a/total.tex +++ b/total.tex @@ -6,6 +6,13 @@ time has a low \emph{total variation} by solving \min_u \int_\Omega \abs{u - v}^p + \beta \int_\Omega \abs{\nabla u}. \label{eq:first_min_presentation} \end{equation} +Minimizing the total variation $\int_\Omega \abs{\nabla u}$ will smooth +out differences in the image while the term $\int_\Omega \abs{u - v}^p$ +will constrain the solution image $u$ to be close to the original image +$v$. Combining the two will give us an image close to the original, but +more regular. The parameter $\beta$ controls how strongly we want to +regularize the image. + How we can integrate the gradient of an image which can contain discontinuities will be clarified later, but first we will look at how this model can be grounded in spatial statistics; \fixme{an important @@ -124,8 +131,16 @@ our case an open subset of $\mathbb{R}^2$. Normally, $p$ is chosen to be models in \eqref{eq:minimizing_probability_l1} and \eqref{eq:minimizing_probability_l2}. -The term $\TV(u)$ is the total variation of the image, introduced -earlier as $\int_\Omega \abs{\nabla u}$, and is defined as follows: +In the following, assume that our image domain $\Omega$ is an open and +bounded subset of $\mathbb{R}^2$, with a Lipschitz boundary. Since most +images are given on rectangles in $\mathbb{R}^2$, this is not +problematic. + +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 is problematic to calculate the traditional gradient at +discontinuities, 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 @@ -140,26 +155,12 @@ earlier as $\int_\Omega \abs{\nabla u}$, and is defined as follows: \end{equation} The test functions $\varphi$ are taken from $C^\infty_c\left(\Omega, \mathbb{R}^2\right)$, the space of smooth - functions from $\Omega$ to $\mathbb{R}^2$ with compact support. - \fixme{$\Omega$ open, bounded, Lipschitz boundary?}. + functions from $\Omega$ to $\mathbb{R}^2$ with compact support in + $\Omega$. \end{definition} - -Minimizing the total variation will smooth out differences in the image. -The term $\int_\Omega \abs{u - v}^p$ of \eqref{eq:energy_function} will -constrain the solution image $u$ to be close to the input image $v$. -Combining the two will give us an image close to the original, but more -regular. The parameter $\beta$ controls how strongly we want to -regularize the image. - -When discretizing the energy function \eqref{eq:energy_function} later -on, we want to decompose it as a sum over the different levels, or pixel -values, of the image. This is why we present the coarea formula here, -and use it to write the total variation $\TV(u)$ as an integral over the -range level values $\lambda$. The coarea formula and further references -can be found in \cite{caselles2011total}. - -First we need to introduce the space of functions with bounded -variation and the perimeter of a set. +Note that since $\Omega$ is open and bounded, the test functions +$\varphi$ never has support on the boundary of $\Omega$. Next we +introduce the space of functions with bounded variation. \begin{definition}[Functions of bounded variation] The space of functions of bounded variation $\BV(\Omega)$ is the space of functions $u \in L^1(\Omega)$ for which the total variation @@ -169,6 +170,17 @@ variation and the perimeter of a set. \right\}. \end{equation} \end{definition} +When discretizing the energy function \eqref{eq:energy_function} later +on, we want to decompose it as a sum over the different levels, or pixel +values, of the image. This is why we present the coarea formula here, +and use it to write the total variation $\TV(u)$ as an integral over the +range level values $\lambda$. The coarea formula and further references +can be found in \cite{caselles2011total}. + +First we need to introduce the formal definition of a set perimeter. +Here, $\idfun_E$ signifies the characteristic function of the set $E$, a +function which is equal to one in every point in $E$, and zero +elsewhere. \begin{definition}[Set perimeter] The perimeter of a set $E$ is defined as \begin{equation} @@ -177,47 +189,61 @@ variation and the perimeter of a set. A measurable set $E \subset \Omega$ is of finite perimeter in $\Omega$ if $\idfun_E \in \BV(\Omega)$. \end{definition} -These two definitions allows us to present the coarea formula +The set perimeter behaves mostly as one might expect, just note that if +the boundary of $E$ overlaps with the boundary of $\Omega$, then +$P(E,\Omega)$ will not include the overlapping part of the boundary. + +For an image $u$ we introduce the level sets of $u$ as +\begin{equation} + u^\lambda = \idfun_{u \leq \lambda}, + \label{eq:level_set} +\end{equation} +and with that we are ready to introduce the coarea formula. \begin{theorem}[The coarea formula] Let $u \in BV(\Omega)$. Then for almost every $\lambda$ the set $u^\lambda$ is of finite perimeter, and one has the coarea formula \begin{equation} \TV(u) = \int_\Omega \abs{D u} - = \int_\mathbb{R} P(u^\lambda) \, d\lambda + = \int_\mathbb{R} P(u^\lambda,\Omega) \, d\lambda \label{eq:coarea_formula} \end{equation} \end{theorem} -This allows us to rewrite \eqref{eq:energy_function} to +Assuming that our image $u$ is in $\BV(\Omega)$, this allows us to +rewrite \eqref{eq:energy_function} as \begin{equation} E_v(u) = \int_\Omega \abs{u - v}^p - + \beta \int_\mathbb{R} P(u^\lambda) \, d\lambda, + + \beta \int_\mathbb{R} P(u^\lambda,\Omega) \, d\lambda, \label{eq:energy_perimeter} \end{equation} -which is a good starting point for the discretization. More analysis of -the continuous problem is given in \cite{caselles2011total}, together -with different numerical methods for solving it. Results on how the set -of jumps in the resulting image $u$ is contained in the set of jumps in -the original image $v$ are also presented. +which is a good starting point for the discretization step. More +analysis of the continuous problem is given in \cite{caselles2011total}, +together with different numerical methods for solving it. Results on how +the set of jumps in the resulting image $u$ is contained in the set of +jumps in the original image $v$ are also presented. \subsection{Discrete formulation} Since digital images are given on a discrete grid, with values taken from a discrete and finite set of levels, we want to discretize \eqref{eq:energy_perimeter}, and solve the resulting discrete problem. -We assume that the image is given on a discrete grid $S$, -where the value of each pixel is taken from the set $\mathcal{L} = \{0, -\hdots, L-1\}$. A reasonable assumption for grayscale images. +We denote $S$ for the grid of pixels, and assume that the value of each +pixel is taken from the set $\mathcal{L} = \{0, \hdots, L-1\}$. This is +a reasonable assumption for grayscale images. -Following the notation used in \cite{darbon2006image}, we let $u_x$ -denote the value of the image $u$ at position $x \in \Omega$ and -introduce the level sets $u^\lambda$ of the image +Chambolle discretizes the total variation as \begin{equation} - u^\lambda = \idfun_{u \leq \lambda} - \label{eq:level_set} + \TV(u) = \sum_{i,j} \sqrt{ + \left( u_{i+1,j} - u_{i,j} \right)^2 + + \left( u_{i,j+1} - u_{i,j} \right)^2 + } \end{equation} -which will be important when dividing the problem into smaller -subproblems. \fixme{Position $x$ already used in stats section.} +in his much cited paper \cite{chambolle2004algorithm}, where he +introduces his dual approach to the continuous minimization problem. +This straight-forward way of discretizing the gradient offers, according +to Chambolle, a good compromize between isotropy and stability. However, +it does not decompose into a sum over the levels of the image, which we +need for our graph composition. \begin{figure} \centering @@ -248,11 +274,15 @@ subproblems. \fixme{Position $x$ already used in stats section.} \caption{The level sets of a one-dimensional image.} \label{fig:level_sets} \end{figure} -After discretizing the image, we obtain a finite number of level sets -$u^\lambda$. Figure \ref{fig:level_sets} shows an example of a -one-dimensional image divided into its level sets. -\begin{figure}[b] +Following the notation used in \cite{darbon2006image}, we let $u_x$ +denote the value of the image $u$ at position $x \in S$. With a finite +set of pixel values $\mathcal{L}$, we also have a finite number of level +sets $u^\lambda$. Figure \ref{fig:level_sets} visualizes the level sets +of a possible one-dimensional image. +\fixme{Position $x$ already used in stats section. Problem?} + +\begin{figure} \centering \begin{subfigure}[b]{0.4\textwidth} \centering @@ -274,28 +304,26 @@ one-dimensional image divided into its level sets. ~ \begin{subfigure}[b]{0.4\textwidth} \centering - \begin{tikzpicture}[->,thick,font=\footnotesize, - main node/.style={circle,draw,minimum size=.7cm}] - - \node[main node] (1) at (0, 0) {x}; - \node[main node] (2) at (-2, 0) {}; - \node[main node] (3) at ( 2, 0) {}; - \node[main node] (4) at (0, -2) {}; - \node[main node] (5) at (0, 2) {}; - \node[main node] (6) at (-2, -2) {}; - \node[main node] (7) at (-2, 2) {}; - \node[main node] (8) at ( 2, 2) {y}; - \node[main node] (9) at ( 2, -2) {}; - - \path[every node/.style={font=\sffamily\small}] - (1) edge node [right] {} (2) - (1) edge node [right] {} (3) - (1) edge node [left] {} (4) - (1) edge node [left] {} (5) - (1) edge node [right] {} (6) - (1) edge node [right] {} (7) - (1) edge node [left] {} (8) - (1) edge node [left] {} (9); + \begin{tikzpicture}[scale=1] + + \node[vertex] (1) at (0, 0) {x}; + \node[vertex] (2) at (-2, 0) {}; + \node[vertex] (3) at ( 2, 0) {}; + \node[vertex] (4) at (0, -2) {}; + \node[vertex] (5) at (0, 2) {}; + \node[vertex] (6) at (-2, -2) {}; + \node[vertex] (7) at (-2, 2) {}; + \node[vertex] (8) at ( 2, 2) {y}; + \node[vertex] (9) at ( 2, -2) {}; + + \path[edge] (1) -- (2); + \path[edge] (1) -- (3); + \path[edge] (1) -- (4); + \path[edge] (1) -- (5); + \path[edge] (1) -- (6); + \path[edge] (1) -- (7); + \path[edge] (1) -- (8); + \path[edge] (1) -- (9); \draw (0,0) +(0:1cm) arc (0:45:1cm); \path (0,0) ++(22.5:.75cm) node{$\alpha$}; @@ -307,29 +335,22 @@ one-dimensional image divided into its level sets. \caption{Two common neighborhood stencils.} \label{fig:common_neighborhoods} \end{figure} -Chambolle discretizes the total variation as -\begin{equation} - \TV(u) = \sum_{i,j} \sqrt{ - \left( u_{i+1,j} - u_{i,j} \right)^2 + - \left( u_{i,j+1} - u_{i,j} \right)^2 - } -\end{equation} -in his much cited paper \cite{chambolle2004algorithm}, in which he -introduces his dual approach to the minimization problem. This -straight-forward way of discretizing the gradient offers, according to -Chambolle, a good compromize between isotropy and stability. However, it -does not decompose into a sum over all the different levels of the -image, which we need for our graph composition. This is why we -discretize the total variation in \eqref{eq:coarea_formula} -anisotropically as follows +Recall that we managed to write the total variation as an integral over +the range of level values in \eqref{eq:coarea_formula}. Here, we +estimate the perimeter of the level set $u^\lambda$ in the discrete +setting, such that the total variation can be written as a sum over the +level values. We introduce a neighborhood? + +We estimate the perimeter in the discrete setting to write the total +variation as \begin{equation} \TV(u) - = \sum_{\lambda = 0}^{L-2} P(u^\lambda) + = \sum_{\lambda = 0}^{L-2} P(u^\lambda, S) = \sum_{\lambda = 0}^{L-2} \sum_{(x,y)} w_{xy} \abs{u_x^\lambda - u_y^\lambda}, \label{eq:tv_discrete_int} \end{equation} -where the second sum is over nodes in a neighborhood relation and the +where the sum over $(x,y)$ signifies neighborhood relation and the $w_{xy}$ is the weight of this relation. Intuitively, the perimeter of the level set $u^\lambda$ is proportional to the number of edges crossing this perimeter, as $\abs{u^\lambda_x - u^\lambda_y}$ only