Apply Non-Maximum Suppression (NMS) horizontally on the given ratio matrix. Args: ---- ratio (np.ndarray): Input ratio matrix. threshold (float): Threshold for NMS. Returns: ------- np.ndarray: Binary mask after applying NMS.
(ratio: np.ndarray, threshold: float)
| 27 | |
| 28 | |
| 29 | def nms_horizontal(ratio: np.ndarray, threshold: float) -> np.ndarray: |
| 30 | """Apply Non-Maximum Suppression (NMS) horizontally on the given ratio matrix. |
| 31 | |
| 32 | Args: |
| 33 | ---- |
| 34 | ratio (np.ndarray): Input ratio matrix. |
| 35 | threshold (float): Threshold for NMS. |
| 36 | |
| 37 | Returns: |
| 38 | ------- |
| 39 | np.ndarray: Binary mask after applying NMS. |
| 40 | |
| 41 | """ |
| 42 | mask = np.zeros_like(ratio, dtype=bool) |
| 43 | r, c = np.nonzero(ratio > threshold) |
| 44 | if len(r) == 0: |
| 45 | return mask |
| 46 | for ids in connected_component(r, c): |
| 47 | values = [ratio[r[i], c[i]] for i in ids] |
| 48 | mi = np.argmax(values) |
| 49 | mask[r[ids[mi]], c[ids[mi]]] = True |
| 50 | return mask |
| 51 | |
| 52 | |
| 53 | def nms_vertical(ratio: np.ndarray, threshold: float) -> np.ndarray: |
no test coverage detected