ó
 ‰\c           @   s8   d  d l  Z d d l m Z d d d d d d „ Z d S(   iÿÿÿÿNi   (   t   gaussiani   gš™™™™™¹?g      à?c         C   sÔ   t  j j | ƒ } t |  g | ƒ } t  j | ƒ } t t d | ƒ | d ƒ } |  | j | | ƒ j t  j ƒ }	 d | t d „  |	 Dƒ ƒ <t	 | d d |  | ƒ} t  j
 | d d | ƒ }
 t  j | |
 k  ƒ S(   s¦  
    Generate synthetic binary image with several rounded blob-like objects.

    Parameters
    ----------
    length : int, optional
        Linear size of output image.
    blob_size_fraction : float, optional
        Typical linear size of blob, as a fraction of ``length``, should be
        smaller than 1.
    n_dim : int, optional
        Number of dimensions of output image.
    volume_fraction : float, default 0.5
        Fraction of image pixels covered by the blobs (where the output is 1).
        Should be in [0, 1].
    seed : int, optional
        Seed to initialize the random number generator.
        If `None`, a random seed from the operating system is used.

    Returns
    -------
    blobs : ndarray of bools
        Output binary image

    Examples
    --------
    >>> from skimage import data
    >>> data.binary_blobs(length=5, blob_size_fraction=0.2, seed=1)
    array([[ True, False,  True,  True,  True],
           [ True,  True,  True, False,  True],
           [False,  True, False,  True,  True],
           [ True, False, False,  True,  True],
           [ True, False, False, False,  True]], dtype=bool)
    >>> blobs = data.binary_blobs(length=256, blob_size_fraction=0.1)
    >>> # Finer structures
    >>> blobs = data.binary_blobs(length=256, blob_size_fraction=0.05)
    >>> # Blobs cover a smaller volume fraction of the image
    >>> blobs = data.binary_blobs(length=256, volume_fraction=0.3)
    g      ð?i   c         s   s   |  ] } | Vq d  S(   N(    (   t   .0t   indices(    (    s9   lib/python2.7/site-packages/skimage/data/_binary_blobs.pys	   <genexpr>3   s    t   sigmag      Ð?id   (   t   npt   randomt   RandomStatet   tuplet   zerost   maxt   intt   randt   astypeR    t
   percentilet   logical_not(   t   lengtht   blob_size_fractiont   n_dimt   volume_fractiont   seedt   rst   shapet   maskt   n_ptst   pointst	   threshold(    (    s9   lib/python2.7/site-packages/skimage/data/_binary_blobs.pyt   binary_blobs   s    )"(   t   numpyR   t   filtersR    t   NoneR   (    (    (    s9   lib/python2.7/site-packages/skimage/data/_binary_blobs.pyt   <module>   s   	