on reading tiff file using skimage

image-processing, python, scikit-image, scipy, tiff

Solution

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.

Problem

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?

Original source