From c942ad54c797f4daca392c287d121d712d9c8970 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Orieux?= Date: Mon, 28 Oct 2013 12:39:23 +0100 Subject: [PATCH] Inline crandn function. --- skimage/deconvolution/uft.py | 11 ----------- skimage/deconvolution/wiener.py | 4 +++- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/skimage/deconvolution/uft.py b/skimage/deconvolution/uft.py index 6f80a22d..a592f8d7 100644 --- a/skimage/deconvolution/uft.py +++ b/skimage/deconvolution/uft.py @@ -332,17 +332,6 @@ def image_quad_norm(inarray): return np.sum(np.sum(np.abs(inarray)**2, axis=-1), axis=-1) -def crandn(shape): - """white complex gaussian noise - - Generate directly the unitary Fourier transform of white gaussian - noise noise field (with given shape) of zero mean and variance - unity (ie N(0,1)). - """ - return np.sqrt(0.5) * (np.random.standard_normal(shape) + - 1j * np.random.standard_normal(shape)) - - def ir2tf(imp_resp, shape, dim=None, real=True): """Compute the transfer function of IR diff --git a/skimage/deconvolution/wiener.py b/skimage/deconvolution/wiener.py index 2247d619..762499c5 100644 --- a/skimage/deconvolution/wiener.py +++ b/skimage/deconvolution/wiener.py @@ -266,7 +266,9 @@ def unsupervised_wiener(data, psf, reg=None, user_params=None): # weighing (correlation in direct space) precision = gn_chain[-1] * atf2 + gx_chain[-1] * areg2 # Eq. 29 - excursion = uft.crandn(data.shape) / np.sqrt(precision) + excursion = np.sqrt(0.5) / np.sqrt(precision) * ( + np.random.standard_normal(data.shape) + + 1j * np.random.standard_normal(data.shape)) # mean Eq. 30 (RLS for fixed gn, gamma0 and gamma1 ...) wiener_filter = gn_chain[-1] * np.conj(trans_fct) / precision