Answers.Body: <p>There are different questions and even different lines of thought here. Let's go through them</p>
  <p><strong>On resizing</strong></p>
  <ul>
  <li><strong>Why do we need to resize?</strong> To fit the network input which is fixed when nets are no Fully Convolutional Networks (FCN)</li>
  <li><strong>What if my net is FCN?</strong> Still makes sense to resize to bound the dimension of the input features you want to detect (a person on a small image VS big image). Take into account that the kernel sizes do not vary although the image size does.</li>
  </ul>
  <p><strong>On keeping aspect ratio</strong> (or <em>letterbox</em> as some people like to say)</p>
  <ul>
  <li><p><strong>Why to keep aspect ratio?</strong> This is more of a philosophical question. It is believed that keeping the aspect ratio helps the nets to learn the natural variability in object sizes (say a person bounding box can not be super hight and super thin, because that would be a street light).</p>
  </li>
  <li><p><strong>Why not to keep aspect ratio?</strong> If you resize without keeping the aspect ratio and the aspect ratio distortion is not <em>mega super very huge</em>, the networks will still learn. In other words, if your input images don't have crazy aspect ratios, then there is no difference between adding or not a bit of distortion. In fact, sometimes it will even act as a regularization or augmentation.</p>
  </li>
  </ul>
  <p><strong>Conlusion</strong></p>
  <p>As long as your application is not too specific and your input images aspect ratios are bounded (this is, if  you train with images from any regular camera), you should not worry too much about this.</p>
  <p><em><strong>When to worry about this?</strong></em> When you train with huge vertical or horizontal images or if you train with images taken from some very specific devices like geophisical, radio, or optical sensors. In these cases you should pay special attention on how to resize or split an image. For example, with a recording of a radio sensor, if you resize with aspect ratio deformation, a wave from a specific frequency would transform to another because of the sine wave warp)</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-11-07T04:23:48.933Z
Answers.Text: Thank you for your answer, I agree with you at the conclusion, I am trying something like that right now. However, I am not sure when you mention "philosophical" in a technical problem, I think it should be explained by mathematics or at least, logical way. Let see [this answer](https://stats.stackexchange.com/questions/494388/resize-image-in-object-detection-task-of-computer-vision/494624#494624), I will give you a vote, but not the correct answers.
Answers.UserDisplayName: CuCaRot
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-11-07T10:20:32.187Z
Answers.Text: Thanks and no prob man, I write for the community. But just for the record, I work in applied research on AI and most of the research and product we build are first based on some philosophical assumptions, then we model those assumptions in math, and then we run the math in python. AI is still a very open field, that is why I love it, so there is not always a closed answer for everything.
Answers.UserDisplayName: JVGD
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-11-07T12:38:36.527Z
Answers.Text: I agree, all of the deep learning ideas that I knew came from the philosophical assumptions, you are doing an amazing job, I will try solving in that direction in the next project.
Answers.UserDisplayName: CuCaRot
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-11-06T13:51:12.850Z
Answers.LastActivityDate: 2020-11-06T13:51:12.850Z
Answers.UserDisplayName: JVGD
Body: <p>In object detection, we can resize images by keeping the ratio the same as the original image, which is often known as &quot;letterbox&quot; resize.</p>
  <p>My questions are</p>
  <ol>
  <li><p>Why do we need to resize images? If we resize images to have all the same dimensions, given that some original images are too long vertically or horizontally, we will lose a lot of features in those images.</p>
  </li>
  <li><p>If the &quot;letterbox&quot; method is better than &quot;normal resize&quot; (i.e. without keeping the aspect ratio, e.g. the result of the application of <a href="https://docs.opencv.org/master/da/d54/group__imgproc__transform.html#ga47a974309e9102f5f08231edc7e7529d" rel="nofollow noreferrer">OpenCV's <code>resize</code> function with the parameter <code>interpolation</code> set to <code>cv2.INTER_AREA</code></a>), why don't people apply it in the classification task?</p>
  </li>
  </ol>
  
Tags: <classification><computer-vision><object-detection><image-processing><data-preprocessing>
Title: Why do we resize images before using them for object detection?
UserDisplayName: CuCaRot
ThreadText: # Why do we resize images before using them for object detection?
  
  (Asked by: username_0 on 2020-10-30)
  
  In object detection, we can resize images by keeping the ratio the same as the original image, which is often known as "letterbox" resize.
  
  My questions are
  
  1. Why do we need to resize images? If we resize images to have all the same dimensions, given that some original images are too long vertically or horizontally, we will lose a lot of features in those images.
  2. If the "letterbox" method is better than "normal resize" (i.e. without keeping the aspect ratio, e.g. the result of the application of [OpenCV's `resize` function with the parameter `interpolation` set to `cv2.INTER_AREA`](https://docs.opencv.org/master/da/d54/group__imgproc__transform.html#ga47a974309e9102f5f08231edc7e7529d)), why don't people apply it in the classification task?
  
  **Tags:** classification, computer-vision, object-detection, image-processing, data-preprocessing
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2020-11-06. Score: 3
  
  There are different questions and even different lines of thought here. Let's go through them
  
  **On resizing**
  
  * **Why do we need to resize?** To fit the network input which is fixed when nets are no Fully Convolutional Networks (FCN)
  * **What if my net is FCN?** Still makes sense to resize to bound the dimension of the input features you want to detect (a person on a small image VS big image). Take into account that the kernel sizes do not vary although the image size does.
  
  **On keeping aspect ratio** (or *letterbox* as some people like to say)
  
  * **Why to keep aspect ratio?** This is more of a philosophical question. It is believed that keeping the aspect ratio helps the nets to learn the natural variability in object sizes (say a person bounding box can not be super hight and super thin, because that would be a street light).
  * **Why not to keep aspect ratio?** If you resize without keeping the aspect ratio and the aspect ratio distortion is not *mega super very huge*, the networks will still learn. In other words, if your input images don't have crazy aspect ratios, then there is no difference between adding or not a bit of distortion. In fact, sometimes it will even act as a regularization or augmentation.
  
  **Conlusion**
  
  As long as your application is not too specific and your input images aspect ratios are bounded (this is, if you train with images from any regular camera), you should not worry too much about this.
  
  ***When to worry about this?*** When you train with huge vertical or horizontal images or if you train with images taken from some very specific devices like geophisical, radio, or optical sensors. In these cases you should pay special attention on how to resize or split an image. For example, with a recording of a radio sensor, if you resize with aspect ratio deformation, a wave from a specific frequency would transform to another because of the sine wave warp)
  
  > **Comments:**
  > **username_0**: Thank you for your answer, I agree with you at the conclusion, I am trying something like that right now. However, I am not sure when you mention "philosophical" in a technical problem, I think it should be explained by mathematics or at least, logical way. Let see [this answer](https://stats.stackexchange.com/questions/494388/resize-image-in-object-detection-task-of-computer-vision/494624#494624), I will give you a vote, but not the correct answers.  
  > **username_1**: Thanks and no prob man, I write for the community. But just for the record, I work in applied research on AI and most of the research and product we build are first based on some philosophical assumptions, then we model those assumptions in math, and then we run the math in python. AI is still a very open field, that is why I love it, so there is not always a closed answer for everything.  
  > **username_0**: I agree, all of the deep learning ideas that I knew came from the philosophical assumptions, you are doing an amazing job, I will try solving in that direction in the next project.  
  
  ---
  
  