The scikit-image and Pillow (PIL) are two popular Python libraries widely used in image processing tasks. While scikit-image provides a rich set of functionalities for manipulating and analyzing images, PIL offers robust tools for image rendering, editing, and saving. In certain scenarios, it becomes essential to convert Scikit image to PIL image. Fortunately, this conversion process is pretty straightforward. This tutorial shows how to do that using Python.
Prepare environment
- Install the following packages using
pip
:
pip install scikit-image
pip install Pillow
Code
In the following code, we load the image using the function provided by scikit-image library. It returns a NumPy array representing the image, where each pixel's RGB values are stored as an array. Next, we create a PIL image object from the NumPy array. That's it, we got an image that can be further processed or saved using PIL's functionality.
from PIL import Image
from skimage import io
skiImg = io.imread('test.jpg')
pilImg = Image.fromarray(skiImg)
Leave a Comment
Cancel reply