How to find out the dimensions of an image

I am using this python code to read this image file

image = img.imread('/content/drive/My Drive/Colab Notebooks/rusty.png')

How do I determine the dimension of this image array? I printed out len(image), len(image[0]) and len(image[0][0]) Which probably shows what's the len of each submatrix...

Topic python

Category Data Science


convert list to nparray:

import numpy as np

image=np.array(image) 
print(image.shape)

Use shape to find the dimensions of an object Reference link

image.shape

images are stored in numpy ndarray. To get the image shape or size, use ndarray.shape to get the dimensions of the image. Then, you can use index on the dimensions variable to get width, height and number of channels for each pixel.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.