You can find the shape of an image in Python using OpenCV by following the given steps. I highly recommend you get the “Computer Vision: Models, Learning, and Inference Book” to learn Computer Vision.
Step 1
If OpenCV is not installed, then first install it using this code.
!pip install opencv-python
Step 2
# Import the OpenCV library import cv2 # Read the Image image = cv2.imread('man.jpg') # Display the shape of the image print(image.shape)
Output: 1107 height, 1280 width, and the number of channels is 3 (Red, Green, Blue).
(1107, 1280, 3)