dataset.py 文件源码

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

项目:stegasawus 作者: rokkuran 项目源码 文件源码
def crop_images(path_images, path_output, dimensions, centre=True):
    """
    Batch crop images from top left hand corner to dimensions specified. Skips
    images where dimensions are incompatible.
    """
    print 'cropping images...'
    for i, filename in enumerate(os.listdir(path_images)):
        try:
            image = io.imread('{}{}'.format(path_images, filename))
            cropped = crop_image(image, dimensions, centre=centre)
            io.imsave(
                fname='{}{}'.format(path_output, filename),
                arr=cropped
            )
            print '{}: {}'.format(i, filename)
        except IndexError:
            print '{}: {} failed - dimensions incompatible'.format(i, filename)

    print 'all images cropped and saved.'
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号