import scipy.misc
from glob import glob
import numpy as np
import os
import matplotlib.pyplot as plt
path = 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.5
if 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()
图像处理--bicubic(双三次插值)
最新推荐文章于 2024-05-24 10:15:12 发布