F_VN_ScharrFilter

F_VN_ScharrFilter 1:

Calculates the first order derivative in x or y direction using a Scharr filter.

Syntax

Definition:

FUNCTION F_VN_ScharrFilter : HRESULT
VAR_INPUT
    ipSrcImage       : ITcVnImage;
    ipDestImage      : Reference To ITcVnImage;
    eDestDepth       : ETcVnElementType;
    eFilterDirection : ETcVnFilterDirection;
    hrPrev           : HRESULT;
END_VAR

F_VN_ScharrFilter 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

eFilterDirection

ETcVnFilterDirection

Filter direction

hrPrev

HRESULT

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

F_VN_ScharrFilter 3: Return value

HRESULT

Further information

The function F_VN_ScharrFilter applies a Scharr filter to the input image. The Scharr filter functions analogously to the Sobel Filter and differs from it only by the kernel.

Algorithm

The Scharr filter is closely related to the Sobel filter. However, it provides more accurate results than a 3 x 3 Sobel filter.

F_VN_ScharrFilter 4:

Parameter

Original image

The original image ipSrcImage can have any format.

Result image

The result image ipDestImage returns the filter result and has the same format as the original image ipSrcImage.

Result depth

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

Filter direction

The filter direction eFilterDirection defines whether the Scharr filter is applied to the image in the X-direction (TCVN_FD_X) or in the Y-direction (TCVN_FD_Y).

Expert parameters

Further parameters can be found in the expert version F_VN_ScharrFilterExp.

Application

hr := F_VN_ScharrFilter(
    ipSrcImage      :=  ipImageIn,
    ipDestImage     :=  ipImageRes,
    eDestDepth      :=  TCVN_ET_USINT,
    eFilterDirection:=  TCVN_FD_X,
    hrPrev          :=  hr,
);

Original image

Result image

F_VN_ScharrFilter 5:

F_VN_ScharrFilter 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