Apply binary mask, or thresholding based on bit mask value (mapping mask is binary). Returns the mapped true value mask and its complementary false value mask. Example: >>> img = np.array([[[108, 201, 72], [255, 11, 127]], ... [[56, 56, 56], [128
(
image_gray: np.ndarray, image_map: np.ndarray
)
| 193 | |
| 194 | |
| 195 | def binary_mask( |
| 196 | image_gray: np.ndarray, image_map: np.ndarray |
| 197 | ) -> tuple[np.ndarray, np.ndarray]: |
| 198 | """ |
| 199 | Apply binary mask, or thresholding based |
| 200 | on bit mask value (mapping mask is binary). |
| 201 | |
| 202 | Returns the mapped true value mask and its complementary false value mask. |
| 203 | |
| 204 | Example: |
| 205 | >>> img = np.array([[[108, 201, 72], [255, 11, 127]], |
| 206 | ... [[56, 56, 56], [128, 255, 107]]]) |
| 207 | >>> gray = grayscale(img) |
| 208 | >>> binary = binarize(gray) |
| 209 | >>> morphological = opening_filter(binary) |
| 210 | >>> binary_mask(gray, morphological) |
| 211 | (array([[1, 1], |
| 212 | [1, 1]], dtype=uint8), array([[158, 97], |
| 213 | [ 56, 200]], dtype=uint8)) |
| 214 | """ |
| 215 | true_mask, false_mask = image_gray.copy(), image_gray.copy() |
| 216 | true_mask[image_map == 1] = 1 |
| 217 | false_mask[image_map == 0] = 0 |
| 218 | |
| 219 | return true_mask, false_mask |
| 220 | |
| 221 | |
| 222 | def matrix_concurrency(image: np.ndarray, coordinate: tuple[int, int]) -> np.ndarray: |
no test coverage detected