imclean.py 520 B

1234567891011121314151617
  1. '''Created Aug 21, 2021 deeejas'''
  2. import cv2
  3. def im_clean(img_path, dst_path):
  4. # read image
  5. img = cv2.imread(img_path)
  6. img = img[270:600, 740:1060]
  7. scale_percent = 220 # percent of original size
  8. width = int(img.shape[1] * scale_percent / 100)
  9. height = int(img.sthape[0] * scale_percent / 100)
  10. dim = (width, height)
  11. # resize image
  12. img = cv2.resize(img, dim, interpolation=cv2.INTER_AREA)
  13. # improve quality
  14. dst = cv2.detailEnhance(img, 10, 1)
  15. cv2.imwrite(dst_path, dst)