merge_many_custom#

static rlemasklib.RLEMask.merge_many_custom(masks, func)[source]#

Merge many masks using a custom n-ary boolean function.

This first calls func with all combinations of n boolean arguments and stores the resulting truth table. It then returns a new mask where the ith pixel is the result of func applied to the ith pixel of all input masks.

Parameters:
  • masks (Sequence[RLEMask]) – a sequence of at RLE masks

  • func (Callable[Ellipsis, bool]) – a callable that takes n bools and returns a bool

Returns:

A new RLEMask with the merged result.

Return type:

RLEMask

Examples

Compute (A or B) and not C:

merge_many_custom([, , ], lambda a, b, c: (a or b) and not c) ==

See also

merge_many(), which allows merging with binary Boolean functions. make_merge_function(), which creates a merge function from a custom n-ary function.