F_VN_TrainImageColor
Create a new color model, describing the image color.
Can use available TwinCAT Job Tasks for executing parallel code regions.
Can return partial results when canceled by Watchdog.
Syntax
Definition:
FUNCTION F_VN_TrainImageColor : HRESULT
VAR_INPUT
ipSrcImage : ITcVnImage;
ipColorModel : Reference To ITcVnColorModel;
nDifferentColors : UDINT;
hrPrev : HRESULT;
END_VAR
Inputs
|
Name |
Type |
Description |
|---|---|---|
|
ipSrcImage |
Source image (3 channels (RGB) of type USINT) | |
|
ipColorModel |
Reference To ITcVnColorModel |
Returns the color model |
|
nDifferentColors |
UDINT |
Number of different colors to distinguish |
|
hrPrev |
HRESULT indicating the result of previous operations (If SUCCEEDED(hrPrev) equals false, no operation is executed.) |
Further information
The function F_VN_TrainImageColor trains a color model on the basis of a reference image. If the trained color model is to be saved to disk, the F_VN_TrainImageColor_ITcVnMlModel with the type ITcVnMlModel must be used.
Parameter
Reference image
The reference image ipSrcImage must have 3 channels in RGB format and the element type USINT (8-bit).
Color model
The parameter ipColorModel returns the trained color model. This is an interface pointer of the type ITcVnColorModel.
Number of colors to be distinguished
The number nDifferentColors defines the number of colors to be trained. Note that the image background, for example, can also have its own color.
Expert parameters
Further parameters can be found in the expert version F_VN_TrainImageColorExp.
Application
The training of a color model for a reference image with 4 differently colored objects and a dark background looks like this, for example:
VAR
ipColorModel : ITcVnColorModel;
END_VAR
hr := F_VN_TrainImageColor(
ipSrcImage := ipImageRef,
ipColorModel := ipColorModel,
nDifferentColors:= 5, // 4 colors + 1 background = 5
hrPrev := hr);Related functions
There are three ways to pass the reference color to the corresponding F_VN_ReferenceColorSimilarity function:
- As a trained color model of the type
ITcVnColorModel - As a trained color model of the type
ITcVnMlModel - Directly with values in a
TcVnVector3_LREAL
For the color models there are corresponding functions for training and for all three data types one function each for execution:
- F_VN_TrainImageColor for the training of a color model
- F_VN_ReferenceColorSimilarity for segmentation by means of a color model
Required License
TC3 Vision Base
Return value