앎을 경계하기

DAFIT/907 - OpenCV 다루기 첫걸음

<DAFIT> 07 OpenCV 다루기 첫걸음 - 06 영상 크기 조절

양갱맨 2019. 11. 26. 02:37

 

이번에는 resizing 문제이다.

import cv2
from google.colab.patches import cv2_imshow

img_path = '/content/drive/My Drive/다핏문제/907/lena.jpg'
img = cv2.imread(img_path,1)
height, width = img.shape[:2]
down_img = cv2.resize(img,(height//2,width//2))
cv2_imshow(down_img)

up_img = cv2.resize(img, (height*2, width*2))
cv2_imshow(up_img)

img_list = []
for i in range(100):
    img_list.append(cv2.resize(img,(height+i,width+i)))
    
cv2_imshow(img_list[0])
cv2_imshow(img_list[-1])

sh = cv2.resize(img, None, fx=5, fy=5, interpolation=cv2.INTER_AREA)
cv2_imshow(sh)
sh1 = cv2.resize(img, None, fx=5, fy=5, interpolation=cv2.INTER_CUBIC)
cv2_imshow(sh1)
sh2 = cv2.resize(img, None, fx=5, fy=5, interpolation=cv2.INTER_LINEAR)
cv2_imshow(sh2)

INTER_AREA 적용,

INTER_CUBIC 적용,

INTER_LINEAR 적용,