def _get_augment_params(self, img):
   h, w = img.shape[:2]
   area = h * w
   for _ in range(10):
     targetArea = self.rng.uniform(self.crop_area_fraction, 1.0) * area
     aspectR = self.rng.uniform(self.aspect_ratio_low, self.aspect_ratio_high)
     ww = int(np.sqrt(targetArea * aspectR) + 0.5)
     hh = int(np.sqrt(targetArea / aspectR) + 0.5)
     if self.rng.uniform() < 0.5:
       ww, hh = hh, ww
     if hh <= h and ww <= w:
       x1 = 0 if w == ww else self.rng.randint(0, w - ww)
       y1 = 0 if h == hh else self.rng.randint(0, h - hh)
       return [CropTransform(y1, x1, hh, ww)]
    def get_transform(self, img):
        hmax = self.hmax or img.shape[0]
        wmax = self.wmax or img.shape[1]
        hmin = min(self.hmin, img.shape[0])
        wmin = min(self.wmin, img.shape[1])
        hmax = min(hmax, img.shape[0])
        wmax = min(wmax, img.shape[1])
        h = self.rng.randint(hmin, hmax + 1)
        w = self.rng.randint(wmin, wmax + 1)
        diffh = img.shape[0] - h
        diffw = img.shape[1] - w
        assert diffh >= 0 and diffw >= 0
        y0 = 0 if diffh == 0 else self.rng.randint(diffh)
        x0 = 0 if diffw == 0 else self.rng.randint(diffw)
        crop_aug = CropTransform(y0, x0, h, w)

        return crop_aug