Threshold Method
Syntax
CWIMAQVision.Threshold SourceImage, DestImage [, MinValue = 128] [, MaxValue = 255] [, DoReplacement = True] [, NewValue = 1]
Return Type
On success, this method returns 0. On failure, this method returns a negative number.
Purpose
Thresholds an image. The method sets pixels values outside of the given range to 0. The method sets pixel values within the range to a given value or leaves the values unchanged.
Remarks
Use this method with U8, I16, and SGL images.
This method is optimized for MMX.
Parameters
SourceImage As CWIMAQImage
The image to threshold.
DestImage As CWIMAQImage
The resulting image.
MinValue As Variant
[Optional] The lower boundary of the range of pixel values to keep.
This parameter has a default value of 128.
MaxValue As Variant
[Optional] The upper boundary of the range of pixel values to keep.
This parameter has a default value of 255.
DoReplacement As Variant
[Optional] Set this parameter to True to set the pixel values within [MinValue, MaxValue] to the value specified in NewValue. Set this parameter to False to leave the pixel values unchanged.
This parameter has a default value of True.
NewValue As Variant
[Optional] The replacement value for pixels within the range if you set DoReplacement to True. If you set DoReplacement to False, the method ignores this parameter.
This parameter has a default value of 1.
Example
Private Sub Run_Click() Dim i As New CWIMAQImage ' Threshold the image in Viewer1 and store the result in i. CWIMAQVision1.Threshold CWIMAQViewer1.Image, i, 128, 255, , 255 ' Threshold the image in Viewer1. ' Do the operation in-place. CWIMAQVision1.Threshold CWIMAQViewer1.Image, CWIMAQViewer1.Image, _ 128, 255, False End Sub