1
$\begingroup$

I have a script to download images, but the images are of different resolutions so I have written a script to shrink the image. I have two options:

size=(224,224)

with cv2

cv2.resize(img,size,interpolation=cv2.INTER_AREA)

with PIL

img.thumbnail(size,Image.ANTIALIAS)

after saving them I see cv2 doesn't maintain the original ratio where as PIL maintains the ratio.

My question :

  1. Maintaining aspect ratio is important or not.

  2. If yes (224,224) is a good choice or should I set it to higher resolution.

Sorry if the question is naive, I am new to image processing.

$\endgroup$
1
  • $\begingroup$ Would you mind putting both images? $\endgroup$ Commented May 28, 2018 at 15:45

1 Answer 1

1
$\begingroup$

Maintaining aspect ratio is important or not.

Yes, it's really important in most cases. As you can read from here, Why does aspect ratio matter? It’s all to do with the relationship of the main subject to the sides of the frame, and the amount of empty space you end up with around the subject. An awareness of the characteristics of the aspect ratio of your particular camera can help you compose better images. It also helps you recognise when cropping to a different aspect ratio will improve the composition of your image.

In deep learning tasks, it depends how you want to feed data to your network. It's better to train your network with real data. Consequently if you are going to face data with standard aspect ratio, you have too keep it during training.

If yes (224,224) is a good choice or should I set it to higher resolution.

Depending on your task 224 may be good or not. In typical classification networks, it is an acceptable size, like the inputs of AlexNet or VGG and such customary nets. For localization tasks, not really. For instance, the input height and width of YOLO is more than that 1.

$\endgroup$
1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.