aleju / imgaug

Image augmentation for machine learning experiments.
http://imgaug.readthedocs.io
MIT License
14.42k stars 2.44k forks source link

Resizing min/max side #757

Open hgaiser opened 3 years ago

hgaiser commented 3 years ago

I was wondering if I can use imgaug to resize an image using the logic often used in object detection algorithms. It works like this in pseudo code (or a pytorch example):

fn scale_image(image, scaled_min_side, scaled_max_side) {
    min_side = min(image.shape)
    max_side = max(image.shape)
    scale = min(scaled_min_side / min_side, scaled_max_side / max_side)
    return image.resize(scale)
}

It seems a similar thing is possible by using shorter-side and longer-side in Resize, but it only allows keeping the same aspect ratio by defining a shorter-side OR a longer-side.

I would expect something like:

iaa.Resize({"shorter-side": 500, "longer-side": "1000", "mode": "keep-aspect-ratio"})