python+opencv:縮小画像サイズを定義する3つの方法:メタグループ、ソース画像、係数


# usr/bin/env python
# coding: utf-8

# 2018 6 15 23:29:13
# 2018 6 16 10:16:49
# python_5

import cv2
import numpy as np

img = cv2.imread('cat.jpg')

#        

#      :                
resImg1 = cv2.resize(img, (300,300), interpolation=cv2.INTER_CUBIC)
# resize     :
#    ,img
# (300,300)         ,        。        
#      ,interpolation         ,               
# ITER_CUBIC     ,        ,       

#      :      shape    
resImg2 = cv2.resize(img,(img.shape[1],img.shape[0]), interpolation=cv2.INTER_CUBIC)
#               ,             ,          
#       shape         


#      :        
img1 = cv2.resize(img, None, fx=0.1,fy=0.5,interpolation=cv2.INTER_CUBIC)
#            ,           。
# fx        x      ,     ,         。
# fy      。     1 ,    ,  1     。


cv2.imshow('img', img)
cv2.imshow('resImg', resImg1)
cv2.imshow('resImg2', resImg2)
cv2.imshow('img1', img1)
cv2.waitKey()

cv2.destroyAllWindows()
#     :           ,