图像处理--bicubic(双三次插值)

11 篇文章 0 订阅
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()

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值