F_VN_MorphologicalOperator

F_VN_MorphologicalOperator 1:

Apply a morphological operator.

Syntax

Definition:

FUNCTION F_VN_MorphologicalOperator : HRESULT
VAR_INPUT
    ipSrcImage           : ITcVnImage;
    ipDestImage          : Reference To ITcVnImage;
    eOperator            : ETcVnMorphologicalOperator;
    ipStructuringElement : ITcVnImage;
    hrPrev               : HRESULT;
END_VAR

F_VN_MorphologicalOperator 2: Inputs

Name

Type

Description

ipSrcImage

ITcVnImage

Source image (only 1 channel supported for reconstruction operators)

ipDestImage

Reference To ITcVnImage

Destination image (An appropriate destination image will be created if required.)

eOperator

ETcVnMorphologicalOperator

Operator type

ipStructuringElement

ITcVnImage

Structuring element to be applied (Typically created via F_VN_CreateStructuringElement.)

hrPrev

HRESULT

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

F_VN_MorphologicalOperator 3: Return value

HRESULT

Further information

The function F_VN_MorphologicalOperator applies a morphological operator to the input image.

Parameter

Original image

The Reconstruction operators can only be applied to a 1-channel image, the other operators have no special requirements for the original image ipSrcImage.

Result image

The modified image is returned in the result image ipDestImage.

Morphological operator

The parameter eOperator defines which morphological operator is applied to the original image ipSrcImage. All operators in the enum ETcVnMorphologicalOperator are available.

Structure element

The structure element ipStructuringElement is the element that specifies the filter area of the morphological operator. It can be created with the help of the function F_VN_CreateStructuringElement.

Application

The application of an Opening operator with a rectangular filter area of the size 3×3 looks like this, for example:

VAR
    ipElement : ITcVnImage;
END_VAR

hr := F_VN_CreateStructuringElement(ipElement, TCVN_SES_RECTANGLE, 3, 3, hr);

hr := F_VN_MorphologicalOperator(
    ipSrcImage  :=  ipImageIn,
    ipDestImage :=  ipImageRes,
    eOperator   :=  TCVN_MO_OPENING,
    ipStructuringElement  :=  ipElement,
    hrPrev      :=  hr
);

Samples

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