util.py 文件源码

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

项目:lung-cancer-detector 作者: YichenGong 项目源码 文件源码
def to_rgb(img):
    """
    Converts the given array into a RGB image. If the number of channels is not
    3 the array is tiled such that it has 3 channels. Finally, the values are
    rescaled to [0,255) 

    :param img: the array to convert [nx, ny, channels]

    :returns img: the rgb image [nx, ny, 3]
    """
    img = np.atleast_3d(img)
    channels = img.shape[2]
    if channels < 3:
        img = np.tile(img, 3)

    img[np.isnan(img)] = 0
    img -= np.amin(img)
    img /= np.amax(img)
    img *= 255
    return img
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号