python图像下采样

import os
import cv2 as cv
root = "D:\\dataset\\UCMerced_train_HR\\"
save_rot = "D:\\dataset\\UCMerced_train_x8\\"
names = os.listdir(root)
scale = 8
for name in names:
    original_name = root + name
    save_name = save_rot + name
    img = cv.imread(original_name)
    h, w, c = img.shape
    downsample_img = cv.resize(img, (w//scale, h//scale), interpolation=cv.INTER_CUBIC)
    cv.imwrite(save_name, downsample_img)
print("over")

发布一段python图像下采样的代码,小伙伴要是有更好的解决方法,可以在评论区交流~

你可能感兴趣的:(python,opencv,计算机视觉)