Previously, in my post about Canny edge detector, we had seen that one of the required steps for obtaining perfectly thinned edges was thresholding, in the source code example for that post I've used an arbitrary good enough value for the thersholds. In this post I'll show you an algorithmic way of obtaining all thresholds for a given number of gray levels output, based on the Otsu's method.