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

Computes the Connected Components Labeled image of a binary image.

The function takes as input a binary image and performs Connected Components Labeling. The output is an image where each Connected Component is assigned a unique label (integer value). 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 BKE Allegretti2019 is supported, see the #ConnectedComponentsAlgorithmsTypes for details. Note that labels in the output are not required to be sequential.

Parameters

  • image: The 8-bit single-channel image to be labeled.
  • labels: Destination labeled image.
  • connectivity: Connectivity to use for the labeling procedure. 8 for 8-way connectivity is supported.
  • ltype: Output image label type. Currently CV_32S is supported.
  • ccltype: Connected components algorithm type (see the #ConnectedComponentsAlgorithmsTypes).

Note: A sample program demonstrating Connected Components Labeling in CUDA can be found at

opencv_contrib_source_code/modules/cudaimgproc/samples/connected_components.cpp