Now, let's take a look at Otsu's thresholding from a more algorithmic point of view. Here are the steps of the algorithm:
For each potential threshold T, we:
Separate the pixels into two clusters according to the threshold.
Find the mean of each cluster.
Square the difference between the means.
Multiply by the number of pixels in one cluster times the number in the other.
If we incorporate a little math into that simple step-wise algorithm, such an explanation evolves:
Compute histogram and probabilities of each intensity level.
Set up initial qi(0) and μi(0).
Step through all possible thresholds maximum intensity.
Update qi and μi.
Compute f9.jpg.
Desired threshold corresponds to the maximum.