F_VN_CreateStructuringElement

F_VN_CreateStructuringElement 1:

Creates a structuring element for the usage with morphological operators and allocate an appropriate data buffer. The initial reference count is set to one if a new image interface is created and kept, otherwise.

Syntax

Definition:

FUNCTION F_VN_CreateStructuringElement : HRESULT
VAR_INPUT
    ipStructuringElement : Reference To ITcVnImage;
    eShape               : ETcVnStructuringElementShape;
    nWidth               : UDINT;
    nHeight              : UDINT;
    hrPrev               : HRESULT;
END_VAR

F_VN_CreateStructuringElement 2: Inputs

Name

Type

Description

ipStructuringElement

Reference To ITcVnImage

Returns the created structuring element (Non-zero interface pointers are reused.)

eShape

ETcVnStructuringElementShape

Shape of the structuring element (rectangle, cross, or ellipse)

nWidth

UDINT

Width

nHeight

UDINT

Height

hrPrev

HRESULT

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

F_VN_CreateStructuringElement 3: Return value

HRESULT

Further information

The function creates a structure element that can be used for morphological operations with F_VN_MorphologicalOperator.

Parameter

Structure element

The structure element created, ipStructuringElement, is returned as ITcVnImage by representing the structure element with pixels with the value 1.

Shape

The shape eShape of the structure element is defined by the enum ETcVnStructuringElementShape. The following shapes are available:

TCVN_SES_RECTANGLE

TCVN_SES_CROSS

TCVN_SES_ELLIPSE

F_VN_CreateStructuringElement 4:

F_VN_CreateStructuringElement 5:

F_VN_CreateStructuringElement 6:

F_VN_CreateStructuringElement 7:

As the pixel values of the structure element are 1, they were scaled up here for a better display.

Size

The size of the structure element is defined by the width nWidth and height nHeight of the image ipStructuringElement to be created.

Application

The creation of a square structure element of the size 9 looks like this, for example:

hr := F_VN_CreateStructuringElement(
    ipStructuringElement    :=  ipElement,
    eShape                  :=  TCVN_SES_RECTANGLE,
    nWidth                  :=  9,
    nHeight                 :=  9,
    hrPrev                  :=  hr
);

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