saliency.py 文件源码

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

项目:saliency-bms 作者: fzliu 项目源码 文件源码
def main(args):
    """
        Entry point.
    """

    # load the image
    img = imread(args.input)
    if img.ndim == 2:
        img = gray2rgb(img)
    elif img.shape[2] == 4:
        img = img[:, :, :3]
    upper_dim = max(img.shape[:2])
    if upper_dim > args.max_dim:
        img = rescale(img, args.max_dim/float(upper_dim), order=3) 

    # compute saliency
    start = timeit.default_timer()
    img_sal = compute_saliency(img)
    runtime = timeit.default_timer() - start
    print("Took {0} seconds.".format(runtime))

    # save image
    (fname, ext) = os.path.splitext(args.input)
    out_path = fname + "_saliency" + ext
    imsave(out_path, img_sal)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号