__setitem__#

rlemasklib.RLEMask.__setitem__(key, value)[source]#

Set the value of a submask to either a constant or another RLE or dense mask.

Parameters:
  • key (Union[tuple[slice], tuple[int]]) – a tuple of two slices, one for height and one for width

  • value (Union[int, RLEMask, ndarray]) – either a constant (0 or 1) or another RLEMask or a numpy mask with the same size as the submask

Examples

>>> rle = RLEMask.ones((4, 4))
>>> rle[1:3, 2:4] = 0
>>> np.array(rle)
array([[1, 1, 1, 1],
       [1, 1, 0, 0],
       [1, 1, 0, 0],
       [1, 1, 1, 1]], dtype=uint8)