F_VN_LaplacianFilter

F_VN_LaplacianFilter 1:

Apply a Laplacian filter to an image.

Syntax

Definition:

FUNCTION F_VN_LaplacianFilter : HRESULT
VAR_INPUT
    ipSrcImage  : ITcVnImage;
    ipDestImage : Reference To ITcVnImage;
    eDestDepth  : ETcVnElementType;
    hrPrev      : HRESULT;
END_VAR

F_VN_LaplacianFilter 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_LaplacianFilter 3: Return value

HRESULT

Further information

The function F_VN_LaplacianFilter applies a Laplace filter to the input image.

Algorithm

The Laplace filter can be used to detect edges by approximating the second derivative of the transitions of adjacent pixel intensities. Since the derivative also has negative values, it is advisable to use a signed element type for the result image (e.g. TCVN_ET_INT).

For nKernelSize = 3, 5, ... the Laplace filter is calculated by adding the second derivative in x- and y-direction over the specified window size. For nKernelSize = 1, the following special 3 x 3 kernel is used:

F_VN_LaplacianFilter 4:

Parameter

Input image

The input image ipSrcImage may be in any available format, except for the data types SINT and DINT, which are generally not supported.

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.

Result depth

The result depth eDestDepth defines which element type the result image ipDestImage has. A larger element type can display more information.

Notice

Combination of input image and result depth

Only the same or a larger data type than that of the input image can be used as the result depth, otherwise data would be lost. For example, a UINT cannot be converted to a USINT. Furthermore, there are two restrictions, so that a UINT cannot be converted into an INT and a REAL cannot be converted into an LREAL.

Expert parameters

The expert version F_VN_LaplacianFilterExp contains additional parameters.

Application

The application of a Laplace filter with a result depth of 8 bits looks like this, for example:

hr := F_VN_LaplacianFilter(
    ipSrcImage  :=  ipImageIn,
    ipDestImage :=  ipImageRes,
    eDestDepth  :=  TCVN_ET_USINT,
    hrPrev      :=  hr
);

Original image

Result image

F_VN_LaplacianFilter 5:

F_VN_LaplacianFilter 6:

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