Flip the image.
| 169 | |
| 170 | |
| 171 | class FlipTransform(Transform): |
| 172 | """ |
| 173 | Flip the image. |
| 174 | """ |
| 175 | def __init__(self, h, w, horiz=True): |
| 176 | """ |
| 177 | Args: |
| 178 | h, w (int): |
| 179 | horiz (bool): whether to flip horizontally or vertically. |
| 180 | """ |
| 181 | self._init(locals()) |
| 182 | |
| 183 | def apply_image(self, img): |
| 184 | if self.horiz: |
| 185 | return img[:, ::-1] |
| 186 | else: |
| 187 | return img[::-1] |
| 188 | |
| 189 | def apply_coords(self, coords): |
| 190 | if self.horiz: |
| 191 | coords[:, 0] = self.w - coords[:, 0] |
| 192 | else: |
| 193 | coords[:, 1] = self.h - coords[:, 1] |
| 194 | return coords |
| 195 | |
| 196 | |
| 197 | class TransposeTransform(Transform): |
no outgoing calls
no test coverage detected
searching dependent graphs…