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:
SpatialFCM– one estimator, variants chosen bymethod:"fcm_s"(Ahmed et al. 2002),"fcm_s1"/"fcm_s2"(Chen and Zhang 2004),"enfcm"(Szilágyi et al. 2003),"fgfcm"(Cai, Chen and Zhang 2007),"flicm"(Krinidis and Chatzis 2010) and plain"fcm"as the reference;neighborhood_sum(),weighted_sum_image(),local_similarity_image()– the neighborhood operations behind them (built onscipy.ndimage, no OpenCV or scikit-image needed);make_synthetic_image(),add_image_noise()– test images with known labels;segmentation_accuracy(),match_labels()– evaluation;plot_segmentation(),plot_image(),plot_label_image(),plot_membership_maps()– matplotlib helpers.
Spatially constrained FCM: FCM_S, FCM_S1/S2, EnFCM, FGFCM, FLICM.
Classes#
|
Spatially constrained fuzzy c-means for image segmentation. |
Functions#
|
Sum of an image over the neighbors of every pixel, \(\sum_{r\in N_k} y_r\) (center excluded). |
|
Linearly weighted sum image of EnFCM. |
|
Locally adaptive weighted image of FGFCM, \(\xi_k=\sum_{r\in N_k}S_{kr}x_r/\sum_{r}S_{kr}\). |
|
A piecewise-constant image of simple shapes with known labels, plus a noisy copy. |
|
Corrupt an image with Gaussian, salt-and-pepper or both kinds of noise. |
|
Fraction of correctly labeled pixels after the best matching of the labels. |
|
Best one-to-one mapping of predicted labels onto true labels (Hungarian algorithm). |
|
Panels original / noisy / labels / membership maps of a fitted |
|
Show a gray-level or RGB image without axes ticks. |
|
Show a label image with the fixed cluster palette (cluster i in color i). |
|
One panel per cluster with its membership image in |
Constants#
Built-in immutable sequence. |