PIL.Image模块中的各种图像大小调整算法之间有什么区别? [英] What's the difference between various image resizing algorithms in the module of PIL.Image?

查看:1242
本文介绍了PIL.Image模块中的各种图像大小调整算法之间有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Image.resize 中所述,多个方法来调整图像大小.例如,PIL.Image.NEARESTPIL.Image.BILINEARPIL.Image.BICUBIC等.但是在 util.py 中进行语义分割,Image.ANTIALIAS当目标图像尺寸小于源图像时,使用Image.BICUBIC;当目标图像较大时,使用Image.BICUBIC,甚至使用Image.LINEAR.它们之间有什么区别?

As described in Image.resize, there are multiple mothods to resize an image. For eexample, PIL.Image.NEAREST, PIL.Image.BILINEAR, PIL.Image.BICUBIC et al. But in util.py for semantic segmentation, Image.ANTIALIAS is used when target image size is smaller than source image, and Image.BICUBIC is used when target image is larger, even Image.LINEAR is also used. What's the difference among them?

推荐答案

这些文档在已添加一些版本的发行说明.例如:

These are described in detail in the docs under Concepts (and also in the release notes for the version where some were added. For example:

NEAREST

从输入图像中选择一个最近的像素.忽略所有其他输入像素.

Pick one nearest pixel from the input image. Ignore all other input pixels.

BILINEAR

要调整大小,请对所有可能影响输出值的像素使用线性插值计算输出像素值.对于其他变换,使用输入图像中2x2环境上的线性插值.

For resize calculate the output pixel value using linear interpolation on all pixels that may contribute to the output value. For other transformations linear interpolation over a 2x2 environment in the input image is used.

BICUBIC

要调整大小,请对所有可能影响输出值的像素使用三次插值法计算输出像素值.对于其他变换,在输入图像中使用4x4环境的三次插值.

For resize calculate the output pixel value using cubic interpolation on all pixels that may contribute to the output value. For other transformations cubic interpolation over a 4x4 environment in the input image is used.

此图:

另请参见 :

Antialias重命名为Lanczos

Antialias renamed to Lanczos

这篇关于PIL.Image模块中的各种图像大小调整算法之间有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