Back to Aurora Vision Library website

You are here: Start » Function Reference » Computer Vision » Image Segmentation » SegmentImage_Watersheds

SegmentImage_Watersheds


Header: AVL.h
Namespace: avl
Module: FoundationBasic

Computes dark or bright watershed basins of an image.

Applications: A classic algorithm, useful for segmentation of ball-shaped objects like plant seeds, cells or fruits.

Syntax

C++
C#
 
void avl::SegmentImage_Watersheds
(
	const avl::Image& inImage,
	atl::Optional<const avl::Region&> inRoi,
	const atl::Array<avl::Region>& inMarkers,
	avl::Polarity::Type inBasinsPolarity,
	atl::Array<avl::Region>& outBasins
)

Parameters

Name Type Default Description
Input value inImage const Image& Input image
Input value inRoi Optional<const Region&> NIL Range of pixels to be processed
Input value inMarkers const Array<Region>& Local minima markers
Input value inBasinsPolarity Polarity::Type Whether to look for bright or dark basins
Output value outBasins Array<Region>&

Requirements

For input inImage only pixel formats are supported: uint8.

Read more about pixel formats in Image documentation.

Description

This filter segments the image into basins based on a set of markers (inMarkers) and a flooding watersheds implementation for grayscale images.

By default a darker pixel is considered lower but that can be changes using the inBasinsPolarity parameter.

Markers have to be computed beforehand. One way to do that is to detect the ridges of the image and threshold it into a single region, Pass the resulting region into the DistanceTransform filter. Then threshold the distance image and split it into blobs.

Examples

Example image

Computed markers

Basins computed with watersheds

Errors

List of possible exceptions:

Error type Description
DomainError No markers present in SegmentImage_Watersheds.
DomainError Not supported inImage pixel format in SegmentImage_Watersheds. Supported formats: UInt8.

See Also

  • ThresholdToRegion – Creates a region containing image pixels with values within the specified range.
  • DistanceTransform – Computes an image in which the pixel values denote the estimated distances to the nearest bright pixel in the input image.