Calculate the area of an image using Matplotlib
Let us see how to calculate the area of an image in Python using Matplotlib.
- Import the matplotlib.pyplot module.
- Import an image using the imread() method.
- Use the shape attribute of the image to get the height and width of the image. It fetches the number of channels in the image.
- Calculate the area as, area = height * width.
- Display the area.
Example 1: Consider the following image :
Area of the image is : 50244
Example 2: Consider the following image :
Area of the image is : 213200