ConnectedComponentsWithStats

Computes the connected components and corresponding statistics of an image.

Syntax

Definition:

HRESULT ConnectedComponentsWithStats(
    HRESULT                           hrPrev,
    ITcVnImage*                       ipSrcImage,
    ITcVnImage*&                      ipLabelImage,
    ITcVnContainer*&                  ipBoundingBoxes,
    ITcVnContainer*&                  ipNumPixels,
    ITcVnContainer*&                  ipCentroids,
    LONG&                             nLabels,
    ETcVnPixelConnectivity            eConnectivity = PC_8,
    ETcVnElementType                  eLabelType = TCVN_ET_DINT,
    ETcVnConnectedComponentsAlgorithm eAlgorithm = CCA_GRANA
)

Parameters

Name

Type

Default

Description

hrPrev

HRESULT

 

HRESULT indicating the result of previous operations (If SUCCEEDED(hrPrev) equals false, no operation is executed.)

ipSrcImage

ITcVnImage*

 

Source image (USINT, 1 channel, binary)

ipLabelImage

ITcVnImage*&

 

Returns the labels for each source image pixel (1 channel, DINT. An appropriate destination image will be created if required.)

ipBoundingBoxes

ITcVnContainer*&

 

Returns the bounding boxes for each labeled region. (ContainerType_Vector_TcVnRectangle_DINT; Non-zero interface pointers are reused.)

ipNumPixels

ITcVnContainer*&

 

Returns the number of pixels for each labeled region. (ContainerType_Vector_DINT; Non-zero interface pointers are reused.)

ipCentroids

ITcVnContainer*&

 

Returns the centroids for each labeled region. (ContainerType_Vector_TcVnPoint2_LREAL; Non-zero interface pointers are reused.)

nLabels

LONG&

 

Returns the number of labels

eConnectivity

ETcVnPixelConnectivity

PC_8

Selects if 4- or 8-way pixel connectivity should be used

eLabelType

ETcVnElementType

TCVN_ET_DINT

Selects the type of ipLabelImage (only UINT or DINT supported)

eAlgorithm

ETcVnConnectedComponentsAlgorithm

CCA_GRANA

Selects the applied algorithm

ConnectedComponentsWithStats 1: Return value

HRESULT

Required License

TC3 Vision Base

System Requirements

Development environment

Target platform

PLC libraries to include

TwinCAT V3.1.4024.54 or later

PC or CX (x64) with PL50, e.g. Intel 4-core Atom CPU

Tc3_Vision