F_VN_CustomFilter
Apply a custom filter to the image.
Syntax
Definition:
FUNCTION F_VN_CustomFilter : HRESULT
VAR_INPUT
ipSrcImage : ITcVnImage;
ipDestImage : Reference To ITcVnImage;
eDestDepth : ETcVnElementType;
END_VAR
VAR_IN_OUT
stKernel : TcVnMatrix;
END_VAR
VAR_INPUT
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 | |
hrPrev |
HRESULT indicating the result of previous operations (If SUCCEEDED(hrPrev) equals false, no operation is executed.) |
In/Outputs
Name |
Type |
Description |
---|---|---|
stKernel |
Custom filter kernel with values of type REAL or LREAL |
Further information
The function F_VN_CustomFilter
applies a user-defined filter to the input image. The filter kernel is defined by a matrix. This matrix is folded with the image.
Parameter
Input image
The input image ipSrcImage
may have any available format.
Result image
The result image ipDestImage
has the same format as the input 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 kernel
The user-defined filter kernel stKernel
is transferred as a matrix. Permitted element types of the matrix are TCVN_ET_REAL
and TCVN_ET_LREAL
. A corresponding matrix of the type TcVnMatrix can be created with the aid of the function F_VN_InitMatrixStruct.
Expert parameters
The expert version F_VN_CustomFilterExp contains additional parameters.
Application
hr := F_VN_InitMatrixStruct(
pSrcBuffer := ADR(aMatrixArray7x7),
stDestMatrix := stKernelMatrix,
nRows := 7,
nCols := 7,
eElementType := TCVN_ET_REAL,
hrPrev := hr
);
hr := F_VN_CustomFilter(
ipSrcImage := ipImageIn,
ipDestImage := ipImageRes,
eDestDepth := TCVN_ET_USINT,
stKernel := stKernelMatrix,
hrPrev := hr
);
- The unprocessed original image (1st row) already exhibits fine structures on the surface of the gear wheels in the detail. In order to illustrate the effects of the filters, additional disturbances were added to the original image by Gauss noise (2nd row) and salt-and-pepper noise (3rd row). An average filter is implemented as an example; a more detailed description can be found in the sample for the Blur filter:
Original images | Result images: Mean filter |
Samples
- Blur filter
- User-defined filters
Required License
TC3 Vision Base
System Requirements
Development environment | Target platform | PLC libraries to include |
---|---|---|
TwinCAT V3.1.4024.59 or later | PC or CX (x64) with PL50, e.g. Intel 4-core Atom CPU | Tc3_Vision |