Threshold

Thresholding is the simplest method of image segmentation. It is used for thresholding color images (RGB, HSV, HLS) and gray scale images.

    Threshold

Library

ComputerVision/Images/Transformations/Misc

Description

In general, for a gray scale image, the Threshold block creates binary images (white and black) as the output. For a color image, the binary output image represents a range of intensity. Thus, the objective of binarization is to mark the pixel foreground region with a single intensity and the background region with different intensities.

With the Threshold block, there are two possible comparison outcomes performed at every pixel location based on the pixel value ratio. If the pixel value is greater than the specified threshold value:

• For a gray scale image: it is assigned one value (bright color (pure white)) else it is assigned another value (dark color (black)).

• For an HSV color image: it is assigned one value (bright color (red/magenta)) else it is assigned another value (dark color (blue/cyan)).

• For an HLS color image: it is assigned one value (mix with white to lighten the value (green/cyan)) else it is assigned another value (mix with black to darken the value (red/magenta)).

Parameters

Threshold_0

NameLabelDescriptionData TypeValid Values

useInput

Use inputs

Use inputs to define the Threshold Value and the Max Binary Threshold.

Number

0
1

thresholdValue

Threshold Value

Indicates the minimum pixel value (0 – 255) for the threshold operation.

Scalar

maxBinaryValue

Max Binary Threshold

Indicates the maximum value (0 – 255) of the pixel for the threshold operation.

Scalar

thresholdType

Threshold Type

Binary: If the source pixel value is greater than the threshold value, the new pixel value is set to the specified Max Binary Value; otherwise, the pixel value is set to 0.

Binary Inverted: If the source pixel value is greater than the threshold value, the new pixel value is set to a 0; otherwise, the pixel value is set to the Max Binary Value.

Threshold to Zero: If the source pixel value is greater than the threshold value, the new pixel value is set to 0; otherwise, the pixel value is set to the source pixel value.

Threshold to Zero Inverted: If the source pixel value is greater than the maximum threshold value, the new pixel value is set to 0; otherwise, the pixel value is set to the source pixel value.

Threshold Truncated: If the source pixel value is greater than the threshold value, the new pixel value is set to the threshold; otherwise, the pixel value is set to 0.

String

'Binary'
'Binary
Inverted'
'Threshold
to
Zero'
'Threshold
to
Zero
Inverted'
'Threshold
Truncated'

externalActivation

External activation

This parameter defines if the block receives or inherits an external activation. When External Activation is used, an additional activation port is added to the block. Default is OFF.

Number

0
1

Ports

NameTypeDescriptionIO TypeNumber

src

explicit

input

1

image

explicit

output

1

Port 3

explicit

input

2*useInput

Port 4

activation

input

externalActivation