darsia.segment#

segment(img, markers_method='gradient_based', edges_method='gradient_based', mask=None, verbosity=False, **kwargs)[source]#

Segment an image using watershed segmentation, with denoising.

Parameters:
imgnumpy.ndarray or darsia.Image

Input image in RGB colour space.

markers_methodstr, optional

"gradient_based" (less input required) or "supervised" (lets you address regions of interest explicitly). Default "gradient_based".

edges_methodstr, optional

"gradient_based" (gradient filtering) or "scharr" (Scharr algorithm). Default "gradient_based".

masknumpy.ndarray, optional

Binary array; segmentation is performed only where it is true.

verbositybool, optional

Plot intermediate quantities, useful when tuning parameters. Default False.

**kwargs

Tuning parameters for the watershed:

  • "method" (str) – "median" or "tvd" (anisotropic TVD with fixed settings).

  • "median disk radius" (int) – rank-median smoothing radius applied before analysis.

  • "rescaling factor" (float) – image scaling before the watershed.

  • "monochromatic_color" (str) – "gray", "red", "green", "blue" or "value"; default "gray".

  • "boundaries" (list of str) – any of "top", "bottom", "right", "left"; omitted in the cleaning routine.

Returns:
numpy.ndarray or darsia.Image

Labelled regions, in the same format as img.