python - openCV 相当于 PIL resize ANTIALIAS?

标签 python python-2.7 opencv python-imaging-library image-resizing

在 PIL 中,我所看到的最高质量调整大小似乎是:

img = img.resize((n1, n2), Image.ANTIALIAS)

对于 openCV 这似乎是这样做的方式:

small = cv2.resize(image, (0,0), fx=0.5, fy=0.5) 

所以我的问题是,是否需要额外的参数,或者这是否会在质量损失最小的情况下减小尺寸?

最佳答案

来自documentation :

To shrink an image, it will generally look best with CV_INTER_AREA interpolation, whereas to enlarge an image, it will generally look best with CV_INTER_CUBIC (slow) or CV_INTER_LINEAR (faster but still looks OK).

调整大小的默认值是 CV_INTER_LINEAR。将插值更改为 CV_INTER_AREA,因为您希望缩小图像:

small = cv2.resize(image, (0,0), fx=0.5, fy=0.5, interpolation = cv2.INTER_AREA)

您可能希望比较两种插值的结果,以目视验证您获得的是最佳质量。

关于python - openCV 相当于 PIL resize ANTIALIAS?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33577732/

相关文章:

python - 强制覆盖字段/方法?

python - numpy genfromtxt 转换器未知列数

python - 如何从 Django/postgreSQL 中的数据库中随机获取一个项目?

python - 如何从 `nl` 脚本求解器中从 `pyomo` 获取 `pyomo` 文件?

python - 尝试使用 pandas 读取 csv 时遇到问题?

c++ - OpenCV::dnn::readNet 抛出异常

c++ - 合并 IplImage 和 cv::Mat 的设计决定是什么?

c - 尝试在C上编写UDP流网络摄像头服务

python - 带有字符数组的 Numpy ufunc.at

python - Python 2 和 Python 3 中 exec 函数的行为