(cfg: Config, mask: np.ndarray, tag: str, passes: int, kill_prob: float = 0.70)
| 462 | |
| 463 | |
| 464 | def prune_specks(cfg: Config, mask: np.ndarray, tag: str, passes: int, kill_prob: float = 0.70) -> np.ndarray: |
| 465 | out = mask.copy() |
| 466 | rows, cols = out.shape |
| 467 | for _ in range(max(0, int(passes))): |
| 468 | kill = [] |
| 469 | for r in range(rows): |
| 470 | for c in range(cols): |
| 471 | if not out[r, c]: |
| 472 | continue |
| 473 | n = neighbor_count(out, r, c) |
| 474 | if n == 0: |
| 475 | kill.append((r, c)) |
| 476 | elif n == 1 and hash01(cfg.seed, r, c, tag) < kill_prob: |
| 477 | kill.append((r, c)) |
| 478 | if not kill: |
| 479 | break |
| 480 | for r, c in kill: |
| 481 | out[r, c] = False |
| 482 | return out |
| 483 | |
| 484 | |
| 485 | def thin_mountains(cfg: Config, mtn: np.ndarray, ridges: np.ndarray) -> np.ndarray: |
no test coverage detected