Find connected components in the given row and column indices. Args: ---- r (np.ndarray): Row indices. c (np.ndarray): Column indices. Yields: ------ List[int]: Indices of connected components.
(r: np.ndarray, c: np.ndarray)
| 4 | |
| 5 | |
| 6 | def connected_component(r: np.ndarray, c: np.ndarray) -> List[List[int]]: |
| 7 | """Find connected components in the given row and column indices. |
| 8 | |
| 9 | Args: |
| 10 | ---- |
| 11 | r (np.ndarray): Row indices. |
| 12 | c (np.ndarray): Column indices. |
| 13 | |
| 14 | Yields: |
| 15 | ------ |
| 16 | List[int]: Indices of connected components. |
| 17 | |
| 18 | """ |
| 19 | indices = [0] |
| 20 | for i in range(1, r.size): |
| 21 | if r[i] == r[indices[-1]] and c[i] == c[indices[-1]] + 1: |
| 22 | indices.append(i) |
| 23 | else: |
| 24 | yield indices |
| 25 | indices = [i] |
| 26 | yield indices |
| 27 | |
| 28 | |
| 29 | def nms_horizontal(ratio: np.ndarray, threshold: float) -> np.ndarray: |