Watershed Segmentation FAQs

NI Vision Assistant

Watershed Segmentation FAQs

How can I label more than 255 zones?

The watershed transform accepts 8-bit and 16-bit images. The maximum number of labels in an 8-bit image is 255. Zones over 255 are saturated at 255. The maximum number of labels in a 16-bit grayscale image is 32,766. If an 8-bit image requires more than 255 labels, cast the image to a 16-bit image before using the Watershed Segmentation step.

If 8-bit images can label up to only 255 zones, is the Number of Zones result still accurate if more than 255 zones are detected?

Watershed Segmentation returns the correct number of zones found even if the number of zones is greater than the maximum number of labels for a particular bit depth.

Can I use the output of the watershed transform to separate touching objects?

The Watershed Segmentation algorithm partitions an image based on the topographic surface of the image. The image is separated into non-overlapping segments. Each segment contains a unique particle. Complete these steps to separate touching particles by masking the segmentation lines.

  1. Store a copy of the binary image in Buffer #1 with the Image Buffer step (Image»Image Buffer).
  2. Use the Danielsson option (Binary»Adv. Morphology»Danielsson) to assign to each pixel a grayscale value equal to the shortest distance to the border of the object.
  3. Use the Watershed Segmentation step (Grayscale»Watershed Segmentation) to partition the image.
  4. Store the watershed image in Buffer #2 with the Image Buffer step.
  5. Retrieve the thresholded image from Buffer #1 using the Image Buffer step.
  6. Mask the thresholded image with the watershed image by using the Mask Buffer step (Grayscale»Operators»Mask).