Args: x0, y0, w, h (int): crop the image(s) by img[y0:y0+h, x0:x0+w]. orig_w, orig_h (int): optional, the original width and height before cropping. Needed to make this transform invertible.
(
self,
x0: int,
y0: int,
w: int,
h: int,
orig_w: Optional[int] = None,
orig_h: Optional[int] = None,
)
| 157 | |
| 158 | class CropTransform(Transform): |
| 159 | def __init__( |
| 160 | self, |
| 161 | x0: int, |
| 162 | y0: int, |
| 163 | w: int, |
| 164 | h: int, |
| 165 | orig_w: Optional[int] = None, |
| 166 | orig_h: Optional[int] = None, |
| 167 | ): |
| 168 | """ |
| 169 | Args: |
| 170 | x0, y0, w, h (int): crop the image(s) by img[y0:y0+h, x0:x0+w]. |
| 171 | orig_w, orig_h (int): optional, the original width and height |
| 172 | before cropping. Needed to make this transform invertible. |
| 173 | """ |
| 174 | super().__init__() |
| 175 | self._set_attributes(locals()) |
| 176 | |
| 177 | def apply_image(self, img: np.ndarray) -> np.ndarray: |
| 178 | """ |
nothing calls this directly
no test coverage detected