decode_mask

cocohelper.utils.segmentation.decode_mask(code, mode, **kwargs)[source]

Decodes a mask using the specified mode. :param code: the encoded mask. :param mode: the mode to use for decoding the mask. :param **kwargs: extra parameters such as:

  • height and width to indicate the shape of the output mask (if mode in [cRLE, polygon]).

  • value to indicate the value of the zero-valued pixels in the output mask (if mode=polygon).

  • dtype to indicate the type of the output mask (if mode in [RLE, cRLE, polygon]).

Returns:

The decoded mask as a numpy array.

Parameters:
  • code (Any) –

  • mode (str) –

Return type:

ndarray