Automatically finds a suitable threshold value for binarizing a gray-level image based on its histogram. This tool uses Otsu's method to find a threshold that best separates background from foreground. Mathematically, the threshold is selected by splitting the input histogram so that the sum of variances on both sides of the threshold is minimized.
In addition to the optimal threshold, the tool estimates which of the sides of the threshold represents foreground and background and sets the invert output accordingly.
- The gray-level histogram of an image.
- The optimal threshold.
- A boolean value that indicates whether the background is dark or light. It is assumed that the input histogram contains more background than foreground. If at least half of its mass is on the left side of the the selected threshold, background is assumed to be dark and the the invert output will be
false. Otherwise, it will be