connected_component_stats#

rlemasklib.RLEMask.connected_component_stats(connectivity=4, min_size=1)[source][C source]#

Get statistics for all connected components without extracting them.

This is faster than extracting all components when you only need the stats.

Parameters:
  • connectivity (int) – 4 or 8, the connectivity of the components.

  • min_size (int) – the minimum size of a component to return.

Returns:

A tuple of (areas, bboxes, centroids) numpy arrays, or None if there are no components. areas is shape (n,), bboxes is shape (n, 4) with columns (x, y, w, h), centroids is shape (n, 2) with columns (x, y).

Return type:

Optional[tuple[ndarray, ndarray, ndarray]]