skimage2.data.binary_blobs#
- skimage2.data.binary_blobs(shape, blob_size, *, volume_fraction=0.5, rng=None, boundary_mode='wrap')[source]#
Generate synthetic binary image containing blob-like objects.
- Parameters:
- shapetuple of (int, âĶ)
Shape of the output image.
- blob_sizefloat
Typical linear size (diameter) of blobs in pixels. Values smaller than 1 or larger than any length in
shapemay lead to unexpected results. The actual size is also affected byvolume_fraction.- volume_fractionfloat, in interval [0, 1], optional
Fraction of image pixels covered by the blobs. Blobs shrink with smaller fractions, and grow and merge together with larger fractions.
- rngint or
numpy.random.Generator, optional Pseudo-random number generator. By default, a PCG64 generator is used (see
numpy.random.default_rng()). Ifrngis an int, it is used to seed the generator.- boundary_mode{âwrapâ, ânearestâ}, 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.
- âwrapâ (
a b c d | a b c d | a b c d) By default, 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.
- ânearestâ (
a a a a | a b c d | d d d d) 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â (
- Returns:
- blobsndarray of dtype bool
Output binary image.
Examples
>>> import _skimage2 as ski2 >>> ski2.data.binary_blobs(shape=(5, 5), blob_size=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]]) >>> blobs = ski2.data.binary_blobs(shape=(256, 256), blob_size=25) >>> # Finer structures >>> blobs = ski2.data.binary_blobs(shape=(256, 256), blob_size=13) >>> # Blobs cover a smaller volume fraction of the image >>> blobs = ski2.data.binary_blobs( ... shape=(256, 256), blob_size=25, volume_fraction=0.3 ... )