02图片缩放2

2019-07-14  本文已影响0人  犬夜叉写作业

第一步:获取图片信息
第二步:创建孔模板
第三步:重新计算xy的值

# 1 info 2 空白模版 3 xy
import cv2
import numpy as np
img = cv2.imread('image0.jpg',1)
imgInfo = img.shape
height = imgInfo[0]
width = imgInfo[1]
dstHeight = int(height/2)
dstWidth = int(width/2)
dstImage = np.zeros((dstHeight,dstWidth,3),np.uint8)#0-255 
for i in range(0,dstHeight):#行
    for j in range(0,dstWidth):#列 
        iNew = int(i*(height*1.0/dstHeight))
        jNew = int(j*(width*1.0/dstWidth))
        dstImage[i,j] = img[iNew,jNew]
cv2.imshow('dst',dstImage)
cv2.waitKey(0)
# 1 opencv API resize 2 算法原理 3 源码 

上一篇 下一篇

猜你喜欢

热点阅读