get x chessboard image Args: width (int): image width height (int): image height grid_size (int): size of chessboard grid color_a (np.ndarray): color of the grid at the top-left corner color_b (np.ndarray): color in complementary grid cells Returns:
(width: int, height: int, grid_size: int, color_a: np.ndarray, color_b: np.ndarray)
| 568 | |
| 569 | |
| 570 | def chessboard(width: int, height: int, grid_size: int, color_a: np.ndarray, color_b: np.ndarray) -> np.ndarray: |
| 571 | """get x chessboard image |
| 572 | |
| 573 | Args: |
| 574 | width (int): image width |
| 575 | height (int): image height |
| 576 | grid_size (int): size of chessboard grid |
| 577 | color_a (np.ndarray): color of the grid at the top-left corner |
| 578 | color_b (np.ndarray): color in complementary grid cells |
| 579 | |
| 580 | Returns: |
| 581 | image (np.ndarray): shape (height, width, channels), chessboard image |
| 582 | """ |
| 583 | x = np.arange(width) // grid_size |
| 584 | y = np.arange(height) // grid_size |
| 585 | mask = (x[None, :] + y[:, None]) % 2 |
| 586 | image = (1 - mask[..., None]) * color_a + mask[..., None] * color_b |
| 587 | return image |
| 588 | |
| 589 | |
| 590 | def square(tri: bool = False) -> Tuple[np.ndarray, np.ndarray]: |
nothing calls this directly
no outgoing calls
no test coverage detected