Coffee_resize.py 468 B

1234567891011121314151617181920
  1. import cv2
  2. import os
  3. image_size = 150
  4. source_path = "test/"
  5. target_path = "test/"
  6. if not os.path.exists(target_path):
  7. os.makedirs(target_path)
  8. image_list = os.listdir(source_path)
  9. i = 0
  10. for file in image_list:
  11. i = i + 1
  12. image_source = cv2.imread(source_path + file)
  13. image = cv2.resize(image_source, (image_size, image_size), 0, 0, cv2.INTER_LINEAR)
  14. cv2.imwrite(target_path + ('0'+'_'+str(i)) + ".png", image)
  15. print("done")