Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PIL.Image vs skimage.io: When to use each, and which (if one) is prefered over the other in general?

I have been using Image for opening and getting pixel info, and have read things like "PIL is the future and blabla..", but I have seen that skimage is extensively used.

Which one should I use for general image processing? I would feel more comfortable with this question answered..

like image 289
Matias Haeussler Avatar asked Nov 30 '25 02:11

Matias Haeussler


1 Answers

In general it is safe to say that Pillow (install this rather than PIL as Pillow is maintained) is the one to go for if you are manipulating Image->Image as this is its main focus.

However, if you are reading an image for manipulation by other science kit based tools, such as machine learning, then go for skimage.io or better its replacement imageio thanks to @cris-luengo for pointing this our and you are likely to have to do less conversion back and forth.

The other consideration is the size:

Results of pip download scikit-image to a Windows 64 machine:

21/10/2022  06:20         3,363,278 imageio-2.22.2-py3-none-any.whl
21/10/2022  06:20         2,023,640 networkx-2.8.7-py3-none-any.whl
21/10/2022  06:20        14,643,698 numpy-1.23.4-cp310-cp310-win_amd64.whl
21/10/2022  06:20            40,750 packaging-21.3-py3-none-any.whl
21/10/2022  06:20         3,276,402 Pillow-9.2.0-cp310-cp310-win_amd64.whl
21/10/2022  06:20            98,338 pyparsing-3.0.9-py3-none-any.whl
21/10/2022  06:20         4,162,789 PyWavelets-1.4.1-cp310-cp310-win_amd64.whl
21/10/2022  06:20        12,044,719 scikit_image-0.19.3-cp310-cp310-win_amd64.whl
21/10/2022  06:20        40,141,232 scipy-1.9.3-cp310-cp310-win_amd64.whl
21/10/2022  06:20           210,312 tifffile-2022.10.10-py3-none-any.whl
              10 File(s)     80,005,158 bytes

Results of pip download Pillow to a Windows 64 machine:

21/10/2022  06:22         3,276,402 Pillow-9.2.0-cp310-cp310-win_amd64.whl

Note that the download of scikit-image includes Pillow as a dependency so you are going to be "using" Pillow whichever way you go but a lot depends on how accessible and in what form it is accessible.

If you are going for the Scipy route anyway you are likely to need all or most of that 80 MB but if you are not then Pillow at 3 MB is a much lighter space commitment.

like image 120
Steve Barnes Avatar answered Dec 02 '25 17:12

Steve Barnes