transform.py 文件源码

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

项目:Imagyn 作者: zevisert 项目源码 文件源码
def pil_to_skimage(img):
    """
    Convert PIL image to a Skimage image
    :param img: PIL image object
    :return: Skimage 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
    img.save(temp.name, 'JPEG')

    # Read the image as a SciKit image object
    ski_img = io.imread(temp.name, plugin='pil')

    # Close the file
    temp.close()

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

    return ski_img
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号