Better docstring. Better test coverage.

This commit is contained in:
François Orieux
2013-12-06 12:03:26 +01:00
parent 587ec48874
commit 4e2a5a9644
4 changed files with 41 additions and 39 deletions
+2
View File
@@ -29,6 +29,8 @@ measure
Measurement of image properties, e.g., similarity and contours.
morphology
Morphological operations, e.g. opening or skeletonization.
restoration
Deconvolution algorithms.
segmentation
Splitting an image into self-similar regions.
transform
+16 -15
View File
@@ -52,7 +52,7 @@ def wiener(image, psf, balance, reg=None, is_real=True):
The impulse response (input image's space) or the transfer
function (Fourier space). Both are accepted. The transfer
function is recognize as being complex
(`np.iscomplexobj(psf)`).
(``np.iscomplexobj(psf)``).
balance : float
The regularisation parameter value that tune the balance
between the data and the prior information.
@@ -60,12 +60,12 @@ def wiener(image, psf, balance, reg=None, is_real=True):
The regularisation operator. The Laplacian by default. It can
be an impulse response or a transfer function, as for the psf.
is_real : boolean, optional
True by default. Specify if `psf` and `reg` are provided with
hermitian hypothesis, that is only half of the frequency plane
is provided (due to the redundancy of Fourier transform of real
signal). It's apply only if `psf` and/or `reg` are provided as
transfer function. For the hermitian property see `uft`
module or `np.fft.rfftn`.
True by default. Specify if ``psf`` and ``reg`` are provided
with hermitian hypothesis, that is only half of the frequency
plane is provided (due to the redundancy of Fourier transform
of real signal). It's apply only if ``psf`` and/or ``reg`` are
provided as transfer function. For the hermitian property see
``uft`` module or ``np.fft.rfftn``.
Returns
-------
@@ -154,8 +154,8 @@ def unsupervised_wiener(image, psf, reg=None, user_params=None, is_real=True):
Return the deconvolution with a Wiener-Hunt approach, where the
hyperparameters are automatically estimated. The algorithm is a
stochastic iterative process (Gibbs sampler) described in ref
belo]. See also `wiener` function.
stochastic iterative process (Gibbs sampler) described in
reference below. See also ``wiener`` function.
Parameters
----------
@@ -165,7 +165,7 @@ def unsupervised_wiener(image, psf, reg=None, user_params=None, is_real=True):
The impulse response (input image's space) or the transfer
function (Fourier space). Both are accepted. The transfer
function is recognize as being complex
(`np.iscomplexobj(psf)`).
(``np.iscomplexobj(psf)``).
reg : ndarray, optional
The regularisation operator. The Laplacian by default. It can
be an impulse response or a transfer function, as for the psf.
@@ -177,12 +177,12 @@ def unsupervised_wiener(image, psf, reg=None, user_params=None, is_real=True):
x_postmean : (M, N) ndarray
The deconvolved image (the posterior mean).
chains : dict
The keys 'noise' and 'prior' contain the chain list of noise and
prior precision respectively.
The keys ``noise`` and ``prior`` contain the chain list of
noise and prior precision respectively.
Other parameters
----------------
The keys of `user_params` are:
The keys of ``user_params`` are:
threshold : float
The stopping criterion: the norm of the difference between to
@@ -194,7 +194,7 @@ def unsupervised_wiener(image, psf, reg=None, user_params=None, is_real=True):
min_iter : int
The minimum number of iterations. 30 by default.
max_iter : int
The maximum number of iterations if `threshold` is not
The maximum number of iterations if ``threshold`` is not
satisfied. 150 by default.
callback : callable (None by default)
A user provided callable to which is passed, if the function
@@ -338,7 +338,8 @@ def richardson_lucy(image, psf, iterations=50):
psf : ndarray
The point spread function
iterations : int
Number of iterations. This parameter play to role of regularisation.
Number of iterations. This parameter play to role of
regularisation.
Returns
-------
Binary file not shown.
+23 -24
View File
@@ -31,7 +31,7 @@ equal to
.. math:: \frac{1}{\sqrt{n}} \sum_i x_i
or the Fourier tranform have the same energy than the original image
(see `image_quad_norm` function). The transform is applied from the
(see ``image_quad_norm`` function). The transform is applied from the
last axes for performance reason (c order array). You may use directly
the numpy.fft module for more sophisticated purpose.
@@ -62,13 +62,13 @@ def ufftn(inarray, dim=None):
inarray : ndarray
The array to transform.
dim : int, optional
The `dim` last axis along wich to compute the transform. All
The ``dim`` last axis along wich to compute the transform. All
axes by default.
Returns
-------
outarray : ndarray (same shape than inarray)
The unitary N-D Fourier transform of `inarray`.
The unitary N-D Fourier transform of ``inarray``.
Examples
--------
@@ -93,13 +93,13 @@ def uifftn(inarray, dim=None):
inarray : ndarray
The array to transform.
dim : int, optional
The `dim` last axis along wich to compute the transform. All
The ``dim`` last axis along wich to compute the transform. All
axes by default.
Returns
-------
outarray : ndarray (same shape than inarray)
The unitary inverse N-D Fourier transform of `inarray`.
The unitary inverse N-D Fourier transform of ``inarray``.
Examples
--------
@@ -127,17 +127,17 @@ def urfftn(inarray, dim=None):
inarray : ndarray
The array to transform.
dim : int, optional
The `dim` last axis along wich to compute the transform. All
The ``dim`` last axis along wich to compute the transform. All
axes by default.
Returns
-------
outarray : ndarray (the last dim as N / 2 + 1 lenght)
The unitary N-D real Fourier transform of `inarray`.
The unitary N-D real Fourier transform of ``inarray``.
Notes
-----
The `urfft` functions assume an input array of real
The ``urfft`` functions assume an input array of real
values. Consequently, the output have an Hermitian property and
redondant values are not computed and returned.
@@ -167,21 +167,21 @@ def uirfftn(inarray, dim=None, shape=None):
inarray : ndarray
The array to transform.
dim : int, optional
The `dim` last axis along wich to compute the transform. All
The ``dim`` last axis along wich to compute the transform. All
axes by default.
shape : tuple of int
The shape of the output. The shape of `rfft` is ambiguous in
The shape of the output. The shape of ``rfft`` is ambiguous in
case of odd shape. In this case, the parameter must be
used. see `np.fft.irfftn`.
used. see ``np.fft.irfftn``.
Returns
-------
outarray : ndarray
The unitary N-D inverse real Fourier transform of `inarray`.
The unitary N-D inverse real Fourier transform of ``inarray``.
Notes
-----
The `uirfft` function assume that output array is of real
The ``uirfft`` function assume that output array is of real
values. Consequently, the input is assumed of having an Hermitian
property and redondant values are implicit.
@@ -213,7 +213,7 @@ def ufft2(inarray):
Returns
-------
outarray : ndarray (same shape than inarray)
The unitary 2-D Fourier transform of `inarray`.
The unitary 2-D Fourier transform of ``inarray``.
See Also
--------
@@ -244,7 +244,7 @@ def uifft2(inarray):
Returns
-------
outarray : ndarray (same shape than inarray)
The unitary 2-D inverse Fourier transform of `inarray`.
The unitary 2-D inverse Fourier transform of ``inarray``.
See Also
--------
@@ -277,7 +277,7 @@ def urfft2(inarray):
Returns
-------
outarray : ndarray (the last dim as (N - 1) *2 lenght)
The unitary 2-D real Fourier transform of `inarray`.
The unitary 2-D real Fourier transform of ``inarray``.
See Also
--------
@@ -310,7 +310,7 @@ def uirfft2(inarray, shape=None):
Returns
-------
outarray : ndarray (the last dim as (N - 1) *2 lenght)
The unitary 2-D inverse real Fourier transform of `inarray`.
The unitary 2-D inverse real Fourier transform of ``inarray``.
See Also
--------
@@ -331,8 +331,7 @@ def uirfft2(inarray, shape=None):
def image_quad_norm(inarray):
"""Return quadratic norm of images in Fourier space
This function detect if the image suppose the hermitian
property.
This function detect if the image suppose the hermitian property.
Parameters
----------
@@ -342,7 +341,7 @@ def image_quad_norm(inarray):
Returns
-------
norm : float
The quadratic norm of `inarray`.
The quadratic norm of ``inarray``.
Examples
--------
@@ -376,7 +375,7 @@ def ir2tf(imp_resp, shape, dim=None, is_real=True):
A tuple of integer corresponding to the target shape of the
tranfert function.
dim : int, optional
The `dim` last axis along wich to compute the transform. All
The ``dim`` last axis along wich to compute the transform. All
axes by default.
is_real : boolean (optionnal, default True)
If True, imp_resp is supposed real and the hermissian property
@@ -385,7 +384,7 @@ def ir2tf(imp_resp, shape, dim=None, is_real=True):
Returns
-------
y : complex ndarray
The tranfert function of shape `shape`.
The tranfert function of shape ``shape``.
See Also
--------
@@ -404,8 +403,8 @@ def ir2tf(imp_resp, shape, dim=None, is_real=True):
-----
The input array can be composed of multiple dimentionnal IR with
an arbitraru number of IR. The individual IR must be accesed
through first axes. The last `dim` axes of space definition. The
`dim` parameter must be specified to compute the transform only
through first axes. The last ``dim`` axes of space definition. The
``dim`` parameter must be specified to compute the transform only
along these last axes.
"""
if not dim: