Get image pixel coordinates grid, ranging in [0, width - 1] and [0, height - 1]. `image[i, j]` has pixel center coordinates `(j, i)`. >>> image_pixel_center(10, 10): [[[0, 0], [1, 0], ..., [9, 0]], [[0, 1.5], [1, 1], ..., [9, 1]], ... ... ...
(
height: int,
width: int,
left: int = None,
top: int = None,
right: int = None,
bottom: int = None,
dtype: np.dtype = np.int32
)
| 426 | return np.stack([u, v], axis=2) |
| 427 | |
| 428 | def image_pixel( |
| 429 | height: int, |
| 430 | width: int, |
| 431 | left: int = None, |
| 432 | top: int = None, |
| 433 | right: int = None, |
| 434 | bottom: int = None, |
| 435 | dtype: np.dtype = np.int32 |
| 436 | ) -> np.ndarray: |
| 437 | """ |
| 438 | Get image pixel coordinates grid, ranging in [0, width - 1] and [0, height - 1]. |
| 439 | `image[i, j]` has pixel center coordinates `(j, i)`. |
| 440 | |
| 441 | >>> image_pixel_center(10, 10): |
| 442 | [[[0, 0], [1, 0], ..., [9, 0]], |
| 443 | [[0, 1.5], [1, 1], ..., [9, 1]], |
| 444 | ... ... ... |
| 445 | [[0, 9.5], [1, 9], ..., [9, 9 ]]] |
| 446 | |
| 447 | Args: |
| 448 | width (int): image width |
| 449 | height (int): image height |
| 450 | |
| 451 | Returns: |
| 452 | np.ndarray: shape (height, width, 2) |
| 453 | """ |
| 454 | if left is None: left = 0 |
| 455 | if top is None: top = 0 |
| 456 | if right is None: right = width |
| 457 | if bottom is None: bottom = height |
| 458 | u = np.arange(left, right, dtype=dtype) |
| 459 | v = np.arange(top, bottom, dtype=dtype) |
| 460 | u, v = np.meshgrid(u, v, indexing='xy') |
| 461 | return np.stack([u, v], axis=2) |
| 462 | |
| 463 | |
| 464 | def image_mesh( |
nothing calls this directly
no outgoing calls
no test coverage detected