%gmChap08.tex

\graphicspath{{./figures/}}

\begin{slide}
\section{Erosions and Dilations}


 \[
T_d u(\fxx)=\sup_{\fxy\in\fxx+B}u(\fxy)\quad\text{ and }\quad T_e u(\fxx)=\inf_{\fxy\in\fxx+B}u(\fxy).
\]
The operator $T_d$  is called a dilation, and $T_e$ is called an
erosion. These function operators have associated set operators,
and in fact we are going to define the set operators first.

\end{slide}
\begin{slide}
\begin{definition}Let $B$ be a subset of $\RR^N$ and let $t\geq0$ be a scale parameter. The set operators $\mathcal D_t$ and $\mathcal E_t$ are defined on subsets $X\in\mathcal P(\RR^N)$ by
\begin{equation}\label{eq8.1}
\mathcal D_t X=X+tB=\{\fxz\mid\fxz=\fxx+\fxy, \fxx\in X, \fxy\in tB\}=\bigcup_{\fxy\in tB}(X+\fxy),
\end{equation}
and
\begin{equation}
\mathcal E_t X=\{\fxx\mid\fxx+tB\subset X\}=\bigcap_{\fxy\in-tB}(X+y).
\end{equation}
$\mathcal D_t X$ is called the dilation of $X$ with structuring element $B$ at scale $t$. $\mathcal E_t X$ is called the erosion of $X$ with structuring element $B$ at scale $t$.
\end{definition}
\end{slide}
\begin{slide}

\begin{figure}[!t]
\setkeys{Gin}{width=10cm} \centerline{
\includegraphics{fig08.01.1.eps}
} \caption[Dilation of a set]{\label{Pfig1}Dilation of a set. Left
to right: A set; its dilation by a ball of radius 20; the
difference set. }
\end{figure}
\end{slide}
\begin{slide}
  When $B$ is symmetric with respect to
zero, the operator $\mathcal D_t\mathcal E_t$ is called an
\textit{opening at scale t} and $\mathcal E_t\mathcal D_t$ is
called a \textit{closing at scale t}. These names have a
topological origin. If $B$ is the open ball centered at zero with
radius one, then the opening at scale $t$ of a set $X$ is the
union of all balls with radius $t$ contained in $X$. The interior
of $X$ is the union of all open balls contained in $X$; it is also
the largest open set contained in $X$. If we call the interior map
$\mathcal T^\circ X=X^\circ$   the opening, then an opening at
scale $t$ appears as a qualified opening. The topological
statement ``the closure of the complement of $X$ is the complement
of the interior of $X$'' has its counterpart for openings and
closings at scale $t$.
\end{slide}
\begin{slide}

 \begin{figure}[!t]
\setkeys{Gin}{width=10cm} \centerline{
\includegraphics{fig08.04.1.eps}
} \caption[Opening of a set as a curvature threshold]{Opening of a
set as curvature threshold from above. Left to right: A set $X$;
its opening by a ball of radius 20; the difference set. This
opening transforms $X$ into the union of all balls of radius 20
contained in it. The resulting operation can be understood as a
threshold from above of the curvature of the set boundary. }
\end{figure}
\end{slide}
\begin{slide}

\begin{enumerate}%[(i)]\setlength\itemsep{2pt}
\item Let $B=\{\fxx\mid |\fxx|<1\}$. Then $\mathcal D_t\mathcal
E_t X$ is the union of all open balls with radius $t$ contained in
$X$. \item Let $B$ be any structuring element that is symmetric
with respect to zero. Writing $X^c=\RR^N\setminus X$, one has
$\mathcal D_t X^c=(\mathcal E_t X)^c$. This implies $\mathcal
E_t\mathcal D_t X^c=(\mathcal D_t\mathcal E_t X)^c$. \finex
\end{enumerate}
\end{slide}


\begin{figure}[!t]
\setkeys{Gin}{width=10cm}
\centerline{
\includegraphics{fig08.02.1.eps}
}
\caption[Erosion of a set]{\label{Pfig2}Erosion of a set. Left to right: A set; its erosion by a ball of radius 20; the difference set.
}
\end{figure}


