darsia.extract_characteristic_data#

extract_characteristic_data(signal, mask=None, samples=None, filter=<function <lambda>>, num_clusters=5, num_attempts=100, num_iterations=200, eps=0.1, mode='most_common', show_plot=False)[source]#

Extract representative colours from an image for given patches.

Parameters:
signalnumpy.ndarray or darsia.Image

Input signal, assumed to be a 2d colour image.

masknumpy.ndarray or darsia.Image, optional

Boolean array flagging pixels of interest; by default all pixels.

sampleslist of slices, optional

2d regions of interest; None means the full region.

filtercallable(), optional

Preprocessing applied to the signal before analysis (e.g. a Gaussian filter). Default: identity.

num_clustersint, optional

Number of clusters to extract. Default 5.

num_attemptsint, optional

Number of attempts to find the best clusters. Default 100.

num_iterationsint, optional

Maximum iterations of the iterative procedure. Default 200.

epsfloat, optional

Stopping tolerance for the iterative procedure. Default 0.1.

mode{“most_common”, “least_common”, “all”}, optional

What to return. Default "most_common".

show_plotbool, optional

Display plots. Default False.

Returns:
numpy.ndarray or tuple of numpy.ndarray

Characteristic colours for the chosen samples when mode is "most_common" / "least_common"; a (labels, palettes) tuple when mode is "all".