Crop the image(s). Args: img (ndarray): of shape NxHxWxC, or HxWxC or HxW. The array can be of type uint8 in range [0, 255], or floating point in range [0, 1] or [0, 255]. Returns: ndarray: cropped image(s).
(self, img: np.ndarray)
| 175 | self._set_attributes(locals()) |
| 176 | |
| 177 | def apply_image(self, img: np.ndarray) -> np.ndarray: |
| 178 | """ |
| 179 | Crop the image(s). |
| 180 | |
| 181 | Args: |
| 182 | img (ndarray): of shape NxHxWxC, or HxWxC or HxW. The array can be |
| 183 | of type uint8 in range [0, 255], or floating point in range |
| 184 | [0, 1] or [0, 255]. |
| 185 | Returns: |
| 186 | ndarray: cropped image(s). |
| 187 | """ |
| 188 | if len(img.shape) <= 3: |
| 189 | return img[self.y0 : self.y0 + self.h, self.x0 : self.x0 + self.w] |
| 190 | else: |
| 191 | return img[..., self.y0 : self.y0 + self.h, self.x0 : self.x0 + self.w, :] |
| 192 | |
| 193 | def apply_coords(self, coords: np.ndarray) -> np.ndarray: |
| 194 | """ |
nothing calls this directly
no outgoing calls
no test coverage detected