我想使用 OpenCV python 库调整图像大小。
它有效,但图像质量很差。
我必须说,我想将这些图像用于照片共享网站,因此质量是必须的。
这是我目前的代码:
[...]
_image = image
height, width, channels = _image.shape
target_height = 1000
scale = height/target_height
_image = cv2.resize(image, (int(width/scale), int(height/scale)), interpolation = cv2.INTER_AREA)
cv2.imwrite(local_output_temp_file,image, (cv2.IMWRITE_JPEG_QUALITY, 100))
[...]
不知道有没有其他参数可以用来指定图像的质量。
谢谢。
最佳答案
尝试使用更精确的插值技术,例如 cv2.INTER_CUBIC
或 cv2.INTER_LANCZOS64
.也尝试切换到 scikit-image
.文档更好,lib 的功能更广泛。它有 6 种插值模式可供选择:
关于python - 使用 Opencv Python 调整图像大小并保持质量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59246231/