skimage2.data#
Warning
This module is part of the experimental skimage2 namespace and is subject to change without notice.
Do not use it in production code.
See the migration guide for more details.
Example images and datasets.
A curated set of general-purpose and scientific images used in tests, examples, and documentation. Also includes functionality to generate synthetic data.
Generate synthetic binary image containing blob-like objects. |
- 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 of blob in pixels. Values smaller than 1 may lead to unexpected results.
- volume_fractionfloat, in interval [0, 1], optional
Fraction of image pixels covered by the blobs.
- 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 ... )