(cfg: Config, mtn: np.ndarray, ridges: np.ndarray)
| 483 | |
| 484 | |
| 485 | def thin_mountains(cfg: Config, mtn: np.ndarray, ridges: np.ndarray) -> np.ndarray: |
| 486 | out = mtn.copy() |
| 487 | rows, cols = out.shape |
| 488 | for _ in range(max(0, int(cfg.mountain_thin_passes))): |
| 489 | kill = [] |
| 490 | for r in range(rows): |
| 491 | for c in range(cols): |
| 492 | if not out[r, c]: |
| 493 | continue |
| 494 | n = neighbor_count(out, r, c) |
| 495 | if n >= cfg.mountain_thin_remove_ge: |
| 496 | if float(ridges[r, c]) < cfg.mountain_thin_junction_ridge: |
| 497 | kill.append((r, c)) |
| 498 | elif n == 0: |
| 499 | kill.append((r, c)) |
| 500 | if not kill: |
| 501 | break |
| 502 | for r, c in kill: |
| 503 | out[r, c] = False |
| 504 | return prune_specks(cfg, out, "mtn_speck", cfg.mountain_speck_prune_passes) |
| 505 | |
| 506 | |
| 507 | def build_fields(cfg: Config): |
no test coverage detected