Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

on reading tiff file using skimage

I am using the following code to read a set of tiff files from a folder

from PIL import image
from skimage import io
io.use_plugin('pil')
images = os.listdir(train_data_path)
for image_name in images:
    img = io.imread(os.path.join(train_data_path, image_name))

When running the above code, most of the files were reading smoothly. But I found the program will generate some warning message for some specific file

/devl/lib/python3.4/site-packages/scikit_image-0.12.3-py3.4-linux-x86_64.egg/skimage/external/tifffile/tifffile.py:1794: RuntimeWarning: py_decodelzw encountered unexpected end of stream                                  
strip = decompress(strip)      

When opening that file, I cannot see any explicit difference with others. What can the reason underlying this?

like image 956
user785099 Avatar asked Oct 20 '16 16:10

user785099


People also ask

How do you show images in Skimage?

Just add matplotlib. pyplot. show() after the io. imshow(coins) line.

Is Skimage and Scikit image same?

scikit-image (a.k.a. skimage ) is a collection of algorithms for image processing and computer vision.


1 Answers

I had the same error and resolved it by explicitly setting the plugin in the call to imread:

img = imread(img_path, plugin='pil')

According to the skimage.io.imread docs:

plugin : str, optional Plugin to load. Defaults to None, in which case the first matching plugin is used.

So, in may case, imread was finding the Tifffile plugin, which was producing the error (for some reason), whereas PIL reads the files correctly. I do not know the source of the Tifffile error.

like image 200
Chris Parry Avatar answered Sep 28 '22 00:09

Chris Parry