inputdata.py 文件源码

python
阅读 90 收藏 0 点赞 0 评论 0

项目:cnn-bnn 作者: jpdz 项目源码 文件源码
def resize_save(path, size):
  path = os.path.join(os.getcwd(), path)
  images_files = os.listdir(path)
  el = (np.array([[0,1],[1,1]])).astype(np.float32)
  for i, image in enumerate(images_files):
    image_file =  os.path.join(path,image)
    try:
      im = (ndimage.imread(image_file)).astype(np.float32)
      np.putmask(im, im < 100, 0)
      im = ndimage.binary_dilation(im, structure=el)
      im = (misc.imresize(im, (size, size))).astype(np.uint8)
      new_im = Image.fromarray(im)
      new_im.save(image_file)
    except Exception as e:
      print('Could not read:', image_file, ':', e, '- it\'s ok, skipping.')
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号