# Min_scale and ratio in RandomResizedCrop

What is the difference between min_scale and ratio in RandomResizedCrop? I did not understand the documentation Data augmentation in computer vision | fastai. As I understand, min_scale=0.8 means a random area of 80% of the image is cropped. What is the purpose of ratio then?

I’ve checked the source code (link is also in the docs) and found this part

area = random.uniform(self.min_scale, self.max_scale) * w * h
ratio = math.exp(random.uniform(math.log(self.ratio), math.log(self.ratio)))
nw = int(round(math.sqrt(area * ratio)))
nh = int(round(math.sqrt(area / ratio)))

So I guess the ratio is to add some more randomeness

1 Like

Thank you for the reply. But why is it done like that?

Hey @s_j
Like how `min_scale` and `max_scale` define how much of the image should be cropped from the original, the ratio defines in what aspect ratio should this image be cropped.

For example, let `min_scale = 0.6` and `max_scale = 0.8`. The augmentation picks a number between 0.6 and 0.8. Lets say 0.7. Now, 70% of the image needs to be selected. This could happen in an equal 1:1 width to height ratio `(height = width)`, or this ratio could be 3 : 4 width to height. `(width = (3/4) * height)`. The ratio parameter defines this. It gives us more augmentations.

2 Likes

That makes sense. Thank you @dhruv.metha