draw.instance_mask
Description
Draws instance segmentation masks.
- class Node(config=None, **kwargs)[source]
Draws instance segmentation masks on image.
The
draw.mask
node draws instance segmentation masks onto the detected object instances.- Inputs
img
(numpy.ndarray
): A NumPy array of shape \((height, width, channels)\) containing the image data in BGR format.masks
(numpy.ndarray
): A NumPy array of shape \((N, H, W)\) containing \(N\) detected binarized masks where \(H\) and \(W\) are the height and width of the masks. The order corresponds to bbox_labels.bbox_labels
(numpy.ndarray
): A NumPy array of shape \((N)\) containing strings representing the labels of detected objects. The order corresponds to bboxes and bbox_scores.- Outputs
img
(numpy.ndarray
): A NumPy array of shape \((height, width, channels)\) containing the image data in BGR format.- Configs
instance_color_scheme (
str
) – {“random”, “hue_family”}, default = “hue_family”
This defines what colors to use for the standard masks.
“hue_family”: use the same hue for each instance belonging to the same class, but with a slightly different saturation.
“random”: use a random color for all instances.effect (
dict
) – {contrast: null, brightness: null, gamma_correction: null, blur: null, mosaic: null}
This defines the effect (if any) to apply to either the masked (objects) or unmasked (background) areas of the image. If no effect is selected, a “standard” instance segmentation mask will be drawn and colored according to the instance_color_scheme.
For example, to apply the contrast effect to the objects in the image, set the following config in pipeline_config.yml:effect : {contrast: 1.2}
Note that at most one effect can be enabled at a time.
Effect
Description
Data Type
Range
contrast
Adjusts contrast using this value as the “alpha” parameter.
float
[0.0, 3.0]
brightness
Adjusts brightness using this value as the “beta” parameter.
int
[-100, 100]
gamma_correction
Adjusts gamma using this value as the “gamma” parameter.
float
[0.0, +inf]
blur
Blurs the area using this value as the “blur_kernel_size” parameter.
Larger values gives more intense blurring.int
[1, +inf]
mosaic
Mosaics the area using this value as the resolution of a mosaic filter
(width × height). The number corresponds to the number of rows
and columns used to create a mosaic. For example, the setting
(mosaic: 25
) creates a \(25 \times 25\) mosaic filter. Increasing
the number increases the intensity of pixelation over an area.int
[1, +inf]
effect_area (
str
) – {“objects”, “background”}, default = “objects”
This defines where the effect should be applied.
“objects”: the effect is applied to the masked areas of the image.
“background”: the effect is applied to the unmasked areas of the image.contours (
dict
) – {show: False, thickness: 2}Contours
Description
Data Type
Range
show
This determines whether to show the contours of the masks.
bool
N.A.
thickness
This defines the thickness of the contours.
int
[1, +inf]