一、bicubic插值法
import PIL.Image as pil_image
scale = 4 # 下采样的倍数
image_file = 'baby.png'
image = pil_image.open(image_file).convert('RGB')
image_width = (image.width // scale) * scale
image_height = (image.height // scale) * scale
hr = image.resize((image_width, image_height), resample=pil_image.Resampling.BICUBIC)
hr.save(image_file.replace('.', '_hr.'))
lr = hr.resize((hr.width // scale, hr.height // scale), resample=pil_image.Resampling.BICUBIC)
bicubic = lr.resize((lr.width * scale, lr.height * scale), resample=pil_image.Resampling.BICUBIC)
bicubic.save(image_file.replace('.', '_bicubic_x{}.'.format(scale)))