图像插值算法
最近使用pytorch对图像进行变换遇到一个
warning:"Argument interpolation should be of type InterpolationMode instead of int. "
也就是这个函数
transforms.Resize(self.height, self.width , interpolation=1)
这个warning就是说参数不能在传数字了了,应该填入InterpolationMode ,查看源码,torchvision说下一个版本更新,会弃用数字参数,应该填入枚举值。目前是兼容两种写法,官方转化数字成枚举值的代码如下:
def _interpolation_modes_from_int(i: int) -> InterpolationMode:
inverse_modes_mapping = {
0: InterpolationMode.NEAREST,
2: InterpolationMode.BILINEAR,
3: InterpolationMode.BICUBIC,
4: InterpolationMode.BOX,
5: InterpolationMode.HAMMING,
1: InterpolationMode.LANCZOS,
}
return inverse_modes_mapping[i]
部分图像插值算法如下:
[链接]
最近邻插值
双线性插值
Lanzoc插值