Collect pixel colors from each frame's image according to a mask. Args: images_raw: Tensor (N, 3, H, W) [0, 1] mask_per_frame: (N, H, W) bool Returns: (M, 3) float32
(images_raw, mask_per_frame)
| 321 | |
| 322 | |
| 323 | def _collect_colors(images_raw, mask_per_frame): |
| 324 | """Collect pixel colors from each frame's image according to a mask. |
| 325 | |
| 326 | Args: |
| 327 | images_raw: Tensor (N, 3, H, W) [0, 1] |
| 328 | mask_per_frame: (N, H, W) bool |
| 329 | |
| 330 | Returns: |
| 331 | (M, 3) float32 |
| 332 | """ |
| 333 | colors = [] |
| 334 | N = len(mask_per_frame) |
| 335 | for i in range(N): |
| 336 | mask = mask_per_frame[i] |
| 337 | if not mask.any(): |
| 338 | continue |
| 339 | img = images_raw[i].permute(1, 2, 0).numpy() |
| 340 | colors.append(img[mask]) |
| 341 | return np.concatenate(colors, axis=0) if colors else np.zeros((0, 3), dtype=np.float32) |
| 342 | |
| 343 | |
| 344 | def save_scene_inputs(scene, inputs_dir): |
no outgoing calls
no test coverage detected