首页 > 编程知识 正文

bicubic插值算法

时间:2023-05-03 21:28:53 阅读:184935 作者:2234

import scipy.miscfrom glob import globimport numpy as npimport osimport matplotlib.pyplot as pltpath = glob('图像路径')imgs_lr = []for img_path in path: img = scipy.misc.imread(img_path, mode='RGB').astype(np.float) # 这个尺寸只是展示图片的大小,跟像素没有关系 h = img.shape[0] w = img.shape[1] low_h, low_w = int(h / 4), int(w / 4) # interp 参数可选择 Interpolation to use for re-sizing ('nearest', 'lanczos', 'bilinear', 'bicubic' or 'cubic'). img_lr = scipy.misc.imresize(img, (low_h, low_w), interp='bicubic') imgs_lr.append(img_lr)imgs_lr = np.array(imgs_lr) / 127.5 - 1.imgs_lr = 0.5 * imgs_lr + 0.5if not os.path.exists('images/bicubic'): os.makedirs('images/bicubic')for i in range(len(imgs_lr)): fig = plt.figure() plt.imshow(imgs_lr[i]) fig.savefig('images/bicubic/%d_low.png' % (i)) plt.close()

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。