赞
踩
import cv2 def opencvInterpolation(): img = cv2.imread('./koala.jpg') # 图片缩小一半 width = int(img.shape[1]*50/100) height = int(img.shape[0]*50/100) whsize = (width , height) minSize = cv2.resize(img, whsize,cv2.INTER_AREA) cv2.imshow("img:", img) cv2.imshow("minsize:",minSize) cv2.waitKey(0) cv2.destroyAllWindows() fx = 1.5 fy = 1.5 resized1 = cv2.resize(minSize, dsize=None, fx=fx, fy=fy, interpolation=cv2.INTER_NEAREST) resized2 = cv2.resize(minSize, dsize=None, fx=fx, fy=fy, interpolation=cv2.INTER_LINEAR) print('Resized Dimensions : ', minSize.shape) cv2.imshow("Resized image", minSize) cv2.imshow("INTER_NEAREST image", resized1) cv2.imshow("INTER_LINEAR image", resized2) cv2.waitKey(0) cv2.destroyAllWindows() if __name__ == '__main__': opencvInterpolation()
参考:https://www.cnblogs.com/yibeimingyue/p/11485732.html
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。