

Dividing 18/24 by 6, you get 3/4, or a 3:4 aspect ratio. Factor your width and height to the lowest common denominator and you will have your aspect ratio.įor example, if you have a painting that is 18″x24″, then you factor 18/24 to its lowestĬommon denominator to understand the ratio.
RESIZE IMAGE CALCULATOR HOW TO
Even if you only finished 8th grade, you know how to figure out aspect ratios if you can remember how to factor fractions. Everybody had to do basic fractions to get out of middle school. Luckily for us, OpenCV provides a couple of different interpolations methods while maintaining our image’s aspect ratio during resizing.īefore diving deep into these interpolation techniques OpenCV provides for us: first, let’s make a new script, naming it opencv_resize_interpolation.Understanding aspect ratios can be intimidating, but it’s really quite easy. Now, rewiring your mind to project the definition towards images, you can refer to interpolation as a method that decides which pixel gets the value based on its neighboring pixel either when increasing or decreasing the size of the image. Image interpolation refers to the “guess” of intensity values at missing locations. Interpolation is a method of constructing new data points within the range of a discrete set of known data points. You might have come across the interpolation argument being passed while calling the cv2.resize command or during one of the classes you’ve taken back in undergraduate. How do you Choose an Interpolation Method?

Now to resize the image, we must keep in mind preserving the aspect ratio. Project Structureīefore we get started implementing our Python script for this tutorial, let’s first review our project directory structure:įigure 2: Displaying the original image to screen. And decreasing the size of the image leaves us with fewer pixels to process which saves time when working with image processing algorithms or deep learning models. That’s why you can see the image is been stretch either along the $ x $- axis or along the $ y $ – axis.Īpart from the aspect ratio, we also need to keep in mind, what interpolation method to use when resizing the image.Īs increasing the size of the pixels requires us to fill in the gaps of pixels we don’t even know exists. And on the right, we have both of the resized images without considering the aspect ratio of the image. And not having this in mind, can lead to having a squished or compressed image: Figure 1: Neglecting the aspect ratio of an image while resizing. Most of the times, a common mistake people make when resizing is neglecting the aspect ratio - which is the ratio of an image’s width to its height. Resizing, or also known as scaling refers to the process of either increasing or decreasing the size of an image in response to it’s width and height. What is Resizing and Why should you consider the Aspect Ratio ?
