Returns a threshold using data from the given range of this histogram. The computed threshold is appropriate for segmenting an image into object and background pixels and is often used to compute a segmentation threshold for blob analysis. The threshold computation includes the left index value but excludes the right index value. This range must include at least two nonzero bins. The returned threshold will be within the range. This threshold divides the histogram data into two groups such that the combined variance within the groups is a minimum.
Namespace: Cognex.VisionPro.ImageProcessingAssembly: Cognex.VisionPro.ImageProcessing (in Cognex.VisionPro.ImageProcessing.dll) Version: 75.1.0.0
Syntax
Parameters
- leftIndex
- Type: System Int32
The index of the lower bound of the partial histogram range for which to compute a threshold.
- rightIndex
- Type: System Int32
The index of the upper bound of the partial histogram range for which to compute a threshold. Specify a value of -1 to use the upper bound of the histogram as the upper bound of the range.
- score
- Type: System Double
An output value into which a score in the range 0.0 through 1.0 is placed. Higher scores indicate better separation between the two groups determined by the threshold.
Return Value
Type: Int32The computed threshold value.
Exceptions
| Exception | Condition |
|---|---|
| InvalidOperationException | If the analyzed range of the histogram contains only empty bins. |
| ArgumentOutOfRangeException | If either index is less than zero or greater than the length of the histogram. Or if leftIndex is greater than or equal to rightIndex. |
See Also