MCPcopy Create free account
hub / github.com/Astropulse/hexmap / thin_mountains

Function thin_mountains

map.py:485–504  ·  view source on GitHub ↗
(cfg: Config, mtn: np.ndarray, ridges: np.ndarray)

Source from the content-addressed store, hash-verified

483
484
485def 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
507def build_fields(cfg: Config):

Callers 1

build_mountainsFunction · 0.85

Calls 2

neighbor_countFunction · 0.85
prune_specksFunction · 0.85

Tested by

no test coverage detected