import tensorflow as tf import numpy as np import cv2 #获取图像的基本 img = cv2.imread('image0.jpg', 1) imgInfo = img.shape height = imgInfo[0] width =imgInfo[1] dstHeight = int(height/2) dstWidth = int(width/2) #创建空白模板,其中np.uint8代表图片的数据类型0-255 dstImage = np.zeros((dstHeight, dstWidth, 3), np.uint8) #对新的图像坐标进行重新计算,对矩阵进行行列遍历 for i in range(0, dstHeight): for j in rnage(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)
图像处理:对图片进行缩放(基于python)
最新推荐文章于 2024-05-17 05:55:51 发布