quickpaver.binary_dilation#
- quickpaver.binary_dilation(seed_mask: ndarray[tuple[Any, ...], dtype[bool]], domain_mask: ndarray[tuple[Any, ...], dtype[bool]], iterations: int = 1) ndarray[tuple[Any, ...], dtype[bool]][source]#
Dilate a 2D boolean array within a constrained domain.
The dilation uses 4-connectivity, meaning that each
Truecell expands to its direct horizontal and vertical neighbours only. Diagonal neighbours are not included.After each dilation step, cells outside
domain_maskare forced toFalse. This ensures that the dilated region never grows outside the allowed domain.- Parameters:
seed_mask (NDArrayBool) – Initial 2D boolean array to dilate. Cells equal to
Trueare used as dilation seeds.domain_mask (NDArrayBool) – Boolean mask defining where dilation is allowed. Cells equal to
Truebelong to the allowed domain. Cells equal toFalseare excluded and are forced to remainFalsein the output.iterations (int, optional) – Number of dilation iterations to apply, by default 1. Each iteration expands the current
Trueregion by one cell in the four cardinal directions withindomain_mask.
- Returns:
Dilated 2D boolean array with the same shape as
seed_mask. The result is alwaysFalseoutsidedomain_mask.- Return type:
NDArrayBool
- Raises:
ValueError – If
seed_maskanddomain_maskdo not have the same shape.ValueError – If
iterationsis negative.