Morphological processing
After segmenting the image into the two components, you are left with a mask or binary image. As was clear from the examples, these masks are not always suitable for direct measurement. Imperfections in the image may result in gaps in objects or small discontinuities in structures. Also, some areas might be detected as foreground when they are actually not really objects of interest. You could manually correct this by converting the missing pixels to white or black in order to include or exclude them, respectively. In some cases, this might be the only possible recourse. However, in many cases, there are a few processing steps available that can fix these problems in a systematic way. These steps are called morphological processing, which we will examine in greater detail in the next section.
Morphological operators
ImageJ supports the two main principal operators for morphological processing: erode and dilate. It also has functions for filling holes, skeletonizing...