fuzzyclust.image.make_synthetic_image#
- fuzzyclust.image.make_synthetic_image(shape=(128, 128), n_classes=4, n_channels=1, noise='gaussian', noise_level=0.1, random_state=None)[source]#
A piecewise-constant image of simple shapes with known labels, plus a noisy copy.
The image is tiled into
n_classespolygonal regions (the Voronoi cells of seed points spread over the image by farthest-point sampling, so the regions have comparable areas and straight edges), and every class additionally owns one disc placed inside another class’s cell (curved edges and small isolated regions). Gray levels are equally spaced in \([0,1]\); withn_channels > 1every class gets a random color vector in \([0,1]^C\). The noisy copy is produced byadd_image_noise(). Spatially unaware pixel clustering fails on such an image as soon as the noise is comparable to the gap between the gray levels, which is exactly what the spatially constrained methods are made for.- Parameters:
- Returns:
- data
sklearn.utils.Bunch image– the noisy image(H, W)or(H, W, C);clean– the noise-free image;truth– label image(H, W)with values0..n_classes-1;levels– the class values(n_classes,)or(n_classes, C).
- data
Examples
>>> from fuzzyclust.image import make_synthetic_image >>> data = make_synthetic_image(shape=(64, 64), n_classes=3, random_state=0) >>> data.image.shape, data.truth.shape, sorted(set(data.truth.ravel().tolist())) ((64, 64), (64, 64), [0, 1, 2])
Examples using fuzzyclust.image.make_synthetic_image#
Image segmentation under noise: six spatially constrained FCM variants
Spatial FCM: the neighborhood weight and the window size