F_VN_SobelFilter
Calculates the first, second, or mixed image derivatives using an extended Sobel filter.
Syntax
Definition:
FUNCTION F_VN_SobelFilter : HRESULT
VAR_INPUT
ipSrcImage : ITcVnImage;
ipDestImage : Reference To ITcVnImage;
eDestDepth : ETcVnElementType;
nXOrder : UDINT;
nYOrder : UDINT;
hrPrev : HRESULT;
END_VAR
Inputs
Name |
Type |
Description |
---|---|---|
ipSrcImage |
Source image | |
ipDestImage |
Reference To ITcVnImage |
Destination image (An appropriate destination image will be created if required.) |
eDestDepth |
Destination image depth | |
nXOrder |
UDINT |
Order of the x-derivative (0, 1, 2) |
nYOrder |
UDINT |
Order of the y-derivative (0, 1, 2) |
hrPrev |
HRESULT indicating the result of previous operations (If SUCCEEDED(hrPrev) equals false, no operation is executed.) |
Further information
The function F_VN_SobelFilter
applies a Sobel filter to the input image. The Sobel filter is used for edge detection. Edges in the input image are highlighted as bright lines on a dark background in the result image.
Algorithm
The extended Sobel filter can be used to detect edges by approximating the nth 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
).
The kernel of the filter is determined by the parameters of the function. Typically the function is called with nXOrder = 1, nYOrder = 0, nKernelSize = 3 or nXOrder = 0, nYOrder = 1, nKernelSize = 3. These parameters lead to the kernels Gx and Gy.
For these kernels, the filter combines Gaussian smoothing with the calculation of the first derivative, so that the result is quite noise resistant. Gx emphasizes vertical edges, Gy emphasizes horizontal edges.
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.
Derivative order
The derivative orders nXOrder
and nYOrder
define which derivative in the X and Y direction is to be used to create the filter.
Expert parameters
Further parameters can be found in the expert version F_VN_SobelFilterExp.
Application
hr := F_VN_SobelFilter(
ipSrcImage := ipImageIn,
ipDestImage := ipImageRes,
eDestDepth := TCVN_ET_USINT,
nXOrder := 1,
nYOrder := 1,
hrPrev := hr,
);
Original image | Result image |
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 |