This algorithm applies a watershed using as a landscape image either, in dark objects mode, the
input image directly or, in bright objects mode, its negative.
A contrast level parameter is used to reduce the number of markers for the watershed process and
thus of false positive separation lines.
This algorithm is a high-level combination of numerical reconstruction and watershed algorithms.
There is a limitation to the separation ability: if some particles overlap too much, they are not
separated by the algorithm. A sensible criteria is that the distance between particle centroids should be
larger than their greatest radius.
This algorithm can be used on the gradient modulus to compute best-fit contours.
Note: This algorithm requires up to 8 times the size of the input image as free memory.
If the system does not have enough free memory, this algorithm will fail during its computation. In this case,
the HExtremaWatershedByBlock should be used instead.
// Command constructor.HExtremaWatershed();/// Gets the inputGrayImage parameter./// The input grayscale image.
std::shared_ptr< iolink::ImageView> inputGrayImage()const;/// Sets the inputGrayImage parameter./// The input grayscale image.void setInputGrayImage( std::shared_ptr< iolink::ImageView> inputGrayImage );/// Gets the objectLightness parameter./// The lightness of objects to separate.HExtremaWatershed::ObjectLightness objectLightness()const;/// Sets the objectLightness parameter./// The lightness of objects to separate.void setObjectLightness(constHExtremaWatershed::ObjectLightness& objectLightness );/// Gets the contrastValue parameter./// The depth of the valley used to select the markers of the watershed.int32_t contrastValue()const;/// Sets the contrastValue parameter./// The depth of the valley used to select the markers of the watershed.void setContrastValue(constint32_t& contrastValue );/// Gets the outputType parameter./// The type of result image.HExtremaWatershed::OutputType outputType()const;/// Sets the outputType parameter./// The type of result image.void setOutputType(constHExtremaWatershed::OutputType& outputType );/// Gets the algorithmMode parameter./// The mode for applying the watershed algorithm.HExtremaWatershed::AlgorithmMode algorithmMode()const;/// Sets the algorithmMode parameter./// The mode for applying the watershed algorithm.void setAlgorithmMode(constHExtremaWatershed::AlgorithmMode& algorithmMode );/// Gets the neighborhood parameter./// The 3D neighborhood configuration. This parameter is ignored with a 2D input image.HExtremaWatershed::Neighborhood neighborhood()const;/// Sets the neighborhood parameter./// The 3D neighborhood configuration. This parameter is ignored with a 2D input image.void setNeighborhood(constHExtremaWatershed::Neighborhood& neighborhood );/// Gets the outputImage parameter./// The output grayscale, binary or label image. Its dimensions are forced to the same values as the input image. Its type depends on the outputType parameter.
std::shared_ptr< iolink::ImageView> outputImage()const;/// Sets the outputImage parameter./// The output grayscale, binary or label image. Its dimensions are forced to the same values as the input image. Its type depends on the outputType parameter.void setOutputImage( std::shared_ptr< iolink::ImageView> outputImage );// Method to launch the command.void execute();
# Property of the inputGrayImage parameter.HExtremaWatershed.input_gray_image
# Property of the objectLightness parameter.HExtremaWatershed.object_lightness
# Property of the contrastValue parameter.HExtremaWatershed.contrast_value
# Property of the outputType parameter.HExtremaWatershed.output_type
# Property of the algorithmMode parameter.HExtremaWatershed.algorithm_mode
# Property of the neighborhood parameter.HExtremaWatershed.neighborhood
# Property of the outputImage parameter.HExtremaWatershed.output_image
// Method to launch the command.
execute()
// Command constructor.HExtremaWatershed()// Property of the inputGrayImage parameter.HExtremaWatershed.inputGrayImage
// Property of the objectLightness parameter.HExtremaWatershed.objectLightness
// Property of the contrastValue parameter.HExtremaWatershed.contrastValue
// Property of the outputType parameter.HExtremaWatershed.outputType
// Property of the algorithmMode parameter.HExtremaWatershed.algorithmMode
// Property of the neighborhood parameter.HExtremaWatershed.neighborhood
// Property of the outputImage parameter.HExtremaWatershed.outputImage
// Method to launch the command.Execute()
Parameters
Parameter Name
Description
Type
Supported Values
Default Value
inputGrayImage
The input grayscale image.
Image
Grayscale
nullptr
objectLightness
The lightness of objects to separate.
DARK_OBJECTS
The watershed is directly applied on the input image in order to separate dark areas.
BRIGHT_OBJECTS
The watershed is applied on the negative of the input image in order to separate bright areas.
Enumeration
DARK_OBJECTS
outputType
The type of result image.
SEPARATED_OBJECTS
The result image is a grayscale image representing the original from which separation lines are added to dark objects or subtracted from bright objects (split areas).
WATERSHED_RIDGES
The result image is a binary image representing the separation lines (watershed).
SEPARATED_BASINS
The result image is a label image representing the catchment areas (labeled complement of the watershed).
CONTIGUOUS_BASINS
The result image is a label image representing the catchment areas with separation lines filled by a label.
Enumeration
SEPARATED_OBJECTS
algorithmMode
The mode for applying the watershed algorithm.
REPEATABLE
The result is repeatable but slower to compute.
FAST
The result is faster to compute but not repeatable because of asynchronous parallel computation. Since a watershed problem does not generally have a unique solution, two processings of the same image can lead to two different results (both exact).
Enumeration
REPEATABLE
contrastValue
The depth of the valley used to select the markers of the watershed.
Int32
>=0
30
neighborhood
The 3D neighborhood configuration. This parameter is ignored with a 2D input image.
CONNECTIVITY_6
The structuring element is composed of voxels with a common face with the voxel of interest.
CONNECTIVITY_18
The structuring element is composed of voxels with at least one common edge.
CONNECTIVITY_26
The structuring element is a full cube.
Enumeration
CONNECTIVITY_26
outputImage
The output grayscale, binary or label image. Its dimensions are forced to the same values as the input image. Its type depends on the outputType parameter.
Image
nullptr
Parameter Name
Description
Type
Supported Values
Default Value
input_gray_image
The input grayscale image.
image
Grayscale
None
object_lightness
The lightness of objects to separate.
DARK_OBJECTS
The watershed is directly applied on the input image in order to separate dark areas.
BRIGHT_OBJECTS
The watershed is applied on the negative of the input image in order to separate bright areas.
enumeration
DARK_OBJECTS
output_type
The type of result image.
SEPARATED_OBJECTS
The result image is a grayscale image representing the original from which separation lines are added to dark objects or subtracted from bright objects (split areas).
WATERSHED_RIDGES
The result image is a binary image representing the separation lines (watershed).
SEPARATED_BASINS
The result image is a label image representing the catchment areas (labeled complement of the watershed).
CONTIGUOUS_BASINS
The result image is a label image representing the catchment areas with separation lines filled by a label.
enumeration
SEPARATED_OBJECTS
algorithm_mode
The mode for applying the watershed algorithm.
REPEATABLE
The result is repeatable but slower to compute.
FAST
The result is faster to compute but not repeatable because of asynchronous parallel computation. Since a watershed problem does not generally have a unique solution, two processings of the same image can lead to two different results (both exact).
enumeration
REPEATABLE
contrast_value
The depth of the valley used to select the markers of the watershed.
int32
>=0
30
neighborhood
The 3D neighborhood configuration. This parameter is ignored with a 2D input image.
CONNECTIVITY_6
The structuring element is composed of voxels with a common face with the voxel of interest.
CONNECTIVITY_18
The structuring element is composed of voxels with at least one common edge.
CONNECTIVITY_26
The structuring element is a full cube.
enumeration
CONNECTIVITY_26
output_image
The output grayscale, binary or label image. Its dimensions are forced to the same values as the input image. Its type depends on the outputType parameter.
image
None
Parameter Name
Description
Type
Supported Values
Default Value
inputGrayImage
The input grayscale image.
Image
Grayscale
null
objectLightness
The lightness of objects to separate.
DARK_OBJECTS
The watershed is directly applied on the input image in order to separate dark areas.
BRIGHT_OBJECTS
The watershed is applied on the negative of the input image in order to separate bright areas.
Enumeration
DARK_OBJECTS
outputType
The type of result image.
SEPARATED_OBJECTS
The result image is a grayscale image representing the original from which separation lines are added to dark objects or subtracted from bright objects (split areas).
WATERSHED_RIDGES
The result image is a binary image representing the separation lines (watershed).
SEPARATED_BASINS
The result image is a label image representing the catchment areas (labeled complement of the watershed).
CONTIGUOUS_BASINS
The result image is a label image representing the catchment areas with separation lines filled by a label.
Enumeration
SEPARATED_OBJECTS
algorithmMode
The mode for applying the watershed algorithm.
REPEATABLE
The result is repeatable but slower to compute.
FAST
The result is faster to compute but not repeatable because of asynchronous parallel computation. Since a watershed problem does not generally have a unique solution, two processings of the same image can lead to two different results (both exact).
Enumeration
REPEATABLE
contrastValue
The depth of the valley used to select the markers of the watershed.
Int32
>=0
30
neighborhood
The 3D neighborhood configuration. This parameter is ignored with a 2D input image.
CONNECTIVITY_6
The structuring element is composed of voxels with a common face with the voxel of interest.
CONNECTIVITY_18
The structuring element is composed of voxels with at least one common edge.
CONNECTIVITY_26
The structuring element is a full cube.
Enumeration
CONNECTIVITY_26
outputImage
The output grayscale, binary or label image. Its dimensions are forced to the same values as the input image. Its type depends on the outputType parameter.