-
# -- coding:utf-8 -- import cv2 import math import numpy as np import os
# jpg文件重命名 list_name = "" path_in = "HDimg-ztx" + list_name + "/" count = -1 print(path_in) for file in os.listdir(path_in): print("Excuted!\t") count += 1 if file.startswith("._") or file.startswith(".DS"): print("file:", file) os.remove(path_in + file) else: if os.path.exists(os.path.join(path_in, str(count) + ".jpg")): os.rename(os.path.join(path_in, str(count) + ".jpg"), os.path.join(path_in, "for_next" + str(count) + ".jpg")) print("Pass to next round!\t") else: pass count = -1 for file in os.listdir(path_in): count += 1 os.rename(os.path.join(path_in,file), os.path.join(path_in, str(count) + ".jpg")) print("Renamed!\t") print(count) #img_num = count # #for num in range(img_num): # filename_in = path_in + str(num + 1) + "_" + list_name + ".jpg" # print("filename_in:", filename_in) # img = cv2.imread(filename_in) # width, height, chs = img.shape # # crop_size = 200 # crop_xnum = int(math.floor(width / crop_size)) # crop_ynum = int(math.floor(height / crop_size)) # crop_img = np.zeros((crop_size, crop_size, chs), dtype=np.float) # # print(crop_size, crop_xnum, crop_ynum) # path_out = "patch" + list_name + "/" # for i in range(crop_xnum): # for j in range(crop_ynum): # crop_img = img[i * crop_size : (i + 1) * crop_size, j * crop_size : (j + 1) * crop_size, :] # filename_out = path_out + "img" + list_name + str(num + 1) + '_' + str(i) + '_' + str(j) + '.jpg' # print(filename_out) # cv2.imwrite(filename_out, crop_img) #print("Work done.")
namelist_20181031.py
最新推荐文章于 2023-06-17 10:44:32 发布