F_VN_DoubleThreshold
Apply a double threshold (also called hysteresis threshold) using morphological reconstruction.
Can use available TwinCAT Job Tasks for executing parallel code regions.
Syntax
Definition:
FUNCTION F_VN_DoubleThreshold : HRESULT
VAR_INPUT
ipSrcImage : ITcVnImage;
ipDestImage : Reference To ITcVnImage;
fLowThreshold : LREAL;
fHighThreshold : LREAL;
fMaxValue : LREAL;
hrPrev : HRESULT;
END_VAR
Inputs
Name |
Type |
Description |
---|---|---|
ipSrcImage |
Source image (USINT, UINT, INT, REAL, or LREAL, 1 channel) | |
ipDestImage |
Reference To ITcVnImage |
Destination image (An appropriate destination image will be created if required.) |
fLowThreshold |
LREAL |
Low threshold determinining the shape of found regions |
fHighThreshold |
LREAL |
High threshold selecting found regions (Each region must at least contain a single pixel if the high threshold is applied.) |
fMaxValue |
LREAL |
Maximum pixel value |
hrPrev |
HRESULT indicating the result of previous operations (If SUCCEEDED(hrPrev) equals false, no operation is executed.) |
Further information
The function F_VN_DoubleThreshold
calculates a double threshold value using morphological reconstruction. The function expects the searched segments to be brighter than the background and, compared to the function F_VN_Threshold
, enables additional filtering of the determined image segments.
Parameter
Input image
The input image ipSrcImage
must be a 1-channel grayscale image.
Result image
The binary result image ipDestImage
has the same format as the input image. The pixels have either the value 0
or the target value fMaxValue
.
Lower threshold value
The lower threshold value determines the shape of the segments found, such as the function F_VN_Threshold
.
Upper threshold value
The upper threshold value is used to mark image segments whose shape is then calculated on the basis of the lower threshold value. In this way, unwanted segments whose grayscale values are greater than the lower threshold value and less than the upper threshold value can be filtered out.
Target value
The target value fMaxValue
defines the value to be assigned to the pixels that fulfill the respective threshold value criterion. If the result image is to consist only of black and white pixels, then the maximum value of the element type of the input image must be set here. This corresponds to (2^d)-1
, where d is the bit depth of the element type; e.g. (2^8)-1=255
for 8-bit images.
Application
hr := F_VN_DoubleThreshold(
ipSrcImage := ipSrcImage,
ipDestImage := ipDestImage,
fLowThreshold := fLowThreshold,
fHighThreshold := fHighThreshold,
fMaxValue := 255,
hrPrev := hr);
Related functions
- F_VN_DoubleThreshold for binary segmentation on the basis of double threshold values using morphological reconstruction
- F_VN_Threshold for binary segmentation on the basis of a threshold value
- F_VN_AdaptiveThreshold for binary, adaptive segmentation
- F_VN_CheckColorRange for binary segmentation on the basis of a color spectrum
- F_VN_ReferenceColorSimilarity for binary segmentation on the basis of a color model
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 |