F_VN_SeparableCustomFilter

F_VN_SeparableCustomFilter 1:

Apply a separable custom filter to the image.

Syntax

Definition:

FUNCTION F_VN_SeparableCustomFilter : HRESULT
VAR_INPUT
    ipSrcImage  : ITcVnImage;
    ipDestImage : Reference To ITcVnImage;
    eDestDepth  : ETcVnElementType;
END_VAR
VAR_IN_OUT
    stKernelX   : TcVnMatrix;
    stKernelY   : TcVnMatrix;
END_VAR
VAR_INPUT
    hrPrev      : HRESULT;
END_VAR

F_VN_SeparableCustomFilter 2: Inputs

Name

Type

Description

ipSrcImage

ITcVnImage

Source image

ipDestImage

Reference To ITcVnImage

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

eDestDepth

ETcVnElementType

Destination image depth

hrPrev

HRESULT

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

F_VN_SeparableCustomFilter 3: In/Outputs

Name

Type

Description

stKernelX

TcVnMatrix

1D custom row-filter kernel with values of type REAL or LREAL

stKernelY

TcVnMatrix

1D custom column-filter kernel with values of type REAL or LREAL

F_VN_SeparableCustomFilter 4: Return value

HRESULT

Further information

The function F_VN_SeparableCustomFilter applies a separable 2D filter to the input image.

Algorithm

A separable 2D filter can be combined from two 1D filters. It is more efficient to apply a 1D filter to an image twice than to apply a 2D filter once. For example, the well-known Sobel filter can be constructed as follows from two separate one-dimensional filters:

F_VN_SeparableCustomFilter 5:
F_VN_SeparableCustomFilter 6:

Parameter

Input image

The input image ipSrcImage may have any available format.

Result image

The result image ipDestImage has the same size as the input image ipSrcImage, but the pixel format is determined by the result depth eDestDepth.

X and Y kernel

The two 1-dimensional filter kernels stKernelX and stKernelY are transferred as a matrix. Permitted element types of the matrix are TCVN_ET_REAL and TCVN_ET_LREAL. Corresponding matrices of the type TcVnMatrix can be created with the aid of the function F_VN_InitMatrixStruct.

Expert parameters

The expert version F_VN_SeparableCustomFilterExp contains additional parameters.

Application

The creation and application of a separable 2D filter looks like this, for example:

hr := F_VN_SeparableCustomFilter(
    ipSrcImage  :=  ipImageIn,
    ipDestImage :=  ipImageRes,
    eDestDepth  :=  TCVN_ET_USINT,
    stKernelX   :=  stKernelMatrixX,
    stKernelY   :=  stKernelMatrixY,
    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