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
评论列表
文章目录