polygon_to_mask

cocohelper.utils.segmentation.polygon_to_mask(polygon_code, width=512, height=512, value=0.0, dtype=<class 'numpy.float32'>, **kwargs)[source]

Creates and returns a mask from polygon in COCO format.

Parameters:
  • polygon_code (List[List]) – polygon coordinates.

  • width (int) – width of the output image array.

  • height (int) – height of the output image array.

  • value (float) – a value used for substituting zero-valued pixels in the output numpy array.

  • dtype (Union[dtype[Any], None, Type[Any], _SupportsDType[dtype[Any]], str, Tuple[Any, int], Tuple[Any, Union[SupportsIndex, Sequence[SupportsIndex]]], List[Any], _DTypeDict, Tuple[Any, Any]]) – an output dtype for the converted mask.

  • **kwargs – extra parameters are ignored.

Returns:

The polygon mask as a numpy array.

Return type:

ndarray