from_counts#

static rlemasklib.RLEMask.from_counts(counts, shape, order='F', validate_sum=True)[source]#

Create an RLEMask object from run-length counts.

Parameters:
  • counts (Sequence[int]) – the run-length counts of the mask, as a list of integers or a numpy array, where even-indexed elements are runs of 0s and odd-indexed elements are runs of 1s. The sum of the counts must be equal to height * width.

  • shape (Sequence[int]) – [height, width] of the mask

  • order – the order of the counts in the list, either ‘F’ or ‘C’ for Fortran (column major) or C (row major) order

  • validate_sum (bool) – if True (default), validates that the sum of counts equals height * width

Raises:
  • ValueError – if validate_sum is True and the sum of the counts is not equal to height * width.

  • ValueError – if the order is not ‘F’ or ‘C’.

Return type:

RLEMask