# How to correctly resize input images in a CNN?

I have a training set composed of images having different width and height, I need to resize them to a fix dimension nxn or nxm before passing them as the input of a CNN.

I would like to know which parameters I need to take into account for correctly choose the new scaled dimensions n and m.

I have a suggestion for you. Maybe not complete enough to be a complete solution but that is exactly what I've experienced. Suppose that you have writings in a paper and the paper is a part of a scene, or you have boys with nice mustaches which are beside a wide scene. In such cases which you have special information which are significant for classifying, the first one may help the classifier recognize book and written things and the second one can help the classifier find the gender of people in the scene, try to resize the images in a way that such significant things be recognizable to the human. If humans can understand them, you can hope that your classifier will be able too. Consider that you shouldn't resize the images to small pixels to avoid your net being with lots parameters. If you resize the images to too small ones, you may loose important information.

• There are some good strategies to find the right images' size, or I have to try empirically? – Simone Jan 28 '18 at 17:33
• @Simone actually I've not seen a paper, but there may be. – Media Jan 28 '18 at 17:42

Two solutions:

1. Crop images to a fixed size
2. Pad images to a fixed size with 0s.

Keep in mind if you are doing segmentation, gt masks have to be cropped/padded too.

• How can I find the right size for images having different sizes? – Simone Jan 28 '18 at 16:15
• Are you using GPU? There should be VRAM constraints – Alex Jan 28 '18 at 18:50