THRESHOLD Function
Performs either binary or grayscale global thresholding on an image.
Usage
result = THRESHOLD(image, a[, b])
Input Parameters
image—A 1D, 2D or 3D array containing a signal; point or signal-interleaved signals; an image; image, row, or pixel-interleaved images; or a volume.
a—The value on the left-hand side of the threshold equation. This parameter is a scalar for a single signal, image, or volume; or an array for an interleaved arrangement of signals or images.
b—(optional) The value on the right-hand side of the threshold equation. This parameter is a scalar for a single signal, image, or volume; or an array for an interleaved arrangement of signals or images.
Returned Value
result—An array of data type byte (for binary thresholding), or of the same data type as image (grayscale thresholding). The data is thresholded in the following manner:
*For two input parameters, image and a, all values in image which are greater than or equal to a are set to the value of the Set_True keyword.
*For three input parameters, image, a, and b, all values in image which are greater than or equal to a and are less than or equal to b are set to the value of the Set_True keyword.
Keywords
A_Neq—If set, the comparison on the left-side of the threshold equation does not include the value of a.
Binary—If set, binary thresholding is performed; otherwise, grayscale thresholding is performed. (Default: 0)
B_Neq—If set, the comparison on the right-side of the threshold equation does not include the value of b.
Intleave—A scalar string indicating the type of interleaving of 2D input signals and 3D image arrays. Valid strings and the corresponding interleaving methods are:
*'point'—The 2D input array arrangement is (px) for p  point-interleaved signals of length x.
*'signal'—The 2D input image array arrangement is (xp) for p  signal-interleaved signals of length x.
*'pixel'—The input array arrangement is (pxy) for p  pixel-interleaved images of x-by-y.
*'row'—The 3D image array arrangement is (xpy) for p  row-interleaved images of x-by-y.
*'image'—The 3D image array arrangement is (xyp) for p  image-interleaved images of x-by-y.
*'volume'—The input image array is treated as a single entity.
Inverse—If set, the comparison relationships of image, and a, and (optionally) b are reversed. This creates disjoint regions for thresholding as follows:
*For the two input parameters, image and a, all values in image which are less than or equal to a are set to the value of the Set_True keyword.
*For the three input parameters, image, a, and b, all values in image which are less than or equal to a, or are greater than or equal to b are set to the value of the Set_True keyword.
Set_False—The amplitude of result where the comparison is false. (Default: 0)
 
note
The Set_False keyword is used only for binary thresholding.
Set_True—Amplitude of result where comparison is true. (Default: 255)
Discussion
Thresholding is used as a simple segmentation method for identifying objects or regions within an image that have consistent graylevels.
Example
To threshold an image, x, such that values between, but not including, 30 and 55 are set to190, and all other values in x are 10, do the following:
result = THRESHOLD(x, 30, 55, Set_True = 190, $
Set_False = 10, /Binary, /A_Neq, /B_Neq)
This is conceptually the same as the following logic statement:
If 30 < x (ij) < 55, then x (ij) = 190, else x (ij) = 10, where 0  i < N and 0  j < M for all x (NM).
See Also