\begin{slide}
\begin{definition}For $u\in\mathcal F$, define $D_t u$ by
\begin{equation}
D_t u(\fxx)=\sup_{\fxy\in tB}u(\fxx-\fxy)
\end{equation}
and define $E_t u$ by
\begin{equation}
E_t u(\fxx)=\inf_{\fxy\in-tB}u(\fxx-\fxy).
\end{equation}
\end{definition}
\end{slide}

\begin{slide}
\begin{theorem}For $u\in\mathcal F$,
\begin{equation}\label{E8.7}
D_t u(\fxx)=\sup\{\lambda\mid\fxx\in\mathcal D_t\levelset_{\lambda}u\}\; \text{ for a.e. }\fxx\in\RR^N,
\end{equation}
\begin{equation}\label{E8.9}
E_t u(\fxx)=\sup\{\lambda\mid\fxx\in\mathcal
E_t\levelset_{\lambda}u\}\; \text{ for a.e. }\fxx\in\RR^N,
\end{equation}

\begin{equation}\label{E8.8}
\mathcal D_t\levelset_{\lambda}u=\levelset_{\lambda}D_t u
\;\;\;\;\mathcal E_t\levelset_{\lambda}u=\levelset_{\lambda}E_t u
\end{equation}
almost everywhere, except possibly for at most a countable number
of $\lambda$'s.
\end{theorem}
\end{slide}

\begin{figure}[!t]
\setkeys{Gin}{width=10cm}
\centerline{
\includegraphics{fig08.05.1.eps}
}
\caption[Closing of a set as a curvature threshold]{Closing of a set as a curvature threshold from below. Left to right: A set $X$; its closing by a ball of radius 20; the difference set. The closing of $X$ is just the opening of $X^c$. It can be viewed as a threshold from below of the curvature of the set boundary.
}
\end{figure}

\begin{slide}
We say that the family of dilations  $\{D_t\mid t>0\}$ associated
with a structuring element $B$ is \textit{recursive} if
$D_tD_s=D_{t+s}$ for all $s,t>0$, and similarly for $\{E_t\mid
t>0\}$. (A recursive family is also called a \textit{semigroup}.)


\begin{lemma}
$B$ is convex if and only if $(s+t)B=sB+tB$ for all $s,t\geq0$.
\end{lemma}
\end{slide}
\begin{figure}[!t]
\setkeys{Gin}{width=6cm} \centerline{
\includegraphics{fig08.06.1.eps}
}  First row: a sea bird image and its level lines for all levels
multiple of 12. Second row: an erosion with radius 4. On the
right, the resulting level lines where the circular shape of the
structuring element (a disk with radius 4) appears around each
local minimum of the original image. Erosion removes local maxima
(in particular, all small white spots) but expands minima. Thus,
all dark spots, like the eye of the bird, are expanded. Third row:
the effect of a dilation with radius 4 and the resulting level
lines. We see how local minima are removed (for example, the eye
of the bird) and how white spots on the tail expand. Here, in
turn, circular level lines appear around all local maxima of the
original image. }
\end{figure}

\begin{slide}
\begin{proposition}The dilations  $\mathcal D_t$ and $D_t$ and the erosions $\mathcal E_t$ and $E_t$ are recursive if and only the structuring element $B$ is convex.
\end{proposition}
\end{slide}

\begin{figure}[!t]
\setkeys{Gin}{width=6cm} \centerline{
\includegraphics{fig08.07.1.eps}
} \caption[Openings and closings of a natural image] {Openings and
closings of a natural image. First row: the original image and its
level lines for all levels multiple of 12. Second row: an opening
with radius 4 has been applied. Third row: a closing with radius
has been applied. We can recognize the circular shape of the
structuring element in the level lines displayed on the right. }
\end{figure}

\begin{slide}
\section{The PDEs associated with erosions and dilations}

