Reputation: 410
So I was working with skimage for some image preprocessing (i'm very new to it). I have a PIL
Image object and wanted to convert to a skimage image with skimage.io.imread()
. I know that I can just save the image and then run imread
on that file, but I was wondering if there was a way I could read the PIL
Image object from the code itself. I tried to run imread
on the PIL Image object itself but I end up getting errors.
OSError: Cannot understand given URI: <PIL.PngImagePlugin.PngImageFile image mode=RGBA size=192....
Anyone know how I can solve this in skimage.
Upvotes: 0
Views: 3069
Reputation: 11
You may review imageio documentation related to the function imread for including in your code the attribute format and code as follows just in case the image format is PNG: imageio.imread(filename, format = 'PNG')
Upvotes: 1
Reputation: 207345
Scikit-Image stores images as Numpy arrays, so you just need to make a Numpy array from your PIL Image:
ImageForScikit = np.array(YourPILImage)
Upvotes: 1