image.py 文件源码

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

项目:tensorlight 作者: bsautermeister 项目源码 文件源码
def write(filepath, image):
    """Saves an image or a frame to the specified path.
    Parameters
    ----------
    filepath: str
        The path to the file.
    image: ndarray(float/int)
        The image data.
    value_range: int (e.g. VALUE_RANGE_0_1)
        The value range of the provided image data.
    """
    dirpath = os.path.dirname(filepath)
    if not os.path.exists(dirpath):
        os.makedirs(dirpath)

    if image.shape[2] == 3:
        image = cast(image)
        image = cv2.cvtColor(image, cv2.COLOR_RGB2BGR)

    factor = 1
    if is_float_image(image):
        factor = 255

    cv2.imwrite(filepath, image * factor)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号