Image segmentation is a procedure that splits an image into multiple segments. The segments have similar color or intensity. The segments also usually have a meaning in the context of medicine, traffic, astronomy, or something else.
The easiest way to segment images is with a threshold value, which produces two segments (if values are equal to the threshold, we put them in one of the two segments). Otsu's thresholding method minimizes the weighted variance of the two segments (refer to the following equation):
If we segment images, it is a good idea to remove noise or foreign artifacts. With dilation (see the See also section) we can find parts of the image that belong to the background and the foreground. However, dilation leaves us with unidentified pixels.