Function connected_components_with_algorithm

Source
pub fn connected_components_with_algorithm(
    image: &impl ToInputArray,
    labels: &mut impl ToOutputArray,
    connectivity: i32,
    ltype: i32,
    ccltype: i32,
) -> Result<i32>
Expand description

computes the connected components labeled image of boolean image

image with 4 or 8 way connectivity - returns N, the total number of labels [0, N-1] where 0 represents the background label. ltype specifies the output label image type, an important consideration based on the total number of labels or alternatively the total number of pixels in the source image. ccltype specifies the connected components labeling algorithm to use, currently Bolelli (Spaghetti) Bolelli2019, Grana (BBDT) Grana2010 and Wu’s (SAUF) Wu2009 algorithms are supported, see the [connected_components_algorithms_types] for details. Note that SAUF algorithm forces a row major ordering of labels while Spaghetti and BBDT do not. This function uses parallel version of the algorithms if at least one allowed parallel framework is enabled and if the rows of the image are at least twice the number returned by #getNumberOfCPUs.

§Parameters

  • image: the 8-bit single-channel image to be labeled
  • labels: destination labeled image
  • connectivity: 8 or 4 for 8-way or 4-way connectivity respectively
  • ltype: output image label type. Currently CV_32S and CV_16U are supported.
  • ccltype: connected components algorithm type (see the #ConnectedComponentsAlgorithmsTypes).