# Image resizer options

Resizing is necessary to make sure every image in the network has the same shape. You can modify the resizer among the preprocessing steps.

{% hint style="success" %}
It is generally recommanded to keep the default resizing values. However there are cases where you would want your model trained on different sizes, for example:

* To adapt to your use-case images if they are smaller/lower quality than your training data
* Mitigating regions with unusual aspect ratios (see [Keep Aspect Ratio resizer](#keep-aspect-ratio-resizer))
  {% endhint %}

{% hint style="info" %}
When experimenting with resizing, in order to see meaningful results, you need to multiply or divide the scales significantly (e.g x2 or x4).
{% endhint %}

## Fixed sized resizer

<figure><img src="https://content.gitbook.com/content/gmfYsBwyGGbiAMWJv9xC/blobs/SJeaFg2mPlNRD2S7i9t4/resizer_fixed.png" alt=""><figcaption><p>Fixed Shape resizer from Studio</p></figcaption></figure>

Here you can set manually the height and width of your images. We enforce an increment of 16 pixels to comply with some architectures convolution constraints (YOLO). Height and width don't need to be equal.

{% hint style="success" %}
This is the recommended option when your image sizes are not extreme (approximately square or 16:9). You generally don't have to worry about slightly distorting your images, even if they lose their "natural" aspect, the network will learn the distorted way, and the performances will be the same. Variance in aspects can even bring some "augmentation" to your data.
{% endhint %}

## Keep Aspect Ratio resizer

<figure><img src="https://content.gitbook.com/content/gmfYsBwyGGbiAMWJv9xC/blobs/0YayJkc0GN3j6M3H8v3w/resizer_aspect.png" alt=""><figcaption><p>Keep Aspect Ratio resizer in Studio</p></figcaption></figure>

This resizer will resize all images to the same size, but it's keeping the original aspect ratio by padding with black pixels. Note that here we are talking about minimum/maximum dimensions, not height/width. The same scaling ratio is applied to both dimensions, such as to match the maximum dimension parameter.

{% hint style="warning" %}
Note that the minimum dimension in pixels parameter is not available in Studio, and it is 1024 by default. You should not set a maximum dimension value lower than 1024, otherwise the preprocessing will crash.
{% endhint %}

The output size can be described by two cases:

1. If the image can be rescaled so its minimum dimension is equal to the provided value without the other dimension exceeding max\_dimension, then do so.
2. Otherwise, resize so the largest dimension is equal to max\_dimension.

#### Examples

* **Example 1**: 600x600 image. min\_dimension is 600. By scaling it to 1024, the max\_dimension will also be 1024.
* **Example 2**: 600x900 image. min\_dimension is 600. By applying the ratio 900\*(1024/600), we get a max\_dimension value of 1536.
  * If you set a max\_dimension value lower than that (e.g 1024), we fall into the case \[2]. So the image is resized to max\_dimension=1024, and min\_dimension is scaled accordingly: 600\*(1024/900).
  * If you set a higher max\_dimension (e.g 2048), we fall into the first case. min\_dimension will be scaled up to 1024, and max\_dimension 1536.

{% hint style="success" %}
The "Keep Aspect Ratio" resizer can be useful when the original images/regions have unusual ratios.&#x20;
{% endhint %}

{% hint style="info" %}
Note that in child view under a detection view, the "images" would actually be the parent regions. Since they are originally bounding boxes matching the objects, these regions could be highly distorted if homogenically resized.
{% endhint %}

&#x20;
