I am trying to read an RGB image using the skimage.io.imread. But after reading the image, I found that the image shape is wrong, print(img.shape)
shows that
the image shape is (2,)
. The complete code to show the problem is:
from skimage import io
img = io.imread(path/to/the/image)
print(img.shape)
I also tried to read the image using opencv's python package, the returned shape is correct (height*width*3).
The skimage version used is 0.12.3, can someone explain is there anything wrong with my way using the package or is this really a bug?
Click the link for the test image
Edit1
The test image is altered when it is uploaded, the unaltered version is here. I have also opened an issue on the skimage github repo, and it turns out that the test image is a two-frame image, but the second frame is empty. You can consider this image a "corrupted" image.
In order to read the right image, you can use this workaround, img = io.imread(/path/to/the/image, img_num=0)
.
You can fix this issue by enforcing
skimage.io.imread()
to use matplotlib:Your image is likely to be a multi object JPG. If you try to read it using PIL (which is the default plugin) you get a NumPy array which consists of two objects. The first object is the image itself and the second one might be a thumbnail, but PIL does not handle it properly:
Take a look at this thread to find out more on this problem.