U
    ?h	                     @   s@   d dl ZddlmZ ddlmZ eddiddd	dddZdS )    N   )deprecate_kwarg)gaussianseedrngz0.21z0.23)Zdeprecated_versionZremoved_version   皙?      ?c                 C   s   t j|}t| g| }t |}ttd| | d}| |||f t}	d|tdd |	D < t|d|  | dd}t 	|dd|  }
t 
||
k S )	a   
    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].
    rng : {`numpy.random.Generator`, int}, optional
        Pseudo-random number generator.
        By default, a PCG64 generator is used (see :func:`numpy.random.default_rng`).
        If `rng` is an int, it is used to seed the generator.

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

    Examples
    --------
    >>> from skimage import data
    >>> data.binary_blobs(length=5, blob_size_fraction=0.2)  # doctest: +SKIP
    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]])
    >>> 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      ?   c                 s   s   | ]
}|V  qd S )N ).0indicesr   r   L/var/www/html/venv/lib/python3.8/site-packages/skimage/data/_binary_blobs.py	<genexpr><   s     zbinary_blobs.<locals>.<genexpr>g      ?F)sigmaZpreserve_ranged   )nprandomZdefault_rngtupleZzerosmaxintZastyper   Z
percentileZlogical_not)lengthZblob_size_fractionZn_dimZvolume_fractionr   rsshapemaskZn_ptsZpoints	thresholdr   r   r   binary_blobs   s    0
r   )r   r   r   r	   N)numpyr   Z_shared.utilsr   Z_shared.filtersr   r   r   r   r   r   <module>   s   
    