minor changes in isortopic tv denoising

- flag istropic in stead of anistropic
  => order of if clause
 -  .. before red
-  whitespace
This commit is contained in:
Ferdinand Deger
2013-07-13 12:38:27 +02:00
parent 71c70ccd71
commit 7809e020a1
+21 -19
View File
@@ -200,7 +200,7 @@ def denoise_bilateral(image, Py_ssize_t win_size=5, sigma_range=None,
return np.squeeze(out)
def denoise_tv_bregman(image, double weight, int max_iter=100, double eps=1e-3, anisotropic=False):
def denoise_tv_bregman(image, double weight, int max_iter=100, double eps=1e-3, isotropic=True):
"""Perform total-variation denoising using split-Bregman optimization.
Total-variation denoising (also know as total-variation regularization)
@@ -225,7 +225,8 @@ def denoise_tv_bregman(image, double weight, int max_iter=100, double eps=1e-3,
max_iter: int, optional
Maximal number of iterations used for the optimization.
anisotropic: boolean, optimal - switch between isotropic and anisotropic tv denoising
isotropic: boolean, optimal
Switch between isotropic and anisotropic tv denoising
Returns
-------
@@ -241,7 +242,7 @@ def denoise_tv_bregman(image, double weight, int max_iter=100, double eps=1e-3,
.. [3] Pascal Getreuer, "RudinOsherFatemi Total Variation Denoising
using Split Bregman" in Image Processing On Line on 20120519,
http://www.ipol.im/pub/art/2012/g-tvd/article_lr.pdf
[4] http://www.math.ucsb.edu/~cgarcia/UGProjects/BregmanAlgorithms_JacquelineBush.pdf
.. [4] http://www.math.ucsb.edu/~cgarcia/UGProjects/BregmanAlgorithms_JacquelineBush.pdf
"""
@@ -329,26 +330,27 @@ def denoise_tv_bregman(image, double weight, int max_iter=100, double eps=1e-3,
byy = by[r, c, k]
# d_subproblem after reference [4]
if anisotropic:
s = ux + bxx
if s > 1/lam:
dxx = s - 1/lam
elif s < -1/lam:
dxx = s + 1/lam
else:
dxx = 0
s = uy + byy
if s > 1/lam:
dyy = s - 1/lam
elif s < -1/lam:
dyy = s + 1/lam
else:
dyy = 0
else:
if isotropic:
s = sqrt((ux + bxx)**2 + (uy + byy)**2)
dxx = s * lam * (ux + bxx) / (s * lam + 1)
dyy = s * lam * (uy + byy) / (s * lam + 1)
else:
s = ux + bxx
if s > 1 / lam:
dxx = s - 1/lam
elif s < -1 / lam:
dxx = s + 1 / lam
else:
dxx = 0
s = uy + byy
if s > 1 / lam:
dyy = s - 1 / lam
elif s < -1 / lam:
dyy = s + 1 / lam
else:
dyy = 0
dx[r, c, k] = dxx
dy[r, c, k] = dyy