merge_count#

static rlemasklib.RLEMask.merge_count(masks, threshold)[source]#

Return a mask where each pixel is set if and only if at least threshold of the input masks have that pixel set.

For example, if threshold is set as half the number of masks, then the result will be the majority vote of the masks.

Parameters:
  • masks (Sequence[RLEMask]) – a list of RLEMask objects

  • threshold (int) – the minimum number of masks that must have a pixel set for it to be set in the result

Returns:

A new RLEMask object representing the merged mask.

Return type:

RLEMask

Examples

Majority vote (at least 2 of 3 masks must agree):

merge_count([, , ], threshold=2) ==