小编Jam*_*mes的帖子

使用 OpenCV Python 调整图像大小的最佳方法

我想根据百分比调整图像大小,并使其尽可能接近原始图像,同时将噪音和失真降至最低。调整大小可以向上或向下,就像我可以缩放到原始图像大小的 5% 或 500%(或作为示例给出的任何其他值)

这就是我尝试过的,我需要对调整大小的图像进行绝对最小的更改,因为我将使用它与其他图像进行比较

def resizing(main,percentage):
    main = cv2.imread(main)
    height = main.shape[ 0] * percentage
    width = crop.shape[ 1] * percentage
    dim = (width,height)
    final_im = cv2.resize(main, dim, interpolation = cv2.INTER_AREA)
    cv2.imwrite("C:\\Users\\me\\nature.jpg", final_im)
Run Code Online (Sandbox Code Playgroud)

python opencv image image-resizing python-imaging-library

5
推荐指数
1
解决办法
1万
查看次数