transform.py 文件源码

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

项目:Imagyn 作者: zevisert 项目源码 文件源码
def skimage_to_pil(img):
    """
    Convert Skimage image to a PIL image
    :param img: Skimage image object
    :return: PIL image object
    """
    # Get the absolute path of the working directory
    abspath = os.path.dirname(__file__)

    # Create a temp file to store the image
    temp = tempfile.NamedTemporaryFile(suffix=".jpg", delete=False, dir=abspath)

    # Save the image into the temp file
    io.imsave(temp.name, img)

    # Read the image as a PIL object
    pil_img = Image.open(temp.name)
    pil_img.load()

    # Close the file
    temp.close()

    # Delete the file
    os.remove(temp.name)

    return pil_img
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号