Watershed

Image segmentation is the process of isolating objects in the image from the background. Separating touching objects in an image is really a difficult task. The watershed transform is often applied to this problem. Another method available in JMicroVision is Object Separation.

The watershed from markers can be intuitively described as the flooding simulation, where the image is treat as a surface (light pixels are high and dark pixels are low). This surface is submerged slowly in water. From each of the holes, the flooding water is painted with the color of the marker. At any time that different colored water coming from different holes meet, a dam is built to avoid their mixing. This mechanism continues progressively until the brightest pixel is reached. The final dams are the watershed lines and the colored water is the segmented regions.

 Note: To obtain better result, the source image is automatically transformed into Sobel edge image (see gradient filtering). The gradient tends to be high at the borders of the objects and low inside the objects.

This implementation always uses markers to control the watershed segmentation. The marker-controlled method leads to segmentation results in which one object (segmented region) corresponds to only one marker.

 Note: The watershed process requires to handle the whole image in memory, thus it can be applied on very high-definition images only if the computer has enough memory.

Source Image

Image: Select an image as input for watershed.

Median filter (pre-processing): Checking this box applies to the input image a median filter (size: 7x7), which reduces noise while it preserves the position of borders.

Markers

Each marker results in one region. When the markers selection is an image, each region characterized by a color or a gray level is considered as a marker, except black region that represents the background. There are different ways to obtain an image of markers. The most common one is the ultimate eroded points image. However, a combination of morphological operations can produce an image of markers.

Merge the markers of the same class: This option has an effect only if the Display a line of separation button is checked. It removes the boundary lines of regions, which belongs to the same class. Do not check this button if all the markers have the same color.

 Note: When Ultimate eroded points is selected, this option has no effect.

Options

Pixel connectivity: Define the pixel connectivity when the algorithm floods the regions.

 Note: When 8 is selected, the black boundary line is larger (pixels in 4 pixel connectivity). This enables to extract each region as an object (in Object Extraction), if 4 is selected, the connected regions will be merged into one object.

Display a line of separation: Display the boundary line of segmented regions.

  Note: This option must be activated to distinguish the boundary of region, especially
when all the markers have an identical color or with binary images.

See also:

Image Factory