import cv2
import numpy as np
img = cv2.imread('flower.jpg');
# To resize the image keeping aspect ratio
rows=100.0/img.shape[1] #img.shape[1] gives the number of rows
dimensions = (100, int(img.shape[0]*rows))
resized = cv2.resize(img, dimensions, interpolation = cv2.INTER_AREA)
cv2.imshow("Original", img)
cv2.imshow("Resized", resized)
cv2.waitKey(0)
cv2.destroyAllWindows
Output:
Resized Image:
import numpy as np
img = cv2.imread('flower.jpg');
# To resize the image keeping aspect ratio
rows=100.0/img.shape[1] #img.shape[1] gives the number of rows
dimensions = (100, int(img.shape[0]*rows))
resized = cv2.resize(img, dimensions, interpolation = cv2.INTER_AREA)
cv2.imshow("Original", img)
cv2.imshow("Resized", resized)
cv2.waitKey(0)
cv2.destroyAllWindows
Output:
Resized Image:
No comments:
Post a Comment