Search code examples
pythonpython-3.xpython-2.7scikit-image

How to know shape of image collection object


I am reading all images of a folder from following code

from skimage.io import imread_collection
img_dir = 'cats/*.jpg'
col = imread_collection(img_dir)

for getting shape or size of col i used following:

col.shape

but get AttributeError: 'ImageCollection' object has no attribute 'shape'

how to solve this problem


Solution

  • ImageCollection is a list of images, so you have to access individual images with their index.

    From the docs:

    >>> coll = io.ImageCollection(data_dir + '/chess*.png')
    >>> len(coll)
    2
    >>> coll[0].shape
    (200, 200)