在 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/