$\newcommand{\dotp}[2]{\langle #1, #2 \rangle}$ $\newcommand{\enscond}[2]{\lbrace #1, #2 \rbrace}$ $\newcommand{\pd}[2]{ \frac{ \partial #1}{\partial #2} }$ $\newcommand{\umin}[1]{\underset{#1}{\min}\;}$ $\newcommand{\umax}[1]{\underset{#1}{\max}\;}$ $\newcommand{\umin}[1]{\underset{#1}{\min}\;}$ $\newcommand{\uargmin}[1]{\underset{#1}{argmin}\;}$ $\newcommand{\norm}[1]{\|#1\|}$ $\newcommand{\abs}[1]{\left|#1\right|}$ $\newcommand{\choice}[1]{ \left\{ \begin{array}{l} #1 \end{array} \right. }$ $\newcommand{\pa}[1]{\left(#1\right)}$ $\newcommand{\diag}[1]{{diag}\left( #1 \right)}$ $\newcommand{\qandq}{\quad\text{and}\quad}$ $\newcommand{\qwhereq}{\quad\text{where}\quad}$ $\newcommand{\qifq}{ \quad \text{if} \quad }$ $\newcommand{\qarrq}{ \quad \Longrightarrow \quad }$ $\newcommand{\ZZ}{\mathbb{Z}}$ $\newcommand{\CC}{\mathbb{C}}$ $\newcommand{\RR}{\mathbb{R}}$ $\newcommand{\EE}{\mathbb{E}}$ $\newcommand{\Zz}{\mathcal{Z}}$ $\newcommand{\Ww}{\mathcal{W}}$ $\newcommand{\Vv}{\mathcal{V}}$ $\newcommand{\Nn}{\mathcal{N}}$ $\newcommand{\NN}{\mathcal{N}}$ $\newcommand{\Hh}{\mathcal{H}}$ $\newcommand{\Bb}{\mathcal{B}}$ $\newcommand{\Ee}{\mathcal{E}}$ $\newcommand{\Cc}{\mathcal{C}}$ $\newcommand{\Gg}{\mathcal{G}}$ $\newcommand{\Ss}{\mathcal{S}}$ $\newcommand{\Pp}{\mathcal{P}}$ $\newcommand{\Ff}{\mathcal{F}}$ $\newcommand{\Xx}{\mathcal{X}}$ $\newcommand{\Mm}{\mathcal{M}}$ $\newcommand{\Ii}{\mathcal{I}}$ $\newcommand{\Dd}{\mathcal{D}}$ $\newcommand{\Ll}{\mathcal{L}}$ $\newcommand{\Tt}{\mathcal{T}}$ $\newcommand{\si}{\sigma}$ $\newcommand{\al}{\alpha}$ $\newcommand{\la}{\lambda}$ $\newcommand{\ga}{\gamma}$ $\newcommand{\Ga}{\Gamma}$ $\newcommand{\La}{\Lambda}$ $\newcommand{\si}{\sigma}$ $\newcommand{\Si}{\Sigma}$ $\newcommand{\be}{\beta}$ $\newcommand{\de}{\delta}$ $\newcommand{\De}{\Delta}$ $\newcommand{\phi}{\varphi}$ $\newcommand{\th}{\theta}$ $\newcommand{\om}{\omega}$ $\newcommand{\Om}{\Omega}$
This tour explores a primal-dual proximal splitting algorithm, with application to imaging problems.
using NtToolBox
using PyPlot
In this tour we use the primal-dual algorithm detailed in:
Antonin Chambolle and Thomas Pock A First-order primal-dual algorithm for convex problems with application to imaging, Journal of Mathematical Imaging and Vision, Volume 40, Number 1 (2011), 120-145
One should note that there exist many other primal-dual schemes.
We consider general optimization problems of the form $$ \umin{f} F(K(f)) + G(f) $$ where $F$ and $G$ are convex functions and $K : f \mapsto K(f)$ is a linear operator.
For the primal-dual algorithm to be applicable, one should be able to compute the proximal mapping of $F$ and $G$, defined as: $$ \text{Prox}_{\gamma F}(x) = \uargmin{y} \frac{1}{2}\norm{x-y}^2 + \ga F(y) $$ (the same definition applies also for $G$).
The algorithm reads: $$ g_{k+1} = \text{Prox}_{\sigma F^*}( g_k + \sigma K(\tilde f_k) $$ $$ f_{k+1} = \text{Prox}_{\tau G}( f_k-\tau K^*(g_{k+1}) ) $$ $$ \tilde f_{k+1} = f_{k+1} + \theta (f_{k+1} - f_k) $$
The dual functional is defined as $$ F^*(y) = \umax{x} \dotp{x}{y}-F(x). $$ Note that being able to compute the proximal mapping of $F$ is equivalent to being able to compute the proximal mapping of $F^*$, thanks to Moreau's identity: $$ x = \text{Prox}_{\tau F^*}(x) + \tau \text{Prox}_{F/\tau}(x/\tau) $$
It can be shown that in the case $\theta=1$, if $\sigma \tau \norm{K}^2<1$, then $f_k$ converges to a minimizer of the original minimization of $F(K(f)) + G(f)$.
More general primal-dual schemes have been developped, see for instance
L. Condat, A primal-dual splitting method for convex optimization involving Lipschitzian, proximable and linear composite terms, J. Optimization Theory and Applications, 2013, in press.
We consider a linear imaging operator $\Phi : f \mapsto \Phi(f)$ that maps high resolution images to low dimensional observations. Here we consider a pixel masking operator, that is diagonal over the spacial domain.
Load an image.
n=256
f0 = load_image("NtToolBox/src/data/lena.png")
s1,s2=size(f0)
f0 = f0[Base.div(s1-n,2):Base.div(s1-n,2)+n-1, Base.div(s2-n,2):Base.div(s2-n,2)+n-1];
Display it.
imageplot(f0);
We consider here the inpainting problem. This simply corresponds to a masking operator.
Load a random mask $\La$.
rho = .8
Lambda = rand(n,n).>rho;
Masking operator $ \Phi $.
Phi = f -> f.*Lambda;
Compute the observations $y=\Phi f_0$.
y = Phi(f0);
Display it.
imageplot(y);
We want to solve the noiseless inverse problem $y=\Phi f$ using a total variation regularization: $$ \umin{ y=\Phi f } \norm{\nabla f}_1 $$
This can be recasted as the minimization of $F(K(f)) + G(f)$ by introducing $$ G(f)=i_H(f), \quad F(u)=\norm{u}_1 \qandq K=\nabla, $$ where $H = \enscond{x}{\Phi(x)=y}$ is an affine space, and $i_H$ is the indicator function $$ i_H(x) = \choice{ 0 \qifq x \in H, \\ +\infty \qifq x \notin H. } $$
Shorcut for the operators.
K = f -> Grad(f)
KS = u -> -Div(u[:,:,1],u[:,:,2]);
Shortcut for the TV norm.
Amplitude = u -> sqrt(sum(u.^2,3));
F = u -> sum(sum(Amplitude(u)));
The proximal operator of the vectorial $\ell^1$ norm reads $$ \text{Prox}_{\lambda F}(u) = \max\pa{0,1-\frac{\la}{\norm{u_k}}} u_k $$
ProxF = (u,lambda) -> max(0,1-lambda./repeat(Amplitude(u), outer=(1, 1, 2))).*u;
Display the thresholding on the vertical component of the vector.
figure(figsize=(10,10))
ax = gca(projection="3d")
t = -linspace(-2,2, 201);
(Y,X) = meshgrid(t,t);
U = cat(3,Y,X);
V = ProxF(U,1);
# 3D display
surf(V[:,:,1]);
set_cmap("jet")
#ax[:view](-150, 40)
#gca()[:invert_zaxis]()
ax[:view_init](-150, 40)
#axis("tight");
#camlight;
#shading interp;