otsu thresholding
1. explained
You have a grayscale photo that you want to segment into dark and light pieces. You can set a threshold so that every pixel below the value is in the dark piece and every pixel above the threshold is in the light piece. How should you set your threshold? You should set it so that the intra-class variance is minimized. That is, within the light pixels the variance among pixel values is low and within the dark pixels, the variance is also low. So you find the argmin the sum of these two variances.
One other thing, you want to avoid trivial cases where the threshold segments the image into one very tiny piece and one very large piece erroneously. So you should weight each variance by the number of pixels in the group.