Skip to content

Commit 0f169af

Browse files
committed
Added trace of Marmousi for rMS tutorial and updated docstring of rMS
1 parent 34c9591 commit 0f169af

File tree

2 files changed

+21
-34
lines changed

2 files changed

+21
-34
lines changed

pyproximal/proximal/rMS.py

Lines changed: 21 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66

77
def _l2(x, thresh):
8-
r"""Soft thresholding.
8+
r"""scaling.
99
1010
Applies soft thresholding to vector ``x - g``.
1111
@@ -41,19 +41,25 @@ def _current_kappa(kappa, count):
4141

4242

4343
class rMS(ProxOperator):
44-
r"""L1 norm proximal operator.
44+
r"""relaxed Mumford-Shoh norm proximal operator.
4545
46-
Proximal operator of the :math:`\ell_1` norm:
47-
:math:`\sigma\|\mathbf{x} - \mathbf{g}\|_1 = \sigma \sum |x_i - g_i|`.
46+
Proximal operator of the relaxed Mumford-Shah norm:
47+
:math:`\text{rMS}(x) = \min (\alpha\Vert x\Vert_2^2, \kappa).`.
4848
4949
Parameters
5050
----------
5151
sigma : :obj:`float` or :obj:`list` or :obj:`np.ndarray` or :obj:`func`, optional
52-
Multiplicative coefficient of L1 norm. This can be a constant number, a list
52+
Multiplicative coefficient of L2 norm that controls the smoothness. This can be a constant number, a list
5353
of values (for multidimensional inputs, acting on the second dimension) or
5454
a function that is called passing a counter which keeps track of how many
5555
times the ``prox`` method has been invoked before and returns a scalar (or a list of)
5656
``sigma`` to be used.
57+
kappa : :obj:`float` or :obj:`list` or :obj:`np.ndarray` or :obj:`func`, optional
58+
Constant value in the rMS norm which essentially controls when the norm allows a jump. This can be a
59+
constant number, a list of values (for multidimensional inputs, acting on the second dimension) or
60+
a function that is called passing a counter which keeps track of how many
61+
times the ``prox`` method has been invoked before and returns a scalar (or a list of)
62+
``kappa`` to be used.
5763
g : :obj:`np.ndarray`, optional
5864
Vector to be subtracted
5965
@@ -62,41 +68,22 @@ class rMS(ProxOperator):
6268
The :math:`\ell_1` proximal operator is defined as [1]_:
6369
6470
.. math::
65-
66-
\prox_{\tau \sigma \|\cdot\|_1}(\mathbf{x}) =
67-
\operatorname{soft}(\mathbf{x}, \tau \sigma) =
68-
\begin{cases}
69-
x_i + \tau \sigma, & x_i - g_i < -\tau \sigma \\
70-
g_i, & -\tau\sigma \leq x_i - g_i \leq \tau\sigma \\
71-
x_i - \tau\sigma, & x_i - g_i > \tau\sigma\\
72-
\end{cases}
73-
74-
where :math:`\operatorname{soft}` is the so-called called *soft thresholding*.
75-
76-
Moreover, as the conjugate of the :math:`\ell_1` norm is the orthogonal projection of
77-
its dual norm (i.e., :math:`\ell_\inf` norm) onto a unit ball, its dual
78-
operator (when :math:`\mathbf{g}=\mathbf{0}`) is defined as:
79-
80-
.. math::
81-
82-
\prox^*_{\tau \sigma \|\cdot\|_1}(\mathbf{x}) = P_{\|\cdot\|_{\infty} <=\sigma}(\mathbf{x}) =
71+
\text{prox}_{\text{rMS}}(x) =
8372
\begin{cases}
84-
-\sigma, & x_i < -\sigma \\
85-
x_i,& -\sigma \leq x_i \leq \sigma \\
86-
\sigma, & x_i > \sigma\\
87-
\end{cases}
73+
\frac{1}{1+2\alpha}x & \text{ if } & \vert x\vert \leq \sqrt{\frac{\kappa}{\alpha}(1 + 2\alpha)} \\
74+
\kappa & \text{ else }
75+
\end{cases}.
8876
89-
.. [1] Chambolle, and A., Pock, "A first-order primal-dual algorithm for
90-
convex problems with applications to imaging", Journal of Mathematical
91-
Imaging and Vision, 40, 8pp. 120–145. 2011.
77+
.. [1] Strekalovskiy, E., and D. Cremers, 2014, Real-time minimization of the piecewise smooth
78+
Mumford-Shah functional: European Conference on Computer Vision, 127–141.
9279
9380
"""
9481
def __init__(self, sigma=1., kappa=1., g=None):
9582
super().__init__(None, False)
9683
self.sigma = sigma
9784
self.kappa = kappa
98-
self.g = g
99-
self.gdual = 0 if g is None else g
85+
# self.g = g
86+
# self.gdual = 0 if g is None else g
10087
self.count = 0
10188

10289
def __call__(self, x):
@@ -123,7 +110,7 @@ def prox(self, x, tau):
123110

124111
@_check_tau
125112
def proxdual(self, x, tau):
126-
x - tau * self.prox(x / tau, 1. / tau)
127-
# x = self._proxdual_moreau(x, tau)
113+
# x - tau * self.prox(x / tau, 1. / tau)
114+
x = self._proxdual_moreau(x, tau)
128115

129116
return x

testdata/marmousi_trace.npy

1012 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)