img_utils.py 文件源码

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

项目:PixelDCN 作者: HongyangGao 项目源码 文件源码
def imsave(image, path):
    label_colours = [
        (0,0,0),
        # 0=background
        (128,0,0),(0,128,0),(128,128,0),(0,0,128),(128,0,128),
        # 1=aeroplane, 2=bicycle, 3=bird, 4=boat, 5=bottle
        (0,128,128),(128,128,128),(64,0,0),(192,0,0),(64,128,0),
        # 6=bus, 7=car, 8=cat, 9=chair, 10=cow
        (192,128,0),(64,0,128),(192,0,128),(64,128,128),(192,128,128),
        # 11=diningtable, 12=dog, 13=horse, 14=motorbike, 15=person
        (0,64,0),(128,64,0),(0,192,0),(128,192,0),(0,64,128)]
        # 16=potted plant, 17=sheep, 18=sofa, 19=train, 20=tv/monitor
    images = np.ones(list(image.shape)+[3])
    for j_, j in enumerate(image):
        for k_, k in enumerate(j):
            if k < 21:
                images[j_, k_] = label_colours[int(k)]
    scipy.misc.imsave(path, images)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号