In Otsu Thresholding , the threshold value is not selected, but is determined automatically. A bimodal image (two different image values) is considered. The generated histogram contains two peaks. So a general condition would be to choose a threshold that is in the middle of both peaks of the histogram.
We use the traditional cv2.threshold
function and use cv2.THRESH_OTSU
as an optional flag.
Syntax: cv2.threshold (source, thresholdValue, maxVal , thresholdingTechnique)
Parameters:
-" source : Input Image array (must be in Grayscale).
-" thresholdValue : Value of Threshold below and above which pixel values will change accordingly.
-" maxVal : Maximum value that can be assigned to a pixel.
-" thresholdingTechnique : The type of thresholding to be applied.
Below is the Python code explaining the father-threshold technique —
< code class = "undefined spaces"> |
Input data :

Exit:

The calculation assumes that the image contains two classes of pixels, following the pixels of the foreground and background, at which point an ideal limit is set, isolating the two classes in order to be consolidated the spread was negligible.