Scaled dilations and erosions are associated with the equations
${\partial u}/{\partial t}=\pm|Du|$. To explain this connection,
we begin with a bounded convex set $B$ that contains the origin,
and we define the gauge $\|\cdot\|_B$ on $\RR^N$ associated with
$B$ by $\|\fxx\|_B=\sup_{\fxy\in B}(\fxx\cdot\fxy)$. If $B$ is a
ball centered at the origin with radius one, then $\|\cdot\|_B$ is
the usual Euclidean norm, which we write simply as $|\cdot|$.
\end{slide}


\begin{slide}
\begin{proposition}[Hopf--Lax formula]Assume that $B$ is a bounded convex set in $\RR^N$ that contains the origin. Given $u_0:\RR^N\to\RR$, define $u:\RR^+\times\RR^N\to\RR$ by $u(t,\fxx)=D_tu_0(\fxx)$. Then $u$ satisfies the equation
\[
\frac{\partial u}{\partial t}=\|Du\|_{-B}
\]
at each point $(t,\fxx)$ where $u$ has continuous derivatives in $t$ and $\fxx$. The same result hold when $D_t$ is replaced with $E_t$ and the equation is replaced with ${\partial u}/{\partial t}=-\|Du\|_{-B}$.
\end{proposition}
\end{slide}
\begin{slide}
\begin{proof} \[
u_0(\fxx-\fyx)-u_0(\fxx)=-Du_0(\fxx)\cdot\fxy+o(|\fxy|),
\]

\[
u(h,\fxx)-u(0,\fxx)=\sup_{\fxy\in hB}(-Du_0(\fxx)\cdot\fxy+o(|\fxy|)).
\]
 \[
u(h,\fxx)-u(0,\fxx)=h\sup_{\fxz\in B}((-Du_0(\fxx)\cdot\fxz)+o(|h|).
\]
We can divide both sides by $h$ and pass to the limit as $|h|\to0$ to obtain
\[
\frac{\partial u}{\partial t}(0,\fxx)=\|Du_0(\fxx)\|_{-B},
\]
which is the result for $t=0$. For an arbitrary $t>0$, we have $D_{t+h}=D_tD_h=D_hD_t$, and we can write
\[
u(t+h,\fxx)-u(t,\fxx)=D_hu(t,\cdot)(\fxx)-u(t,\fxx).
\]
By repeating the argument  made for $t=0$ with $u_0$ replaced with
$u(t,\cdot)$, we arrive at the general result.
\end{proof}
\end{slide}
\begin{figure}[!t]
\setkeys{Gin}{width=10cm} \centerline{
\includegraphics{fig08.08.1.eps}
} \caption[Denoising based on openings and closings
I]{\label{operaun}Denoising based on openings and closings. First
row: scanned picture of the word ``operator'' with black dots and
a black line added; a dilation with a $2 \times 5$ rectangle; an
erosion with the same structuring element applied to the middle
image. The resulting operator is a closing. Small black structures
are removed by such a process. Second row: the word ``operator''
with  a white line and white dots inside the letters; erosion with
a rectangle $2 \times 5$; a dilation with the same structuring
element applied to the middle image. The resulting operator is an
opening. This time, small white structures are removed. }
\end{figure}
\begin{figure}[!t]
\setkeys{Gin}{width=6cm} \centerline{
\includegraphics{fig08.09.1.eps}
} \caption[Denoising based on opening and closing
(II)]{\label{POPERATORDEUX}Examples of denoising based on opening
or closing, as in Figure \ref{operaun}. Perturbations made with
both black and white lines or dots have been added to the
``operator'' image. First column, top to bottom: original
perturbed image; erosion with a $1 \times 3$ rectangle; then
dilation with the same structuring element. (In other words,
opening with this rectangle.) Then a dilation is applied with a
rectangle $3 \times 1$, and finally an erosion with the same
rectangle. Second column: The same process is applied,  but with
erosions and dilations exchanging their roles. It does not work so
well because closing expands white perturbations and opening
expands black perturbations. These operators do not commute. See
Figure \ref{medianofoperatorimage}, where an application of the
median filter is more successful. }
\end{figure}
