When segmenting an image based on threshold, ROIs may be too near or overlap adjacent areas of interest. Thus when counting, the connected ROIs will be counted as one object instead of two. By processing the image, after the binary operation, the surrounding pixels that bridge ROIs can be eroded away by systematically removing edge pixels. This process is called erosion. Conversely, pixels may be added systematically to fill holes and close spaces between objects. This operation is called dilation. Sequential erosion/dilation operations can be used to make noisy images solid in the process of opening. The converse of this is the closing operation, which can bridge adjacent binary ROIs.

binary operations
Binary operations. The original image was segmented into a binary image using thresholding. Sequential dilation followed by erosion (a Close operation) can be used to fill in gaps between adjacent structures. Sequential erosion followed by dilation (an Open operation) can remove bridges between adjacent structures.