MIL_ID SrcImageBufId, | //in |
MIL_ID MarkerImageBufId, | //in |
MIL_ID DstImageBufId, | //in |
MIL_INT MinVariation, | //in |
MIL_INT64 ControlFlag | //in |
This function performs a watershed transformation on the specified source buffer. The catchment basins of the source buffer can be determined from extrema (minima or maxima) in the source buffer and/or from a specified marker image. In the case when no marker image is specified, a valid catchment basin is determined from an extrema when the minimum variation in gray levels of an extremum's catchment basin is equal to or greater than the value specified by the MinVariation parameter. In the case when a marker image is specified, each marker of a marker image produces catchment basin(s) by forcing an extremum in the corresponding area(s) of the source buffer.
There are two types of marker images: non-labeled and labeled. In a non-labeled marker image, each group of touching pixels with the value zero in the marker image (known as a marker) starts a catchment basin in the corresponding area of the source image. Specifically, each marker in the marker image forces a extremum in the corresponding area of the source image. Pixels in the marker image are considered touching if they are vertically, horizontally, or diagonally adjacent, that is, if they are "8-connected". Note that each catchment basin in the destination image is given a unique grayscale value, starting at 1.
In a labeled marker image, a marker is a set of pixels that do not have to necessarily touch and that have all the same label value (pixel intensity). Each marker starts a catchment basin in the corresponding area of the source image and each catchment basin of the destination image is assigned the label value of the marker that generated it. Note that, in a labeled marker image, a marker can touch other markers, allowing you to specify adjacent catchment basins. Valid marker label values are 1 to 2 n - 2 (where n refers to the number of bits per pixel in the buffer). Pixels with the label value of zero are interpreted as the region of the image that is not a marker. Finally, pixels with the label value of 2 n - 1 are considered to be part of a "don't care" mask and are not processed, accelerating the watershed transformation.
You can specify that the destination buffer contain one of the following:
Watershed lines. The watershed lines are given the value 0 and all other pixels are given the maximum value in the destination buffer.
Labeled catchment basins, without watershed lines. Each catchment basin is assigned a grayscale value greater or equal to 1.
Labeled catchment basins and watershed lines. Each catchment basin is assigned a grayscale value greater or equal to 1. Watershed lines are given the value 0.
For more information, see the Watershed transformations section of Chapter 4: Advanced image processing.
Specifies the buffer on which to perform the transform. This buffer can be 8-bit or 16-bit, signed or unsigned.
This image buffer must not have a region of interest (ROI) associated with it. Using an image buffer with an ROI will cause an error.
Specifies the buffer to use as a marker image. This buffer can be 8-bit or 16-bit, signed or unsigned. If you are not using a marker image, set this parameter to M_NULL.
This image buffer must not have a region of interest (ROI) associated with it. Using an image buffer with an ROI will cause an error.
The default marker image type is non-labeled. If you want to use a labeled marker image, you must add M_LABELED_MARKER to the ControlFlag parameter.
Specifies the buffer in which to place the results of the transformation. This buffer can be 8-bit or 16-bit, signed or unsigned. The destination buffer can hold 2 n - 5 catchment basins, where n refers to the number of bits per pixel in the buffer. Therefore, an 8-bit destination buffer can hold 251 catchment basins and a 16-bit destination buffer can hold 65531 catchment basins.
This image buffer must not have a region of interest (ROI) associated with it. Using an image buffer with an ROI will cause an error.
Specifies the minimum variation of gray-level of a catchment basin. This parameter must be set to one of the values below.
For specifying the minimum variation of
gray-level
|
|||||||||||||||||||||||||||||||||||||||
Value | Description
|
||||||||||||||||||||||||||||||||||||||
M_DEFAULT |
Produces a catchment basin from each extremum in the source buffer. (more details...) |
||||||||||||||||||||||||||||||||||||||
M_OFF |
Specifies that catchment basins will not be determined from extrema in the source buffer. |
||||||||||||||||||||||||||||||||||||||
Value |
Sets the minimum variation. |
Specifies how to perform the transformation. It can be set to any combination of the following seven sets of values below. It can also be set to M_DEFAULT, in which case the default value from each set is used (without M_SKIP_LAST_LEVEL, M_LABELED_MARKER and M_FILL_SOURCE). If no value from a set is specified, its default value is used.
For specifying how to perform the
transformation
|
|||||||||||||||||||||||||||||||||||||||
Value | Description
|
||||||||||||||||||||||||||||||||||||||
M_DEFAULT |
Same as M_WATERSHED + M_MINIMA_FILL + M_REGULAR + M_4_CONNECTED. |
||||||||||||||||||||||||||||||||||||||
M_BASIN + |
Labels catchment basins. |
||||||||||||||||||||||||||||||||||||||
M_WATERSHED + |
Calculates watershed lines. |
||||||||||||||||||||||||||||||||||||||
M_WATERSHED + M_BASIN + |
Labels catchment basin and calculates watershed lines. |
You can add one of the following values to the above-mentioned values to specify whether to use the source buffer's minima or maxima when determining catchment basins from extrema in the source buffer.
For specifying whether to use the source
buffer's minima or maxima
|
|||||||||||||||||||||||||||||||||||||||
Combination value | Description
|
||||||||||||||||||||||||||||||||||||||
M_MAXIMA_FILL |
Uses the source buffer's maxima. |
||||||||||||||||||||||||||||||||||||||
M_MINIMA_FILL |
Uses the source buffer's minima. (more details...) |
You can add one of the following values to the above-mentioned values to specify how the watershed lines are drawn.
For specifying how the watershed lines
are drawn
|
|||||||||||||||||||||||||||||||||||||||
Combination value | Description
|
||||||||||||||||||||||||||||||||||||||
M_REGULAR |
Traces the watershed lines exactly. (more details...) |
||||||||||||||||||||||||||||||||||||||
M_STRAIGHT_WATERSHED |
Forces the watershed lines to be straight. (more details...) |
You can add one of the following values to the above-mentioned values to specify whether 4 or 8-connected watershed lines will be used.
For specifying 4 or 8-connected watershed
lines
|
|||||||||||||||||||||||||||||||||||||||
Combination value | Description
|
||||||||||||||||||||||||||||||||||||||
M_4_CONNECTED |
Uses 4-connected watershed lines. (more details...) |
||||||||||||||||||||||||||||||||||||||
M_8_CONNECTED |
Uses 8-connected watershed lines. |
You can add the following value to the above-mentioned values to specify that an extremum's zone of influence cannot extend past the minimum and maximum gray level.
For preventing an extremum's zone of
influence from extending past the minimum and maximum gray
level
|
|||||||||||||||||||||||||||||||||||||||
Combination value | Description
|
||||||||||||||||||||||||||||||||||||||
M_SKIP_LAST_LEVEL |
Prevents an extremum's zone of influence from extending beyond Lmax - 1 (for a minimum) or Lmin - 1 (for a maximum), where Lmax is the maximum gray level in the image and Lmin is the minimum gray level. |
You can add the following value to the above-mentioned values to specify that the marker image is a labeled marker image.
For denoting that the marker image is
labeled
|
|||||||||||||||||||||||||||||||||||||||
Combination value | Description
|
||||||||||||||||||||||||||||||||||||||
M_LABELED_MARKER |
Specifies that the marker image is a labeled marker image. |
You can add the following value to the above-mentioned values to specify that any unwanted extrema from the source image is removed.
It removes the extrema by filling the catchment basins of unwanted extrema until they become plateaus.
For removing unwanted
extrema
|
|||||||||||||||||||||||||||||||||||||||
Combination value | Description
|
||||||||||||||||||||||||||||||||||||||
M_FILL_SOURCE |
Fill all local basins of a valid catchment basin in the source image. |
Header | Include mil.h. |
Library | Use mil.lib; milim.lib. |
DLL | Requires mil.dll; milim.dll. |