MCPcopy
hub / github.com/apple/ml-depth-pro / connected_component

Function connected_component

src/depth_pro/eval/boundary_metrics.py:6–26  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

4
5
6def 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
29def nms_horizontal(ratio: np.ndarray, threshold: float) -> np.ndarray:

Callers 1

nms_horizontalFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected