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_classes polygonal 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]\); with n_channels > 1 every class gets a random color vector in \([0,1]^C\). The noisy copy is produced by add_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:
shapetuple (H, W), default=(128, 128)
n_classesint, default=4
n_channelsint, default=1
noise{“gaussian”, “salt_pepper”, “both”, “none”}, default=”gaussian”
noise_levelfloat, default=0.1
random_stateint, RandomState instance or None
Returns:
datasklearn.utils.Bunch

image – the noisy image (H, W) or (H, W, C); clean – the noise-free image; truth – label image (H, W) with values 0..n_classes-1; levels – the class values (n_classes,) or (n_classes, C).

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

Image segmentation under noise: six spatially constrained FCM variants

Spatial FCM: the neighborhood weight and the window size

Spatial FCM: the neighborhood weight and the window size