ó
 ‰\c           @   sI  d  d l  Z d  d l Z d  d l m Z d d l m Z d d l m	 Z	 m
 Z
 d d l m Z m Z d  d l Z d  d l j Z d  d l Z d d d d d	 d
 d d „ Z d d e d „ Z d d d d „ Z d d d e d „ Z d „  Z d „  Z d d „ Z d d d d d d „ Z d d d d e e d d „ Z e e d „ Z d S(   iÿÿÿÿN(   t   ceili   (   t   img_as_float(   t   _denoise_bilateralt   _denoise_tv_bregman(   t   skimage_deprecationt   warni   i'  t   constanti    c   	      C   sZ  | d k r t d ƒ t } n  | rÞ |  j d k rm |  j d k rR t d ƒ ‚ qÛ t d j |  j ƒ ƒ ‚ q|  j d d k r|  j d d k r¼ d } t | j |  j |  j d ƒ ƒ qÛ d } t | j |  j ƒ ƒ qn* |  j d k rt d	 j |  j ƒ ƒ ‚ n  | d k r>t d
 d t t	 d | ƒ ƒ d ƒ } n  t
 |  | | | | | | ƒ S(   s¼	  Denoise image using bilateral filter.

    This is an edge-preserving, denoising filter. It averages pixels based on
    their spatial closeness and radiometric similarity [1]_.

    Spatial closeness is measured by the Gaussian function of the Euclidean
    distance between two pixels and a certain standard deviation
    (`sigma_spatial`).

    Radiometric similarity is measured by the Gaussian function of the
    Euclidean distance between two color values and a certain standard
    deviation (`sigma_color`).

    Parameters
    ----------
    image : ndarray, shape (M, N[, 3])
        Input image, 2D grayscale or RGB.
    win_size : int
        Window size for filtering.
        If win_size is not specified, it is calculated as
        ``max(5, 2 * ceil(3 * sigma_spatial) + 1)``.
    sigma_color : float
        Standard deviation for grayvalue/color distance (radiometric
        similarity). A larger value results in averaging of pixels with larger
        radiometric differences. Note, that the image will be converted using
        the `img_as_float` function and thus the standard deviation is in
        respect to the range ``[0, 1]``. If the value is ``None`` the standard
        deviation of the ``image`` will be used.
    sigma_spatial : float
        Standard deviation for range distance. A larger value results in
        averaging of pixels with larger spatial differences.
    bins : int
        Number of discrete values for Gaussian weights of color filtering.
        A larger value results in improved accuracy.
    mode : {'constant', 'edge', 'symmetric', 'reflect', 'wrap'}
        How to handle values outside the image borders. See
        `numpy.pad` for detail.
    cval : string
        Used in conjunction with mode 'constant', the value outside
        the image boundaries.
    multichannel : bool
        Whether the last axis of the image is to be interpreted as multiple
        channels or another spatial dimension.

    Returns
    -------
    denoised : ndarray
        Denoised image.

    References
    ----------
    .. [1] http://users.soe.ucsc.edu/~manduchi/Papers/ICCV98.pdf

    Examples
    --------
    >>> from skimage import data, img_as_float
    >>> astro = img_as_float(data.astronaut())
    >>> astro = astro[220:300, 220:320]
    >>> noisy = astro + 0.6 * astro.std() * np.random.random(astro.shape)
    >>> noisy = np.clip(noisy, 0, 1)
    >>> denoised = denoise_bilateral(noisy, sigma_color=0.05, sigma_spatial=15)
    s=   denoise_bilateral will default to multichannel=False in v0.15i   i   s“   Use ``multichannel=False`` for 2D grayscale images. The last axis of the input image must be multiple color channels not another spatial dimension.s¥   Bilateral filter is only implemented for 2D grayscale images (image.ndim == 2) and 2D multichannel (image.ndim == 3) images, but the input image has {0} dimensions. i   sÂ   The last axis of the input image is interpreted as channels. Input image with shape {0} has {1} channels in last axis. ``denoise_bilateral`` is implemented for 2D grayscale and color images onlys?   Input image must be grayscale, RGB, or RGBA; but has shape {0}.s¢   Bilateral filter is not implemented for grayscale images of 3 or more dimensions, but input image has {0} dimension. Use ``multichannel=True`` for 2-D RGB images.i   i   N(   i   i   (   t   NoneR   t   Truet   ndimt
   ValueErrort   formatt   shapet   maxt   intR    R   (	   t   imaget   win_sizet   sigma_colort   sigma_spatialt   binst   modet   cvalt   multichannelt   msg(    (    s;   lib/python2.7/site-packages/skimage/restoration/_denoise.pyt   denoise_bilateral   s,    @
		#	*id   gü©ñÒMbP?c         C   s   t  |  | | | | ƒ S(   sÂ  Perform total-variation denoising using split-Bregman optimization.

    Total-variation denoising (also know as total-variation regularization)
    tries to find an image with less total-variation under the constraint
    of being similar to the input image, which is controlled by the
    regularization parameter ([1]_, [2]_, [3]_, [4]_).

    Parameters
    ----------
    image : ndarray
        Input data to be denoised (converted using img_as_float`).
    weight : float
        Denoising weight. The smaller the `weight`, the more denoising (at
        the expense of less similarity to the `input`). The regularization
        parameter `lambda` is chosen as `2 * weight`.
    eps : float, optional
        Relative difference of the value of the cost function that determines
        the stop criterion. The algorithm stops when::

            SUM((u(n) - u(n-1))**2) < eps

    max_iter : int, optional
        Maximal number of iterations used for the optimization.
    isotropic : boolean, optional
        Switch between isotropic and anisotropic TV denoising.

    Returns
    -------
    u : ndarray
        Denoised image.

    References
    ----------
    .. [1] http://en.wikipedia.org/wiki/Total_variation_denoising
    .. [2] Tom Goldstein and Stanley Osher, "The Split Bregman Method For L1
           Regularized Problems",
           ftp://ftp.math.ucla.edu/pub/camreport/cam08-29.pdf
    .. [3] Pascal Getreuer, "Rudinâ€“Osherâ€“Fatemi Total Variation Denoising
           using Split Bregman" in Image Processing On Line on 2012â€“05â€“19,
           http://www.ipol.im/pub/art/2012/g-tvd/article_lr.pdf
    .. [4] http://www.math.ucsb.edu/~cgarcia/UGProjects/BregmanAlgorithms_JacquelineBush.pdf

    (   R   (   R   t   weightt   max_itert   epst	   isotropic(    (    s;   lib/python2.7/site-packages/skimage/restoration/_denoise.pyt   denoise_tv_bregmanx   s    ,gš™™™™™¹?g-Cëâ6*?iÈ   c         C   sÀ  |  j  } t j |  j  f |  j d |  j ƒ} t j | ƒ } t j |  ƒ } d } xg| | k  r»| d k rC| j d ƒ } t d
 ƒ g | }	 t d
 ƒ g | d }
 xŒ t	 | ƒ D]~ } t d d
 ƒ |	 | <t d d ƒ |
 | d <| |
 d <| t
 |	 ƒ c | t
 |
 ƒ 7<t d
 ƒ |	 | <t d
 ƒ |
 | d <q´ W|  | } n |  } | d j ƒ  } t d
 ƒ g | d } xh t	 | ƒ D]Z } t d d ƒ | | d <| | d <t j | d | ƒ| t
 | ƒ <t d
 ƒ | | d <q}Wt j | d j d d ƒ ƒ t j d f } | | | j ƒ  7} d d	 | } | | | 9} | d 7} | | | 8} | | :} | t |  j ƒ :} | d k r‡| } | } n' t j | | ƒ | | k  r¨Pn | } | d 7} qU W| S(   sÛ  Perform total-variation denoising on n-dimensional images.

    Parameters
    ----------
    image : ndarray
        n-D input data to be denoised.
    weight : float, optional
        Denoising weight. The greater `weight`, the more denoising (at
        the expense of fidelity to `input`).
    eps : float, optional
        Relative difference of the value of the cost function that determines
        the stop criterion. The algorithm stops when:

            (E_(n-1) - E_n) < eps * E_0

    n_iter_max : int, optional
        Maximal number of iterations used for the optimization.

    Returns
    -------
    out : ndarray
        Denoised array of floats.

    Notes
    -----
    Rudin, Osher and Fatemi algorithm.

    t   dtypei    i   iÿÿÿÿi   t   axis.g      ð?g       @N(   R	   t   npt   zerosR   R   t
   zeros_liket   sumt   sliceR   t   ranget   tuplet   difft   sqrtt   newaxist   floatt   sizet   abs(   R   R   R   t
   n_iter_maxR	   t   pt   gt   dt   it   slices_dt   slices_pt   axt   outt   Et   slices_gt   normt   taut   E_initt
   E_previous(    (    s;   lib/python2.7/site-packages/skimage/restoration/_denoise.pyt   _denoise_tv_chambolle_nd§   sT    	%
 
,

	c         C   sŸ   |  j  } | j d k s' t |  ƒ }  n  | r† t j |  ƒ } x\ t |  j d ƒ D]/ } t |  d | f | | | ƒ | d | f <qP Wn t |  | | | ƒ } | S(   s¦	  Perform total-variation denoising on n-dimensional images.

    Parameters
    ----------
    image : ndarray of ints, uints or floats
        Input data to be denoised. `image` can be of any numeric type,
        but it is cast into an ndarray of floats for the computation
        of the denoised image.
    weight : float, optional
        Denoising weight. The greater `weight`, the more denoising (at
        the expense of fidelity to `input`).
    eps : float, optional
        Relative difference of the value of the cost function that
        determines the stop criterion. The algorithm stops when:

            (E_(n-1) - E_n) < eps * E_0

    n_iter_max : int, optional
        Maximal number of iterations used for the optimization.
    multichannel : bool, optional
        Apply total-variation denoising separately for each channel. This
        option should be true for color images, otherwise the denoising is
        also applied in the channels dimension.

    Returns
    -------
    out : ndarray
        Denoised image.

    Notes
    -----
    Make sure to set the multichannel parameter appropriately for color images.

    The principle of total variation denoising is explained in
    http://en.wikipedia.org/wiki/Total_variation_denoising

    The principle of total variation denoising is to minimize the
    total variation of the image, which can be roughly described as
    the integral of the norm of the image gradient. Total variation
    denoising tends to produce "cartoon-like" images, that is,
    piecewise-constant images.

    This code is an implementation of the algorithm of Rudin, Fatemi and Osher
    that was proposed by Chambolle in [1]_.

    References
    ----------
    .. [1] A. Chambolle, An algorithm for total variation minimization and
           applications, Journal of Mathematical Imaging and Vision,
           Springer, 2004, 20, 89-97.

    Examples
    --------
    2D example on astronaut image:

    >>> from skimage import color, data
    >>> img = color.rgb2gray(data.astronaut())[:50, :50]
    >>> img += 0.5 * img.std() * np.random.randn(*img.shape)
    >>> denoised_img = denoise_tv_chambolle(img, weight=60)

    3D example on synthetic data:

    >>> x, y, z = np.ogrid[0:20, 0:20, 0:20]
    >>> mask = (x - 22)**2 + (y - 20)**2 + (z - 17)**2 < 8**2
    >>> mask = mask.astype(np.float)
    >>> mask += 0.2*np.random.randn(*mask.shape)
    >>> res = denoise_tv_chambolle(mask, weight=100)

    t   fiÿÿÿÿ.(   R   t   kindR   R    R"   R%   R   R<   (   R   R   R   R-   R   t   im_typeR5   t   c(    (    s;   lib/python2.7/site-packages/skimage/restoration/_denoise.pyt   denoise_tv_chambolleù   s    H	c         C   sL   t  j |  |  ƒ } t  j |  j ƒ j } | t  j t | | | ƒ ƒ } | S(   s:   BayesShrink threshold for a zero-mean details coeff array.(   R    t   meant   finfoR   R   R(   R   (   t   detailst   vart   dvarR   t   thresh(    (    s;   lib/python2.7/site-packages/skimage/restoration/_denoise.pyt   _bayes_threshO  s     c         C   s!   | t  j d t  j |  j ƒ ƒ S(   s3    Universal threshold used by the VisuShrink method i   (   R    R(   t   logR+   (   t   imgt   sigma(    (    s;   lib/python2.7/site-packages/skimage/restoration/_denoise.pyt   _universal_threshX  s    t   Gaussianc         C   si   |  t  j |  ƒ }  | j ƒ  d k rY t j j j d ƒ } t  j t  j |  ƒ ƒ | } n t	 d ƒ ‚ | S(   sj  Calculate the robust median estimator of the noise standard deviation.

    Parameters
    ----------
    detail_coeffs : ndarray
        The detail coefficients corresponding to the discrete wavelet
        transform of an image.
    distribution : str
        The underlying noise distribution.

    Returns
    -------
    sigma : float
        The estimated noise standard deviation (see section 4.2 of [1]_).

    References
    ----------
    .. [1] D. L. Donoho and I. M. Johnstone. "Ideal spatial adaptation
       by wavelet shrinkage." Biometrika 81.3 (1994): 425-455.
       DOI:10.1093/biomet/81.3.425
    t   gaussiang      è?s5   Only Gaussian noise estimation is currently supported(
   R    t   nonzerot   lowert   scipyt   statsR8   t   ppft   medianR,   R
   (   t   detail_coeffst   distributiont   denomRK   (    (    s;   lib/python2.7/site-packages/skimage/restoration/_denoise.pyt   _sigma_est_dwt]  s    t   softc            sS  t  j | ƒ } t d „  |  j Dƒ ƒ } | d k r„ | j } t j g  |  j D] }	 t  j |	 | ƒ ^ qM ƒ } t	 | d d ƒ } n  t  j
 |  d | d | ƒ}
 |
 d } | d k rß | d d |  j } t | d d	 ƒ} n  | d k	 rˆ d k	 rt d
 j | ƒ ƒ n  ˆ d k r¯| d ‰ | d k r>t d ƒ ‚ q¯| d k ryg  | D] ‰  ‡  ‡ f d †  ˆ  Dƒ ^ qQ‰ q¯| d k r—t |  | ƒ ‰ q¯t d j | ƒ ƒ ‚ n  t j ˆ ƒ rðg  | D]" ‰  ‡  ‡ ‡ f d †  ˆ  Dƒ ^ qÅ} n> g  t ˆ | ƒ D]( \ ‰ ‰  ‡  ‡ ‡ f d †  ˆ  Dƒ ^ q } |
 d g | } t  j | | ƒ | S(   sQ  Perform wavelet thresholding.

    Parameters
    ----------
    image : ndarray (2d or 3d) of ints, uints or floats
        Input data to be denoised. `image` can be of any numeric type,
        but it is cast into an ndarray of floats for the computation
        of the denoised image.
    wavelet : string
        The type of wavelet to perform. Can be any of the options
        pywt.wavelist outputs. For example, this may be any of ``{db1, db2,
        db3, db4, haar}``.
    method : {'BayesShrink', 'VisuShrink'}, optional
        Thresholding method to be used. The currently supported methods are
        "BayesShrink" [1]_ and "VisuShrink" [2]_. If it is set to None, a
        user-specified ``threshold`` must be supplied instead.
    threshold : float, optional
        The thresholding value to apply during wavelet coefficient
        thresholding. The default value (None) uses the selected ``method`` to
        estimate appropriate threshold(s) for noise removal.
    sigma : float, optional
        The standard deviation of the noise. The noise is estimated when sigma
        is None (the default) by the method in [2]_.
    mode : {'soft', 'hard'}, optional
        An optional argument to choose the type of denoising performed. It
        noted that choosing soft thresholding given additive noise finds the
        best approximation of the original image.
    wavelet_levels : int or None, optional
        The number of wavelet decomposition levels to use.  The default is
        three less than the maximum number of possible decomposition levels
        (see Notes below).

    Returns
    -------
    out : ndarray
        Denoised image.

    References
    ----------
    .. [1] Chang, S. Grace, Bin Yu, and Martin Vetterli. "Adaptive wavelet
           thresholding for image denoising and compression." Image Processing,
           IEEE Transactions on 9.9 (2000): 1532-1546.
           DOI: 10.1109/83.862633
    .. [2] D. L. Donoho and I. M. Johnstone. "Ideal spatial adaptation
           by wavelet shrinkage." Biometrika 81.3 (1994): 425-455.
           DOI: 10.1093/biomet/81.3.425

    c         s   s   |  ] } t  | ƒ Vq d  S(   N(   R$   (   t   .0t   s(    (    s;   lib/python2.7/site-packages/skimage/restoration/_denoise.pys	   <genexpr>¶  s    i   i   t   wavelett   leveliÿÿÿÿR0   RV   RM   sO   Thresholding method {} selected.  The user-specified threshold will be ignored.i   s0   If method is None, a threshold must be provided.t   BayesShrinkc            s&   i  |  ] } t  ˆ  | ˆ ƒ | “ q S(    (   RH   (   RZ   t   key(   R]   RE   (    s;   lib/python2.7/site-packages/skimage/restoration/_denoise.pys
   <dictcomp>Ö  s   	 t
   VisuShrinks   Unrecognized method: {}c            s2   i  |  ]( } t  j ˆ  | d  ˆ d ˆ ƒ| “ q S(   t   valueR   (   t   pywtt	   threshold(   RZ   R_   (   R]   R   Rc   (    s;   lib/python2.7/site-packages/skimage/restoration/_denoise.pys
   <dictcomp>à  s   	c            s6   i  |  ], } t  j ˆ  | d  ˆ | d ˆ ƒ| “ q S(   Ra   R   (   Rb   Rc   (   RZ   R_   (   R]   R   RG   (    s;   lib/python2.7/site-packages/skimage/restoration/_denoise.pys
   <dictcomp>æ  s   	i    N(   Rb   t   WaveletR&   R   R   t   dec_lenR    t   mint   dwt_max_levelR   t   wavedecnR	   RX   R   R   R
   RL   t   isscalart   zipt   waverecn(   R   R\   t   methodRc   RK   R   t   wavelet_levelst   original_extentt   dlenR[   t   coeffst   dcoeffsRU   t   denoised_detailt   denoised_coeffs(    (   R]   R   RG   Rc   RE   s;   lib/python2.7/site-packages/skimage/restoration/_denoise.pyt   _wavelet_threshold€  sB    2	+
	
,/;t   db1R^   c         C   s;  | d k r$ t  d j | ƒ ƒ ‚ n  t |  ƒ }  | rn t | t j ƒ sT | d k rn | g |  j d } qn n  | rã| rqt j	 |  ƒ } xÓ t
 d ƒ D]Å }	 | d |	 f j ƒ  | d |	 f j ƒ  }
 } | d |	 f |
 } | | |
 :} t | d | d | d	 | |	 d
 | d | ƒ| d |	 f <| d |	 f | |
 | d |	 f <| d |	 f c |
 7<q– Wt j | ƒ } qt j |  ƒ } xŠ t
 |  j d ƒ D]H } t |  d | f d | d | d	 | | d
 | d | ƒ| d | f <q”Wn* t |  d | d | d	 | d
 | d | ƒ} |  j ƒ  d k  r%d n d } t j | | Œ S(   sÍ  Perform wavelet denoising on an image.

    Parameters
    ----------
    image : ndarray ([M[, N[, ...P]][, C]) of ints, uints or floats
        Input data to be denoised. `image` can be of any numeric type,
        but it is cast into an ndarray of floats for the computation
        of the denoised image.
    sigma : float or list, optional
        The noise standard deviation used when computing the wavelet detail
        coefficient threshold(s). When None (default), the noise standard
        deviation is estimated via the method in [2]_.
    wavelet : string, optional
        The type of wavelet to perform and can be any of the options
        ``pywt.wavelist`` outputs. The default is `'db1'`. For example,
        ``wavelet`` can be any of ``{'db2', 'haar', 'sym9'}`` and many more.
    mode : {'soft', 'hard'}, optional
        An optional argument to choose the type of denoising performed. It
        noted that choosing soft thresholding given additive noise finds the
        best approximation of the original image.
    wavelet_levels : int or None, optional
        The number of wavelet decomposition levels to use.  The default is
        three less than the maximum number of possible decomposition levels.
    multichannel : bool, optional
        Apply wavelet denoising separately for each channel (where channels
        correspond to the final axis of the array).
    convert2ycbcr : bool, optional
        If True and multichannel True, do the wavelet denoising in the YCbCr
        colorspace instead of the RGB color space. This typically results in
        better performance for RGB images.
    method : {'BayesShrink', 'VisuShrink'}, optional
        Thresholding method to be used. The currently supported methods are
        "BayesShrink" [1]_ and "VisuShrink" [2]_. Defaults to "BayesShrink".

    Returns
    -------
    out : ndarray
        Denoised image.

    Notes
    -----
    The wavelet domain is a sparse representation of the image, and can be
    thought of similarly to the frequency domain of the Fourier transform.
    Sparse representations have most values zero or near-zero and truly random
    noise is (usually) represented by many small values in the wavelet domain.
    Setting all values below some threshold to 0 reduces the noise in the
    image, but larger thresholds also decrease the detail present in the image.

    If the input is 3D, this function performs wavelet denoising on each color
    plane separately. The output image is clipped between either [-1, 1] and
    [0, 1] depending on the input image range.

    When YCbCr conversion is done, every color channel is scaled between 0
    and 1, and `sigma` values are applied to these scaled color channels.

    Many wavelet coefficient thresholding approaches have been proposed.  By
    default, ``denoise_wavelet`` applies BayesShrink, which is an adaptive
    thresholding method that computes separate thresholds for each wavelet
    sub-band as described in [1]_.

    If ``method == "VisuShrink"``, a single "universal threshold" is applied to
    all wavelet detail coefficients as described in [2]_.  This threshold
    is designed to remove all Gaussian noise at a given ``sigma`` with high
    probability, but tends to produce images that appear overly smooth.

    References
    ----------
    .. [1] Chang, S. Grace, Bin Yu, and Martin Vetterli. "Adaptive wavelet
           thresholding for image denoising and compression." Image Processing,
           IEEE Transactions on 9.9 (2000): 1532-1546.
           DOI: 10.1109/83.862633
    .. [2] D. L. Donoho and I. M. Johnstone. "Ideal spatial adaptation
           by wavelet shrinkage." Biometrika 81.3 (1994): 425-455.
           DOI: 10.1093/biomet/81.3.425

    Examples
    --------
    >>> from skimage import color, data
    >>> img = img_as_float(data.astronaut())
    >>> img = color.rgb2gray(img)
    >>> img += 0.1 * np.random.randn(*img.shape)
    >>> img = np.clip(img, 0, 1)
    >>> denoised_img = denoise_wavelet(img, sigma=0.1)

    R^   R`   sV   Invalid method: {}. The currently supported methods are "BayesShrink" and "VisuShrink"iÿÿÿÿi   .R\   Rl   RK   R   Rm   i    i   (   R^   R`   N(   iÿÿÿÿi   (   i    i   (   R
   R   R   t
   isinstancet   numberst   NumberR   R   t   colort	   rgb2ycbcrR%   Rf   R   t   denoise_wavelett	   ycbcr2rgbR    t
   empty_likeRt   t   clip(   R   RK   R\   R   Rm   R   t   convert2ycbcrRl   R5   R1   Rf   R   t   channelR@   t
   clip_range(    (    s;   lib/python2.7/site-packages/skimage/restoration/_denoise.pyR{   î  sD    X-"	c   	      C   sÐ   | rd |  j  d } g  t | ƒ D]" } t |  d | f d t ƒ^ q  } | r` t j | ƒ } n  | S|  j  d d k rš d } t | j |  j  d ƒ ƒ n  t j	 |  d d ƒ} | d |  j
 } t | d	 d
 ƒS(   sË  
    Robust wavelet-based estimator of the (Gaussian) noise standard deviation.

    Parameters
    ----------
    image : ndarray
        Image for which to estimate the noise standard deviation.
    average_sigmas : bool, optional
        If true, average the channel estimates of `sigma`.  Otherwise return
        a list of sigmas corresponding to each channel.
    multichannel : bool
        Estimate sigma separately for each channel.

    Returns
    -------
    sigma : float or list
        Estimated noise standard deviation(s).  If `multichannel` is True and
        `average_sigmas` is False, a separate noise estimate for each channel
        is returned.  Otherwise, the average of the individual channel
        estimates is returned.

    Notes
    -----
    This function assumes the noise follows a Gaussian distribution. The
    estimation algorithm is based on the median absolute deviation of the
    wavelet detail coefficients as described in section 4.2 of [1]_.

    References
    ----------
    .. [1] D. L. Donoho and I. M. Johnstone. "Ideal spatial adaptation
       by wavelet shrinkage." Biometrika 81.3 (1994): 425-455.
       DOI:10.1093/biomet/81.3.425

    Examples
    --------
    >>> import skimage.data
    >>> from skimage import img_as_float
    >>> img = img_as_float(skimage.data.camera())
    >>> sigma = 0.1
    >>> img = img + sigma * np.random.standard_normal(img.shape)
    >>> sigma_hat = estimate_sigma(img, multichannel=False)
    iÿÿÿÿ.R   i   s–   image is size {0} on the last axis, but multichannel is False.  If this is a color image, please set multichannel to True for proper noise estimation.R\   t   db2R0   RV   RM   (   R   R%   t   estimate_sigmat   FalseR    RB   R   R   Rb   t   dwtnR	   RX   (	   R   t   average_sigmasR   t	   nchannelsR@   t   sigmasR   Rp   RU   (    (    s;   lib/python2.7/site-packages/skimage/restoration/_denoise.pyRƒ   r  s    +2(   t   scipy.statsRQ   t   numpyR    t   mathR    t    R   t   restoration._denoise_cyR   R   t   _shared.utilsR   R   Rb   t   skimage.colorRy   Rw   R   R   R   R   R<   R„   RA   RH   RL   RX   Rt   R{   Rƒ   (    (    (    s;   lib/python2.7/site-packages/skimage/restoration/_denoise.pyt   <module>   s.   	j/R	U			#m	‚