1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| import cv2 import numpy as np import matplotlib.pyplot as plt
img = cv2.imread('cat_dog.jpg') img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
half = cv2.resize(img, (0, 0), fx=0.2, fy=0.2) bigger = cv2.resize(img, (600, 600))
stretch_near = cv2.resize( img, (700, 600), interpolation=cv2.INTER_LINEAR)
titles = ['Original', 'Half', 'Bigger', 'Interpolation Nearest'] images = [img, half, bigger, stretch_near] count = 4
for i in range(count): plt.subplot(2, 2, i + 1) plt.title(titles[i]) plt.imshow(images[i])
plt.show()
|