# We want the new image to be 60% of the original imageĬv2.destroyAllWindows() Original shape: (400, 600, 3) This way, you are sure that the aspect ratio of the original image will be the same as that of the new image. For example, if you want your new image to be half of the original image, then the scaling factor should be 0.5. Basically, a scaling factor is a number by which you multiply the dimension of the image. We can resize an image by using a scaling factor. Resizing with a Scaling Factor (Preserve Aspect Ratio) New_image = cv2.resize(image, dimensions, interpolation=cv2.INTER_LINEAR)Īs you can see, the new image is a bit distorted because we didn't take into account the aspect ratio. We can downscale or upscale an image when resizing it. Let's downscale the original image to 300x300 pixels: import cv2 Resizing with a Specific Width and Height (Don't Preserve Aspect Ratio)
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |