Flip the image(s). Args: img (ndarray): of shape HxW, HxWxC, or NxHxWxC. The array can be of type uint8 in range [0, 255], or floating point in range [0, 1] or [0, 255]. Returns: ndarray: the flipped image(s).
(self, img: np.ndarray)
| 88 | self._set_attributes(locals()) |
| 89 | |
| 90 | def apply_image(self, img: np.ndarray) -> np.ndarray: |
| 91 | """ |
| 92 | Flip the image(s). |
| 93 | |
| 94 | Args: |
| 95 | img (ndarray): of shape HxW, HxWxC, or NxHxWxC. The array can be |
| 96 | of type uint8 in range [0, 255], or floating point in range |
| 97 | [0, 1] or [0, 255]. |
| 98 | Returns: |
| 99 | ndarray: the flipped image(s). |
| 100 | """ |
| 101 | tensor = torch.from_numpy(np.ascontiguousarray(img)) |
| 102 | if len(tensor.shape) == 2: |
| 103 | # For dimension of HxW. |
| 104 | tensor = tensor.flip((-2)) |
| 105 | elif len(tensor.shape) > 2: |
| 106 | # For dimension of HxWxC, NxHxWxC. |
| 107 | tensor = tensor.flip((-3)) |
| 108 | return tensor.numpy() |
| 109 | |
| 110 | def apply_coords(self, coords: np.ndarray) -> np.ndarray: |
| 111 | """ |
nothing calls this directly
no outgoing calls
no test coverage detected