
    79j                     8    d dl Z d dlZddlmZ 	 	 	 	 	 ddddZy)    N   )gaussiannearest)boundary_modec                t   |dvrt        d|      || z  }|dk  r8d| z  }|| z  }t        j                  d|d| d| d| d| d	t        d
       |}t        j
                  j                  |      }	t        | g|z        }
t	        j                  |
      }t        t        d|z        |z  d      }| |	j                  ||f      z  j                  t              }d|t        d |D              <   t        |d| z  |z  d|      }t	        j                  |dd|z
  z        }t	        j                  ||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.
    boundary_mode : {'nearest', 'wrap'}, optional
        The blobs are created by smoothing and then thresholding an
        array consisting of ones at seed positions. This mode determines which values are
        filled in when the smoothing kernel overlaps the seed array's boundary.

        'nearest' (`a a a a | a b c d | d d d d`)
            By default, when applying the Gaussian filter, the seed array is extended by replicating the last
            boundary value. This will increase the size of blobs whose seed or
            center lies exactly on the edge.

        'wrap' (`a b c d | a b c d | a b c d`)
            The seed array is extended by wrapping around to the opposite edge.
            The resulting blob array can be tiled and blobs will be contiguous and
            have smooth edges across tile boundaries.

    boundary_mode : str, default "nearest"
        The `mode` parameter passed to the Gaussian filter.
        Use "wrap" for periodic boundary conditions.

    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)
    >   wrapr   zunsupported `boundary_mode`: 皙?z`blob_size_fraction=z` together with `length=z!` would result in a blob size of z] pixels. Small blob sizes likely lead to unexpected results! Clamping to `blob_size_fraction=z` and a blob size of z- pixels to avoid allocating excessive memory.r   )category
stacklevelg      ?   c              3       K   | ]  }|  y w)N ).0indicess     Z/media/conek/DATA/Code/OCR/venv/lib/python3.12/site-packages/skimage/data/_binary_blobs.py	<genexpr>zbinary_blobs.<locals>.<genexpr>b   s     -7w-s   g      ?F)sigmapreserve_rangemoded   )
ValueErrorwarningswarnRuntimeWarningnprandomdefault_rngtuplezerosmaxintastyper   
percentilelogical_not)lengthblob_size_fractionn_dimvolume_fractionrngr   	blob_sizeclamped_size_fractionclamped_blob_sizersshapemaskn_ptspoints	thresholds                  r   binary_blobsr3      ss   F //88IJKK"V+I3 #f1F:#"$$=fY ? k "//D.E F#$$Q	S
 $	
 3			s	#B6(U"#E88E?DC,,-6:Eryy%0088=F12D-f-	-.Vm00	D dC1+>$?@I>>$*++    )i   r	   r   g      ?N)r   numpyr   _shared.filtersr   r3   r   r4   r   <module>r7      s0      & 
b, b,r4   