canny#

Canny edge-detector.

DEFAULT_DIMS: list[Hashable] = ['lat', 'lon']#

Default dimensions names.

Used for Xarray input where the dims argument is None and window_size is not a Mapping.

canny_core(image, hysteresis=True, low_threshold=None, high_threshold=None, use_quantiles=False)#

Canny edge-detector.

Copied from skimage.feature.canny().

Warning

Internal function.

Users should rather use canny_numpy().

Parameters:
Return type:

ndarray[tuple[int, int], dtype[bool]]

canny_dask(input_field, hysteresis=True, low_threshold=None, high_threshold=None, use_quantiles=False, axes=None)#

Apply Canny Edge Detector.

Important

Omits the gaussian filter.

Parameters:
  • input_field (Array) – Array of the input field.

  • hysteresis (bool) – If True (default), apply double-thresholding/hysteresis: weak edges are kept only if they are connected to a strong edge. If not, return both weak and strong edges.

  • low_threshold (float | None) – Lower bound for hysteresis thresholding (linking edges). If None, low_threshold is set to 10% of dtype’s max.

  • high_threshold (float | None) – Upper bound for hysteresis thresholding (linking edges). If None, high_threshold is set to 20% of dtype’s max.

  • use_quantiles (bool) – If True then treat low_threshold and high_threshold as quantiles of the edge magnitude image, rather than absolute edge magnitude values. If True then the thresholds must be in the range [0, 1].

  • axes (Sequence[int] | None) – Indices of the the y/lat and x/lon axes on which to work. If None (default), the last two axes are used.

Return type:

Array

canny_numpy(input_field, hysteresis=True, low_threshold=None, high_threshold=None, use_quantiles=False, axes=None)#

Apply Canny Edge Detector.

Important

Omits the gaussian filter.

Parameters:
  • input_field (ndarray[_Size, dtype[Any]]) – Array of the input field.

  • hysteresis (bool) – If True (default), apply double-thresholding/hysteresis: weak edges are kept only if they are connected to a strong edge. If not, return both weak and strong edges.

  • low_threshold (float | None) – Lower bound for hysteresis thresholding (linking edges). If None, low_threshold is set to 10% of dtype’s max.

  • high_threshold (float | None) – Upper bound for hysteresis thresholding (linking edges). If None, high_threshold is set to 20% of dtype’s max.

  • use_quantiles (bool) – If True then treat low_threshold and high_threshold as quantiles of the edge magnitude image, rather than absolute edge magnitude values. If True then the thresholds must be in the range [0, 1].

  • axes (Sequence[int] | None) – Indices of the the y/lat and x/lon axes on which to work. If None (default), the last two axes are used.

Return type:

ndarray[_Size, dtype[bool]]

canny_xarray(input_field, hysteresis=True, low_threshold=None, high_threshold=None, use_quantiles=False, dims=None)#

Apply Canny Edge Detector.

Important

Omits the gaussian filter.

Parameters:
  • input_field (DataArray) – Array of the input field.

  • hysteresis (bool) – If True (default), apply double-thresholding/hysteresis: weak edges are kept only if they are connected to a strong edge. If not, return both weak and strong edges.

  • low_threshold (float | None) – Lower bound for hysteresis thresholding (linking edges). If None, low_threshold is set to 10% of dtype’s max.

  • high_threshold (float | None) – Upper bound for hysteresis thresholding (linking edges). If None, high_threshold is set to 20% of dtype’s max.

  • use_quantiles (bool) – If True then treat low_threshold and high_threshold as quantiles of the edge magnitude image, rather than absolute edge magnitude values. If True then the thresholds must be in the range [0, 1].

  • dims (Collection[Hashable] | None) – Names of the dimensions along which to apply the algorithm. Order is irrelevant, no reordering will be made between the two dimensions. If the window_size argument is given as a mapping, its keys are used instead. If not specified, is taken as module-wide variable DEFAULT_DIMS which defaults to {'lat', 'lon'}.

Return type:

DataArray