(a: np.ndarray, wx: np.ndarray, wy: np.ndarray)
| 376 | |
| 377 | |
| 378 | def warp_int(a: np.ndarray, wx: np.ndarray, wy: np.ndarray) -> np.ndarray: |
| 379 | rows, cols = a.shape |
| 380 | rr = np.arange(rows, dtype=np.int32)[:, None] |
| 381 | cc = np.arange(cols, dtype=np.int32)[None, :] |
| 382 | r2 = np.clip(rr + wy.astype(np.int32), 0, rows - 1) |
| 383 | c2 = np.clip(cc + wx.astype(np.int32), 0, cols - 1) |
| 384 | return a[r2, c2] |
| 385 | |
| 386 | |
| 387 | def hex_bfs_distance(mask_sources: np.ndarray) -> np.ndarray: |