The basic idea is to find a point between the peak of the foreground pixel values and the peak of the background pixel values. Image histogram can be used to automatically determine the value of the threshold to be used for converting a grayscale image to a binary image. The image histogram is a statistical graph with grayscale value on the x-axis and the number of pixels for each grayscale on the y-axis. The global thresholding method takes advantage of the image histogram. The image is divided into several sub-blocks, and the distribution of gray-value in each block was analyzed. With the local thresholding method, a threshold is calculated at each pixel, which depends on some local statistics such as mean, range, and the variance of the pixel neighborhood. The images below show an example of before and after binarization. Global thresholding - calculates the threshold once for all pixels.Local thresholding - calculates the threshold pixel by pixel.The critical task is to find a suitable threshold. This transformation is useful in detecting blobs and further reduces the computational complexity. Binarization: Grayscale to black/white Conversionīinarization converts a grayscale image to a black/white image.