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)
| 36 | self._set_attributes(locals()) |
| 37 | |
| 38 | def apply_image(self, img: np.ndarray) -> np.ndarray: |
| 39 | """ |
| 40 | Flip the image(s). |
| 41 | |
| 42 | Args: |
| 43 | img (ndarray): of shape HxW, HxWxC, or NxHxWxC. The array can be |
| 44 | of type uint8 in range [0, 255], or floating point in range |
| 45 | [0, 1] or [0, 255]. |
| 46 | Returns: |
| 47 | ndarray: the flipped image(s). |
| 48 | """ |
| 49 | # NOTE: opencv would be faster: |
| 50 | # https://github.com/pytorch/pytorch/issues/16424#issuecomment-580695672 |
| 51 | if img.ndim <= 3: # HxW, HxWxC |
| 52 | return np.flip(img, axis=1) |
| 53 | else: |
| 54 | return np.flip(img, axis=-2) |
| 55 | |
| 56 | def apply_coords(self, coords: np.ndarray) -> np.ndarray: |
| 57 | """ |
nothing calls this directly
no outgoing calls
no test coverage detected