Method ConnectedComponents
- Namespace
- OpenCvSharp
- Assembly
- OpenCvSharp.dll
ConnectedComponents(InputArray, OutputArray, PixelConnectivity)
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.
public static int ConnectedComponents(InputArray image, OutputArray labels, PixelConnectivity connectivity = PixelConnectivity.Connectivity8)
Parameters
imageInputArraythe image to be labeled
labelsOutputArraydestination labeled image
connectivityPixelConnectivity8 or 4 for 8-way or 4-way connectivity respectively
Returns
- int
The number of labels
ConnectedComponents(InputArray, OutputArray, PixelConnectivity, MatType)
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.
public static int ConnectedComponents(InputArray image, OutputArray labels, PixelConnectivity connectivity, MatType ltype)
Parameters
imageInputArraythe image to be labeled
labelsOutputArraydestination labeled image
connectivityPixelConnectivity8 or 4 for 8-way or 4-way connectivity respectively
ltypeMatTypeoutput image label type. Currently CV_32S and CV_16U are supported.
Returns
- int
The number of labels
ConnectedComponents(InputArray, out int[,], PixelConnectivity)
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.
public static int ConnectedComponents(InputArray image, out int[,] labels, PixelConnectivity connectivity)
Parameters
imageInputArraythe image to be labeled
labelsint[,]destination labeled rectangular array
connectivityPixelConnectivity8 or 4 for 8-way or 4-way connectivity respectively
Returns
- int
The number of labels