fuzzyclust.image#

Fuzzy c-means for image segmentation with spatial constraints.

An image is a data set with a twist: the samples (pixels) have neighbors, and neighboring pixels almost always belong to the same region. Pixel-wise fuzzy c-means ignores this and labels every noisy pixel on its own. This sub-package collects the classical ways of putting the neighborhood into the c-means functional:

Spatially constrained FCM: FCM_S, FCM_S1/S2, EnFCM, FGFCM, FLICM.

Classes#

SpatialFCM([n_clusters, method, m, alpha, ...])

Spatially constrained fuzzy c-means for image segmentation.

Functions#

neighborhood_sum(img[, window_size, kernel])

Sum of an image over the neighbors of every pixel, \(\sum_{r\in N_k} y_r\) (center excluded).

weighted_sum_image(img[, alpha, window_size])

Linearly weighted sum image of EnFCM.

local_similarity_image(img[, lambda_s, ...])

Locally adaptive weighted image of FGFCM, \(\xi_k=\sum_{r\in N_k}S_{kr}x_r/\sum_{r}S_{kr}\).

make_synthetic_image([shape, n_classes, ...])

A piecewise-constant image of simple shapes with known labels, plus a noisy copy.

add_image_noise(image[, noise, noise_level, ...])

Corrupt an image with Gaussian, salt-and-pepper or both kinds of noise.

segmentation_accuracy(y_true, y_pred)

Fraction of correctly labeled pixels after the best matching of the labels.

match_labels(y_true, y_pred)

Best one-to-one mapping of predicted labels onto true labels (Hungarian algorithm).

plot_segmentation(model, image[, clean, ...])

Panels original / noisy / labels / membership maps of a fitted SpatialFCM.

plot_image(image[, ax, title, cmap, vmin, vmax])

Show a gray-level or RGB image without axes ticks.

plot_label_image(labels[, ax, title, ...])

Show a label image with the fixed cluster palette (cluster i in color i).

plot_membership_maps(membership[, axes, ...])

One panel per cluster with its membership image in [0, 1].

Constants#

METHODS

Built-in immutable sequence.